【问题标题】:Forecasts with specific VAR model lags具有特定 VAR 模型的预测滞后
【发布时间】: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


【解决方案1】:

生成受限系数矩阵restrict后,你可以在restrict(...)上使用predict,因为restrict(...)也返回一个类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) 是一个可以生成的对象,因此如果愿意,他们也可以使用以下内容:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-04
    • 2015-02-15
    • 2017-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 2022-07-28
    相关资源
    最近更新 更多