非季節性時間序列的自動 ARIMA 模型
在影片中,你學到 auto.arima() 函式會根據時間序列自動選出合適的「自我迴歸整合移動平均(autoregressive integrated moving average, ARIMA)」模型,就像 ets() 會為 ETS 模型做的事一樣。summary() 函式可以提供一些額外的洞見:
> # p = 2, d = 1, p = 2
> summary(fit)
Series: usnetelec
ARIMA(2,1,2) with drift
...
在這個練習中,你會為已載入的 austa 序列自動選擇一個 ARIMA 模型。austa 包含 1980–2015 年澳洲的年度國際訪客人數。接著你會檢查殘差(記得:p 值大於 0.05 表示資料類似白噪音),並產生一些預測。除了建模的函式不同外,其他步驟與你在 ETS 預測中的作法相同。
本練習屬於課程
R 的時間序列預測
練習說明
- 使用新介紹的函式,對
austa序列擬合自動 ARIMA 模型。將結果存為fit。 - 使用適當的函式檢查所得模型的殘差是否看起來像白噪音。若是,將
TRUE指派給residualsok;若否,指派FALSE。 - 對模型套用
summary(),檢視配適的係數。 - 根據
summary()的結果,AICc 的數值(小數點後兩位)是多少?使用了幾階差分?分別指派給AICc與d。 - 最後,使用管線運算子,繪製此模型對未來 10 期的預測圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit an automatic ARIMA model to the austa series
fit <- ___
# Check that the residuals look like white noise
___
residualsok <- ___
# Summarize the model
___
# Find the AICc value and the number of differences used
AICc <- ___
d <- ___
# Plot forecasts of fit
fit %>% forecast(h = ___) %>% ___()