从ARIMAX模型中提取参数系数和p值(python pyflux程序包)

时间:2019-01-04 16:51:04

标签: python-3.x parameters time-series p-value coefficients

我正在使用pyflux ARIMAX模型,我想提取参数系数和p值。我浏览了文档,但找不到任何东西。我尝试了model.params,但它给了我以下错误。我也尝试过model.coeff_,但是得到了类似的错误。任何帮助是极大的赞赏。谢谢。


AttributeError跟踪(最近一次通话)  在()中 ----> 1个model.params

AttributeError:“ MLEResults”对象没有属性“ params”

2 个答案:

答案 0 :(得分:0)

为您提供帮助可能有点晚了,但请放在那里以备将来参考。这完全埋在API文档中。

model.latent_variables.get_z_values(transformed=True)

或针对拟合的模型对象:

model.fit().z.get_z_values(transformed=True)

答案 1 :(得分:0)

使用示例this example,您得到表

>>> model = pf.ARIMAX(data=data, formula='drivers~seat_belt+oil_crisis', ar=1, ma=1, family=pf.Normal())
... x = model.fit("MLE")
... x.summary()

Normal ARIMAX(2,0,1)                                                                                      
======================================================= ==================================================
Dependent Variable: drivers                             Method: MLE                                       
Start Date: 1969.16666666667                            Log Likelihood: -1288.9807                        
End Date: 1984.91666666667                              AIC: 2591.9615                                    
Number of observations: 190                             BIC: 2614.6907                                    
==========================================================================================================
Latent Variable                          Estimate   Std Error  z        P>|z|    95% C.I.                 
======================================== ========== ========== ======== ======== =========================
AR(1)                                    1.4031     0.0694     20.2033  0.0      (1.267 | 1.5392)         
AR(2)                                    -0.4058    0.0599     -6.7751  0.0      (-0.5231 | -0.2884)      
MA(1)                                    -0.8534    0.0429     -19.9112 0.0      (-0.9374 | -0.7694)      
Beta 1                                   0.0099     39.506     0.0003   0.9998   (-77.4218 | 77.4417)     
Beta seat_belt                           0.0021     12.3407    0.0002   0.9999   (-24.1856 | 24.1897)     
Beta oil_crisis                          0.0027     4.3974     0.0006   0.9995   (-8.6162 | 8.6216)       
Normal Scale                             227.6325                                                         
==========================================================================================================

获取Latent Variable表行名和索引:

>>> ind = x.z.z_indices

{'AR(1)': {'start': 0, 'end': 0}, 'AR(2)': {'start': 1, 'end': 1}, 'MA(1)': {'start': 2, 'end': 2}, 'Beta 1': {'start': 3, 'end': 3}, 'Beta seat_belt': {'start': 4, 'end': 4}, 'Beta oil_crisis': {'start': 5, 'end': 5}, 'Normal Scale': {'start': 6, 'end': 6}}

使用它们来获取EstimateStd Error

>>> est = x.z.z_list[ind['AR(1)']['start']].value
... se = x.z.z_list[ind['AR(1)']['start']].std
... print(est, se)

1.4030704563076553 0.0694474441044986

您现在可以计算95%的置信区间:

>>> est - 1.96 * se

1.266953465862838

>>> est + 1.96 * se

1.5391874467524724