0

So im trying to get 5 arima models (to predict from 1 up to 5 days into the future). With the statsmodels arima class is somehow not working if i use d>0 or q>0. With auto arima its working (pmdarima).

For example(Statsmodel)

p,d,q = 1, 1, 0

models = []
for dayidx in range(0,5):
    models.append(ARIMA(exog=X_train[dayidx], endog=y_train[dayidx],order=(p,d,q)).fit())

models[0].forecast(exog=X_test[0],steps=157)[0]

If i use forecast with p>0, d>0 and q=0 i get not the expected target values (there a just increasing values and like x2-x10 higher). If i use forecast p>0, d=0, q=0 i get expetable values. If i use any value for q i get the following error, which tells me that the data is non stationary that why im using d>0 in the case im using q>0 and it should work but it doenst...

The computed initial AR coefficients are not stationary
You should induce stationarity, choose a different model order, or you can
pass your own start_params.

Here the code for the pmarima model

auto_arima = {'adf': [], 'kpss': []}
stattests = ('adf','kpss')
for stattest in stattests:
    print(stattest)
    for dayidx in range(0,5):
        auto_arima[stattest].append(pm.auto_arima(y=y_train[dayidx], exogenous=X_train[dayidx],
                             stepwise=True,
                             suppress_warnings=True, 
                             error_action="ignore",
                             test=stattest,
                             start_p=0,
                             start_d=0,
                             start_q=0,
                             max_p=6,
                             max_d=3,
                             max_q=3,
                             max_order=None, 
                             trace=False))
    print('done')

With Auto Arima (pmdarima) is working like it should be (there i got the value from d -> d>0)

Training with adf
(1, 0, 1)
(4, 0, 1)
(1, 0, 1)
(2, 0, 2)
(2, 0, 0)
Training with kpss
(1, 1, 2)
(1, 1, 2)
(2, 1, 1)
(1, 1, 2)
(2, 1, 1)

These are the parameter the arima model is trained with (pmarima). So q should be >0

Does anyone know why ARIMA from statsmodels is not working for me but autoarima from pmarima is?

Tollpatsch
  • 304
  • 4
  • 13

1 Answers1

1

pmdarima uses the Statsmodels class sm.tsa.SARIMAX and not the class sm.tsa.ARIMA class.

Currently, the sm.tsa.SARIMAX class is recommended for all ARIMA models, because the sm.tsa.ARIMA class is no longer receiving feature updates, and will be deprecated in the next release (v0.12).

(There is also a new class, sm.tsa.arima.ARIMA, that will be the recommended version in the next Statsmodels release, because it contains all of the features of sm.tsa.SARIMAX, but also includes alternative methods for fitting the model.)

cfulton
  • 2,855
  • 2
  • 14
  • 13