Grid search to automatically pick SARIMAX order model in python statsmodels
Asked Answered
T

1

6

I am currently writing a function to do a grid search for the order of a SARIMAX model: (p,q,d)X(P,Q,D,s). However, I routinely get the following types of error with the default settings on statsmodels.tsa.SARIMAX() when fitting:

ValueError: Non-stationary starting autoregressive parameters found with `enforce_stationarity` set to True.

or

ValueError: non-invertible starting MA parameters found with `enforce_invertibility` set to True.

I could stop enforcing stationarity and invertibility to stop getting these errors, however, as far as I know, I would not want model parameters which created a model that isn't invertible.

Is it ok to relax the enforce_stationarity and enforce_invertibility arguments, or would this result in poor models?

Timpani answered 10/10, 2016 at 9:28 Comment(0)
C
5

This is what I did within the for-loop where I perform my grid search:

for ...:
    try:
        model = smt.SARIMAX(...)
        result = model.fit()
        ...
    except:
        continue

This way, you will skip non-stationary or non-invertible models.

Classless answered 29/11, 2016 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.