1

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.

Community
  • 1
  • 1
gtnbz2nyt
  • 1,465
  • 3
  • 17
  • 33
  • 1
    I suppose you use `predict` for unrestricted VAR model, but then, since `restrict(...)` also returns an object of class `varest`, you should be able to successfully use `predict` on `restrict(...)` too. Maybe you were trying `predict(coef(restrict(...)))` or something like that? – Julius Vainora Apr 08 '14 at 20:33
  • @Julius okay I can see clearly now. I need to get used to the R terminology with Objects and Classes. Thank you very much. – gtnbz2nyt Apr 08 '14 at 20:40
  • Feel free to post an answer to your question and accept it. – Julius Vainora Apr 08 '14 at 21:53

1 Answers1

1

After generating the restricted coefficient matrix restrict, you can use predict on restrict(...) since restrict(...) also returns an object of class varest :

 ##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

         expostrestrict <- predict(restrict(var1, method="man", resmat = restrict), n.ahead = 13, ci=.95)

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 :

restrict_var <- restrict(var1, method="man", resmat = restrict)
expostrestrict <- predict(restrict_var, n.ahead = 13, ci=.95)
gtnbz2nyt
  • 1,465
  • 3
  • 17
  • 33