Closed richards-1227 closed 4 years ago
To get multi-step forecasts of observations 189-250:
forecast(fit1, xreg=X[189:250,])
To get one-step forecasts of observations 189-250, with the model trained only on observations 1-188:
fit2 <- Arima(y, model=fit1, xreg=X)
fitted(fit2)[189:250]
No.
Thanks.
So then does my earlier code
forecast(Arima(y, order=c(1,1,0), xreg=X) , xreg=X )$fitted[189:250]
estimate parameters and predict based on all 250 observations? Is there a way to get rolling parameter estimates? I.e. predict observation 190 based on 1-189, predict obs 191 on 1-190, re-estimating every time?
I thought that was the way it was supposed to work if you didn't have X
forecast(Arima(y , order=c(1,1,0) ) )$fitted[189:250]
would give you rolling predictions. Or am I mistaken?
Yes, that re-estimates the model on all data.
To get rolling fits, use tsCV()
.
It appears to be working with an appropriate modification of this code:
Rob, I received the same error as in this closed post: https://github.com/robjhyndman/forecast/issues/682
One thing that's not clear to me with your solution is that it has new regressors "xreg=ex" but it doesn't seem to be fitting on new values of the TS object.
Sorry if the following isn't clear -- I'm new both to TS analysis and GitHub so I'm not sure how to copy in code.
My attempt at psuedo-code: y is a 250x1 TS object first 188 for training, remainder for validation X is a matrix of regressors (250x4)
I fit a model:
Now I want one-step forecasts for obs. 189-250:
produces the No regressors provided error
produces output (although I do get a Upper prediction intervals are not finite error) but it's not clear if the predictions are truly "out of sample"
On an somewhat unrelated note, is there any way to use the Arima/forecast commands for non-GLM prediction of the residuals based on inputs? In other words yt = \theta * y{t-1} + \eta_t where \eta_t = f(X) + \epsilon_t where f(X) is some non-linear function estimated by something like RF, etc.
Thanks for any help you can provide. Drew