简体   繁体   English

arima:如何拟合ARIMA时间序列?

[英]arima: How can I get fitted ARIMA time series?

m7 = arima(lill,order=c(0,0,1),
          seasonal=list(order=c(1,0,0),period=22),
          xreg=data.frame(lpGDP))

preds = predict(m7,n.ahead = 1, newxreg = 1)

There are 329 observations in lill object. lill对象中有329个观测值。 How can I predict the last observation 328, instead of 330 observation? 我如何预测最后的观测值328,而不是330的观测值? Thank you. 谢谢。

You don't need to call predict for prediction of observed data. 您不需要调用predict来预测观察到的数据。 You can do: 你可以做:

fitted_values <- lill - m7$residuals

This is the fitted ARIMA model. 这是拟合的ARIMA模型。 To inspect the 328th value, do 要检查第328个值,请执行

fitted_values[328]

I don't have your data, so I use R's built-in data set LakeHuron as a toy demonstration. 我没有您的数据,所以我使用R的内置数据集LakeHuron作为玩具演示。

fit <- arima(LakeHuron, order = c(2,0,0), xreg = time(LakeHuron) - 1920)
fitted_values <- LakeHuron - fit$residuals
ts.plot(LakeHuron)  ## observed time series (black)
lines(fitted_values, col = 2)  ## fitted time series (red)

玩具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM