季節性與循環性時間序列的自相關
當資料具有季節性或循環性時,ACF 會在季節性延遲或平均循環長度附近出現峰值。
你將透過繪圖來觀察這個現象:使用 sunspot.year 的年度太陽黑子序列(約 10–11 年的太陽循環),以及 hyndsight 的 Hyndsight 部落格每日流量(呈現 7 天的每週模式)。這兩個物件已載入到你的工作空間中。
本練習屬於課程
R 的時間序列預測
練習說明
- 繪製
sunspot.year的時間圖與 ACF 圖。 - 觀察 ACF 圖,在哪一個延遲值(x)可以找到最大的自相關(y)?將此值指定給
maxlag_sunspot。 - 繪製
hyndsight的時間圖與 ACF 圖。 - 觀察 ACF 圖,在哪一個延遲值(x)可以找到最大的自相關(y)?將此值指定給
maxlag_hyndsight。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the annual sunspot numbers
autoplot(___)
ggAcf(___)
# Save the lag corresponding to maximum autocorrelation
maxlag_sunspot <- ___
# Plot the traffic on the Hyndsight blog
___
___
# Save the lag corresponding to maximum autocorrelation
maxlag_hyndsight <- ___