當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


R AirPassengers 1949 年至 1960 年每月航空公司乘客數量


R語言 AirPassengers 位於 datasets 包(package)。

說明

經典的 Box & Jenkins 航空公司數據。 1949 年至 1960 年每月國際航空旅客總數。

用法

AirPassengers

格式

每月時間序列,以千為單位。

例子

## Not run: 
## These are quite slow and so not run by example(AirPassengers)

## The classic 'airline model', by full ML
(fit <- arima(log10(AirPassengers), c(0, 1, 1),
              seasonal = list(order = c(0, 1, 1), period = 12)))
update(fit, method = "CSS")
update(fit, x = window(log10(AirPassengers), start = 1954))
pred <- predict(fit, n.ahead = 24)
tl <- pred$pred - 1.96 * pred$se
tu <- pred$pred + 1.96 * pred$se
ts.plot(AirPassengers, 10^tl, 10^tu, log = "y", lty = c(1, 2, 2))

## full ML fit is the same if the series is reversed, CSS fit is not
ap0 <- rev(log10(AirPassengers))
attributes(ap0) <- attributes(AirPassengers)
arima(ap0, c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period = 12))
arima(ap0, c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period = 12),
      method = "CSS")

## Structural Time Series
ap <- log10(AirPassengers) - 2
(fit <- StructTS(ap, type = "BSM"))
par(mfrow = c(1, 2))
plot(cbind(ap, fitted(fit)), plot.type = "single")
plot(cbind(ap, tsSmooth(fit)), plot.type = "single")

## End(Not run)

來源

Box, G. E. P.、Jenkins, G. M. 和 Reinsel, G. C. (1976) 時間序列分析、預測和控製。第三版。 Holden-Day。 G 係列。

相關用法


注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Monthly Airline Passenger Numbers 1949-1960。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。