Thanks in advance. In this post, I asked the question of how to choose specific lags in a VAR model. After a quick reply and information of the 'restrict' and 'coef' functions I was able to successfully run a VAR model with the specific lags I wanted. However, what's the code I need to use the restricted VAR model to make forecasts?
Sample of my code is below:
##Attempt to Restrict VAR Coefficients
##VAR has 5 lags with three variables plus constant and 11 seasonal dummies.
library("vars")
var1 <- VAR(DVARmat, p = 5, type ="const", season = 12)
restrict <- matrix (c(1,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0,
1,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0,
1,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0),
nrow = 3, ncol = 27, byrow = T)
var1_restrict <- coef(restrict(var1, method ="man", resmat = restrict))
var1_restrict
I know the forecast code after a normal VAR, but can't seem to fudge the restricted VAR into it. Thanks again.
After generating the restricted coefficient matrix
restrict
, you can usepredict
onrestrict(...)
sincerestrict(...)
also returns an object of classvarest
:Note that
restrict(var1, method="man", resmat = restrict)
is an object that could be generated, thus if one prefers they may also use the following :