使用 auto.arima 模型 R 进行样本外预测

Make out-of-sample predictions using auto.arima model R

我正在尝试对时间序列进行样本外预测。因此,我使用以下方法估计了火车数据的 arima 模型:

      arma_fit <- auto.arima(tsOrders)
      forecast <- forecast(arma_fit, h = 1, level=95)

其中 tsOrders 是时间序列对象。此处,forecast 对象仅包含样本内拟合值。我想对测试数据集进行预测,我没有使用它来估计 arima 模型。有谁知道如何用这种方法做到这一点?

根据您的预测,您可以提前一步。增加 h 的值以进一步预测。

library(forecast)
set.seed(1)
tsOrders <- ts(rnorm(20, 10, 4))
arma_fit <- auto.arima(tsOrders)
forecast <- forecast(arma_fit, h = 10, level=95)
forecast
#>    Point Forecast    Lo 95    Hi 95
#> 21        10.7621 3.602318 17.92187
#> 22        10.7621 3.602318 17.92187
#> 23        10.7621 3.602318 17.92187
#> 24        10.7621 3.602318 17.92187
#> 25        10.7621 3.602318 17.92187
#> 26        10.7621 3.602318 17.92187
#> 27        10.7621 3.602318 17.92187
#> 28        10.7621 3.602318 17.92187
#> 29        10.7621 3.602318 17.92187
#> 30        10.7621 3.602318 17.92187

reprex package (v0.3.0)

于 2020-04-17 创建