jiterika
jiterika

Reputation: 21

Extract parameter coefficients and p-value's from ARIMAX models (python pyflux package)

I am using pyflux ARIMAX model and i want to extract the parameter coefficients and p-values. I have gone through the documentation, but couldn't find anything. I tried model.params but it gave me following error. I have also tried model.coeff_, but got similar error. Any help is greatly appreciated. Thank You.


AttributeError Traceback (most recent call last) in () ----> 1 model.params

AttributeError: 'MLEResults' object has no attribute 'params'

Upvotes: 1

Views: 1485

Answers (2)

Justas
Justas

Reputation: 159

Using example this example you get table

>>> 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                                                         
==========================================================================================================

Te get Latent Variable table line names and indexes:

>>> 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}}

Use them to get Estimate and Std 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

You can now calculate 95% confidence intervals:

>>> est - 1.96 * se

1.266953465862838

>>> est + 1.96 * se

1.5391874467524724

Upvotes: 1

user3438907
user3438907

Reputation: 1

Probably a bit late to help you, but putting this out there for future reference. This is quite buried in the API documentation.

model.latent_variables.get_z_values(transformed=True)

or for a fitted model object:

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

Upvotes: 0

Related Questions