具有特定 VAR 模型的预测滞后 [英] Forecasts with specific VAR model lags
问题描述
提前致谢.在这篇文章中,我问了如何在 VAR 模型中选择特定滞后的问题.在限制"和系数"函数的快速回复和信息之后,我能够成功运行具有我想要的特定滞后的 VAR 模型.但是,使用受限 VAR 模型进行预测需要什么代码?
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?
我的代码示例如下:
##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
我知道普通 VAR 之后的预测代码,但似乎无法将受限 VAR 加入其中.再次感谢.
I know the forecast code after a normal VAR, but can't seem to fudge the restricted VAR into it. Thanks again.
推荐答案
生成受限系数矩阵restrict
后,可以在restrict(...)
因为 restrict(...)
也返回一个 varest
类的对象:
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)
请注意,restrict(var1, method="man", resmat = restrict)
是一个可以生成的对象,因此如果愿意,他们也可以使用以下内容:
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)
这篇关于具有特定 VAR 模型的预测滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!