【发布时间】:2014-04-01 14:28:27
【问题描述】:
提前致谢。在this post 中,我提出了如何在 VAR 模型中选择特定滞后的问题。在快速回复并了解“restrict”和“coef”功能后,我能够成功运行具有我想要的特定滞后的 VAR 模型。但是,使用受限 VAR 模型进行预测需要什么代码?
我的代码示例如下:
##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 加入其中。再次感谢。
【问题讨论】:
-
我想您将
predict用于无限制的VAR 模型,但是由于restrict(...)也返回类varest的对象,您应该能够在@987654327 上成功使用predict@ 也。也许您正在尝试predict(coef(restrict(...)))或类似的东西? -
@Julius 好的,我现在可以看清楚了。我需要习惯对象和类的 R 术语。非常感谢。
-
随时发布您的问题的答案并接受它。
标签: r time-series restrict