| predict.TVAR | R Documentation | 
VAR’, ‘VECM’ or ‘TVAR’Forecasting the level of a series estimated by  ‘VAR’ / ‘VECM’ or ‘TVAR’
## S3 method for class 'TVAR'
predict(object, newdata, n.ahead = 5, newdataTrendStart, ...)
## S3 method for class 'VAR'
predict(object, newdata, n.ahead = 5, newdataTrendStart, exoPred = NULL, ...)
object | 
 An object of class  ‘  | 
newdata | 
 Optional. A new data frame to predict from. This should contain lags of the level of the original series. See Details.  | 
n.ahead | 
 An integer specifying the number of forecast steps.  | 
newdataTrendStart | 
 If ‘  | 
... | 
 Arguments passed to the unexported ‘  | 
exoPred | 
 vector/matrix of predictions for the exogeneous variable(s) (with ‘  | 
The forecasts are obtained recursively, and are for the levels of the series.
When providing newdata, newdata has to be ordered chronologically, so that the first row/element is the earliest value.
For VECM, the forecasts are obtained by transforming the VECM to a VAR (using function VARrep). 
Note that a VECM(lag=p) corresponds to a VAR(lag=p+1), so that if the user provides newdata 
for a VECM(lag=p), newdata should actually contain p+1 rows.
A matrix of predicted values.
Matthieu Stigler
lineVar and VECM. VARrep
A more sophisticated predict function, allowing to do sub-sample rolling
predictions: predict_rolling.
data(barry)
barry_in <- head(barry, -5)
barry_out <- tail(barry, 5)
mod_vecm <- VECM(barry_in, lag=2)
mod_var <- lineVar(barry_in, lag=3)
mod_tvar <- TVAR(barry_in, lag=3, nthresh=1, thDelay=1)
pred_vecm <- predict(mod_vecm)
pred_var  <- predict(mod_var) 
pred_tvar <- predict(mod_tvar)
 
## compare forecasts on a plot
n <- 30
plot(1:n, tail(barry[,1], n), type="l", xlim=c(0,n))
lines((n-5+1):n, pred_var[,1], lty=2, col=2)
lines((n-5+1):n, pred_vecm[,1], lty=2, col=3)
lines((n-5+1):n, pred_tvar[,1], lty=2, col=4) 
legend("bottomright", lty=c(1,2,2,2), col=1:4, legend=c("true", "var", "vecm", "tvar"))
## example for newdata:
all.equal(predict(mod_vecm), predict(mod_vecm, newdata=barry[c(317, 318, 319),]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.