Reputation: 15
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. How can I predict the last observation 328, instead of 330 observation? Thank you.
Upvotes: 1
Views: 699
Reputation: 73265
You don't need to call predict
for prediction of observed data. You can do:
fitted_values <- lill - m7$residuals
This is the fitted ARIMA model. To inspect the 328th value, do
fitted_values[328]
I don't have your data, so I use R's built-in data set LakeHuron
as a toy demonstration.
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)
Upvotes: 2