使用statsmodels在VARMAX上使用.forecast()方法时出错

时间:2018-11-03 00:15:50

标签: time-series forecasting

我有一个多元时间序列,因此我正在尝试进行向量自回归移动平均(VARMA)预测。我相信VARMA最适合该系列,因为该系列确实具有多个变量,所有变量都是内生的。

根据多个来源(包括statsmodel文档),VARMAX类可用于完成VARMA计算。实际上,我可以使用VARMA成功拟合模型,并提供以下摘要。

from statsmodels.tsa.statespace.varmax import VARMAX

# fit model 
varma = VARMAX(df_pca, order=(1, 1))
varma_fit = varma.fit(maxiter=1000, disp=False)
print (varma_fit.summary())

Statespace Model Results                           
==============================================================================
Dep. Variable:              [0, 1, 2]   No. Observations:                13199
Model:                     VARMA(1,1)   Log Likelihood               59909.901
                          + intercept   AIC                        -119765.801
Date:                Fri, 02 Nov 2018   BIC                        -119563.628
Time:                        23:50:27   HQIC                       -119698.300
Sample:                    01-02-1962                                         
                         - 10-29-2018                                         
Covariance Type:                  opg                                         
=====================================================================================================
Ljung-Box (Q):          163.74, 127.73, 137.46   Jarque-Bera (JB):   149761.37, 41120716.89, 29871.12
Prob(Q):                      0.00, 0.00, 0.00   Prob(JB):                           0.00, 0.00, 0.00
Heteroskedasticity (H):       1.41, 2.31, 0.80   Skew:                              -0.12, 6.25, 0.13
Prob(H) (two-sided):          0.00, 0.00, 0.00   Kurtosis:                       19.50, 276.16, 10.37
                            Results for equation 0                            
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const         -0.0005      0.002     -0.251      0.802      -0.005       0.004
L1.0           0.9998      0.000   4756.659      0.000       0.999       1.000
L1.1           0.0022      0.002      1.105      0.269      -0.002       0.006
L1.2           0.0081      0.008      1.039      0.299      -0.007       0.023
L1.e(0)        0.1021      0.005     21.093      0.000       0.093       0.112
L1.e(1)        0.1295      0.016      8.233      0.000       0.099       0.160
L1.e(2)       -0.0327      0.031     -1.063      0.288      -0.093       0.028
                            Results for equation 1                            
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const      -1.522e-05      0.001     -0.025      0.980      -0.001       0.001
L1.0       -5.163e-05   5.98e-05     -0.863      0.388      -0.000    6.56e-05
L1.1           0.9981      0.001   1584.755      0.000       0.997       0.999
L1.2          -0.0063      0.002     -2.797      0.005      -0.011      -0.002
L1.e(0)        0.0044      0.002      2.512      0.012       0.001       0.008
L1.e(1)        0.0390      0.006      6.702      0.000       0.028       0.050
L1.e(2)       -0.0389      0.012     -3.375      0.001      -0.061      -0.016
                            Results for equation 2                            
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const      -3.385e-05      0.000     -0.150      0.881      -0.000       0.000
L1.0        5.207e-06   2.41e-05      0.216      0.829   -4.21e-05    5.25e-05
L1.1          -0.0002      0.000     -0.775      0.438      -0.001       0.000
L1.2           0.9916      0.001   1100.941      0.000       0.990       0.993
L1.e(0)       -0.0075      0.001     -9.812      0.000      -0.009      -0.006
L1.e(1)       -0.0045      0.003     -1.554      0.120      -0.010       0.001
L1.e(2)       -0.1088      0.005    -20.812      0.000      -0.119      -0.099
                            Error covariance matrix                             
================================================================================
                   coef    std err          z      P>|z|      [0.025      0.975]
--------------------------------------------------------------------------------
sqrt.var.0       0.1405      0.000    409.870      0.000       0.140       0.141
sqrt.cov.0.1     0.0051      0.000     28.134      0.000       0.005       0.006
sqrt.var.1       0.0463   8.13e-05    569.743      0.000       0.046       0.046
sqrt.cov.0.2    -0.0016      0.000    -15.317      0.000      -0.002      -0.001
sqrt.cov.1.2     0.0073      0.000     61.894      0.000       0.007       0.007
sqrt.var.2       0.0232   7.59e-05    306.162      0.000       0.023       0.023
================================================================================

但是,当我尝试向前预测该模型时(与VAR类一样),如下所示:

 yhat = varma_fit.forecast(steps=10)

我收到以下错误/回溯信息:

/opt/conda/lib/python3.6/site-packages/statsmodels/tsa/base/datetools.py in _date_from_idx(d1, idx, freq)
     84     offset. For now, this needs to be taken care of before you get here.
     85     """
---> 86     return _maybe_convert_period(d1) + int(idx) * _freq_to_pandas[freq]
     87 
     88 

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

文档说,在各个地方VARMA都有问题,但我还没有看到为什么从技术上讲这不起作用的任何原因。任何输入将不胜感激。

0 个答案:

没有答案