在R中使用`predict`与`forecast`预测ARIMA

机器算法验证 r 时间序列 预测 有马
2022-03-03 17:15:03

由 30 个值组成的数据存储在时间序列中time
在 上应用 ARIMA 建模后time,我使用forecast函数来预测未来值:

model = arima(time, order = c(3,2,1))
prediction = forecast.Arima(model,h=10)
prediction step is not working and showing error 
Error in ts(x) : object is not a matrix

如您在上面看到的,我收到一条错误消息。但如果我这样做

model = arima(time[1:25], order = c(3,2,1))
prediction = forecast.Arima(model,h=10)

有用。为什么会这样?

当我使用该predict功能时

model = arima(time, order = c(3,2,1))
prediction=predict(model,n.ahead=10)

它也有效。

对于 R 中的 ARIMA 模型,哪个函数更适合使用predict为什么forecast

1个回答

他们会给你同样的答案。但是Arima(not arima) 和forecastpredict 包的组合是具有附加功能的增强版本。

Arima调用stats::arima估计,但在返回的对象中存储更多信息。它还允许一些额外的模型功能,例如在具有单位根的模型中包含漂移项。

forecast调用stats::predict以生成预测。它将自动处理来自 的漂移项Arima它返回一个预测对象(而不是一个简单的列表),该对象对于绘制、显示、总结和分析结果很有用。