我是vars包中的新手,并使用Canada数据进行了一些测试。我的简单代码如下。我想知道为什么当我调用预测函数时输出有10行。我以为我只会得到一排(预测值和置信区间),因为我试图提前一个月预测。谢谢!
data(Canada)
varfit <- VAR(Canada, p = 2, type = "const")
pred <- predict(varfit, n.head = 1)
pred
以下是结果。每个都有十行。
$e
fcst lower upper CI
[1,] 962.6557 961.9446 963.3668 0.7111044
[2,] 963.6538 962.3422 964.9654 1.3116050
[3,] 964.6932 962.8261 966.5603 1.8670903
[4,] 965.6882 963.3092 968.0671 2.3789396
[5,] 966.5814 963.7240 969.4387 2.8573301
[6,] 967.3460 964.0344 970.6576 3.3116112
[7,] 967.9769 964.2302 971.7236 3.7467269
[8,] 968.4827 964.3193 972.6461 4.1633974
[9,] 968.8798 964.3200 973.4396 4.5597736
[10,] 969.1877 964.2546 974.1208 4.9330961
$prod
fcst lower upper CI
[1,] 417.2623 415.9835 418.5411 1.278808
[2,] 417.7410 415.7854 419.6965 1.955532
[3,] 418.2196 415.7674 420.6717 2.452134
[4,] 418.5639 415.6897 421.4380 2.874136
[5,] 418.7644 415.5065 422.0224 3.257935
[6,] 418.8374 415.2253 422.4494 3.612043
[7,] 418.8097 414.8748 422.7446 3.934890
[8,] 418.7110 414.4881 422.9340 4.222973
[9,] 418.5693 414.0952 423.0435 4.474127
[10,] 418.4083 413.7200 423.0966 4.688305
$rw
fcst lower upper CI
[1,] 470.2954 468.7660 471.8247 1.529348
[2,] 470.8948 468.8195 472.9701 2.075289
[3,] 471.5360 469.0592 474.0128 2.476757
[4,] 472.2490 469.4525 475.0456 2.796577
[5,] 473.0652 469.9976 476.1329 3.067654
[6,] 473.9943 470.6851 477.3035 3.309184
[7,] 475.0275 471.4966 478.5584 3.530898
[8,] 476.1454 472.4082 479.8825 3.737164
[9,] 477.3237 473.3938 481.2536 3.929867
[10,] 478.5375 474.4271 482.6478 4.110375
$U
fcst lower upper CI
[1,] 6.428832 5.880708 6.976957 0.5481244
[2,] 5.903919 5.017510 6.790327 0.8864083
[3,] 5.396177 4.219319 6.573035 1.1768580
[4,] 4.949219 3.518061 6.380377 1.4311576
[5,] 4.595008 2.932516 6.257500 1.6624923
[6,] 4.343933 2.463420 6.224445 1.8805126
[7,] 4.191928 2.102592 6.281265 2.0893366
[8,] 4.126745 1.837864 6.415625 2.2888805
[9,] 4.132323 1.655370 6.609276 2.4769529
[10,] 4.191762 1.540817 6.842707 2.6509449
答案 0 :(得分:1)
试试pred = predict(varfit, n.ahead =1)
。这应该解决你的问题。