Rolling forecasts
Forecasts a VAR or VECM by discarding a part of the sample, and generating a series of updated forecasts.
predict_rolling(object, ...) ## S3 method for class 'nlVar' predict_rolling(object, nroll = 10, n.ahead = 1, refit.every, newdata, ...)
object |
A linear object of class ‘ |
... |
Currently not used. |
nroll |
The number of rolling forecasts |
n.ahead |
An integer specifying the number of forecast steps. |
refit.every |
Determines every how many periods the model is re-estimated. |
newdata |
In case the model given is already estimated on the sub-sample, the out of sample data can be provided. Note it should contain observations to predict the first values, that are also contained in the in-sample. |
This function allows to check the out-of sample forecasting accuracy by
estimating the model on a sub-sample of the original, then making
nroll forcasts of horizont n.ahead, each time by updating the
sample. In other words, with a given model estimated on 100 observations, the
function will estimate it on say 90 first obs (nroll=10), generate a
say 1 step-ahead n.ahead=1 from obs 90, then using true value 91,
92,... till full sample.
Unlike usual predict() methods, specifiying n.ahead=2 will
not generate a 1 step-ahead and a 2 step-ahead forecasts, but only
nroll 2 step-ahead forecasts.
Note that while the forecasts are updated with new values, the model
estimation is (by default) not updated. This can however be done with the
argument fit.every, specifiying at which frequency the model should be
re-estimated. By setting it to 1 for example, each time a new observation is
taken, the model is reestimated. This is similar to the
ugarchroll in package rugarch.
A matrix containing the forecasts.
Matthieu Stigler
predict.nlar for the standard predict function.
data(barry)
## model estimated on full sample:
mod_vec <- VECM(barry, lag=2)
## generate 10 1-step-ahead forecasts:
preds_roll <- predict_rolling(mod_vec, nroll=10)
## plot the results:
plot(window(barry[,"dolcan"],start=1998), type="l", ylab="barry: dolcan")
preds_roll_ts <- ts(preds_roll$pred, start=time(barry)[nrow(barry)-10], freq=12)
lines(preds_roll_ts[,"dolcan"], col=2, lty=2)
legend("bottomright", lty=c(1,2), col=1:2, leg=c("True", "Fitted"))
title("Comparison of true and rolling 1-ahead forecasts\n")Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.