VAR 模型错误

Error in VAR model

我有这个数据:

     Year W  L  PTS GF  GA  S    SA
1    2006 49 25 106 253 224 2380 2662
2    2007 51 23 110 266 207 2261 2553
3    2008 41 32 91  227 224 2425 2433
4    2009 40 34 88  207 228 2375 2398
5    2010 47 29 100 217 221 2508 2389
6    2011 44 27 99  213 190 2362 2506
7    2012 48 26 104 232 205 2261 2517
8    2014 38 32 88  214 233 2382 2365
9    2015 47 25 104 226 202 2614 2304
10   2016 41 27 96  224 213 2507 2231
11   2017 41 29 94  238 220 2557 2458
12   2018 53 18 117 261 204 2641 2650

我根据这些数据建立了一个 VAR 模型(它是一个球队在所列年份的曲棍球数据)。我将上面的 ts() 参数转换为时间序列,并创建了这个模型:

VARselect(NSH_ts[, 3:5], lag.max = 8)
var1 <- VAR(NSH_ts[, 3:5], p = 2, type = "both", ic = c("AIC"))
serial.test(var1, type = "PT.adjusted")
forecast.var1 <- forecast(var1, h = 2) 
autoplot(forecast.var1) +
  scale_x_continuous(breaks = seq(2006, 2022))

我想使用 serial.test() 参数,但出现此错误:

Error in t(Ci) %*% C0inv : non-conformable arguments

为什么 serial.test() 论点不起作用? (总的来说,我试图根据集合中的变量预测 PTS 未来两年。

我一直以此为指导:https://otexts.org/fpp2/VAR.html

我收到另一个错误,可能来自 VARselect。我的 table 主要是 -Inf 个条目,有一个 NaN,其余为 0。调整 lag.max 给了我实数,我也必须调整其他值.

VARselect(dfVAR[, 3:5], lag.max = 2)
var1 <- VAR(dfVAR[, 3:5], p = 1, type = "both", ic = c("AIC"))
serial.test(var1, lags.pt = 4, type = "PT.adjusted")

    Portmanteau Test (adjusted)

data:  Residuals of VAR object var1
Chi-squared = 35.117, df = 27, p-value = 0.1359

The basis of the non-conformable error is that your matrix algebra isn't working, the number of cols in the first matrix have to match the number of rows in the second. 由于不了解 VAR 模型,我无法提供除此之外的帮助。