模擬 ARMA 模型
就像影片中所示,任何平穩的時間序列都可以寫成白雜訊的線性組合。此外,任何 ARMA 模型都具有這種形式,因此用來建模平穩時間序列很合適。
R 提供了名為 arima.sim() 的簡單函式,可用來從 ARMA 模型產生資料。例如,要從參數為 0.9 的 MA(1) 產生 100 筆觀測值,其語法為 arima.sim(model = list(order = c(0, 0, 1), ma = .9 ), n = 100)。你也可以使用 order = c(0, 0, 0) 來產生白雜訊。
在這個練習中,你將從不同的 ARMA 模型產生資料。對每個指令,請產生 200 筆觀測值並繪圖顯示結果。
本練習屬於課程
R 中的 ARIMA 模型
練習說明
- 使用
arima.sim()與plot()產生並繪製白雜訊。 - 使用
arima.sim()與plot()產生並繪製參數為 0.9 的 MA(1)。 - 使用
arima.sim()與plot()產生並繪製參數為 1.5 與 -0.75 的 AR(2)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Generate and plot white noise
WN <-
# Generate and plot an MA(1) with parameter .9
MA <-
# Generate and plot an AR(2) with parameters 1.5 and -.75
AR <-