I estimated my model with VAR() of the vars package in R. I included an exogenous variable. Now I want to forecast from my model and used predict(). However, I got the following error.

No matrix for dumvar supplied, but object varest contains exogenous variables.

My problem is now, that I can't include my exogenous variable as the dummy, since it has no values in the future. predict() asks for a dummy variable, which has the same number of rows as the n.ahead prediction, though. Going through the function (see the complete one here) shows that the dummy variable is only used once:

Zdet <- as.matrix(dumvar)

forecast recursion

forecast <- matrix(NA, ncol = K, nrow = n.ahead)
lasty <- c(Zy[nrow(Zy), ])
for(i in 1 : n.ahead){
  lasty <- lasty[1 : (K * p)]
  Z <- c(lasty, Zdet[i, ])
  forecast[i, ] <- B %*% Z
  temp <- forecast[i, ]
  lasty <- c(temp, lasty)

where B is the matrix of the estimated coefficients of the model.

Am I on the right way, if I use a zero matrix as the dummy variable?


1 Answer 1


If you have a VAR model with an exogenous variable and you want to forecast, you have to supply the forecast for the exogenous variable. You cannot get around that unless you choose to use a different type of model. The forecast has to be sensible, so using all-zero forecast will normally not work (unless it truly is the best forecast you have).

Regarding the implementation in R, the dummy variable is first used as is (under the name dumvar) but later incorporated in the matrix Zdet (for example, in the first code line that you included), and Zdet is used in the forecast recursion. So the variable is important and does not disappear, it just becomes part of another variable.

  • $\begingroup$ Great! Good luck! $\endgroup$ Commented Aug 18, 2015 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.