auto.arima() equivalent for python

There is now a proper python package to do auto-arima. https://github.com/tgsmith61591/pmdarima

Docs: http://alkaline-ml.com/pmdarima

Example usage: https://github.com/tgsmith61591/pmdarima/blob/master/examples/quick_start_example.ipynb


You can implement a number of approaches:

  1. ARIMAResults include aic and bic. By their definition, (see here and here), these criteria penalize for the number of parameters in the model. So you may use these numbers to compare the models. Also scipy has optimize.brute which does grid search on the specified parameters space. So a workflow like this should work:

     def objfunc(order, exog, endog):
         from statsmodels.tsa.arima.model import ARIMA
         fit = ARIMA(endog, order, exog).fit()
         return fit.aic()
    
     from scipy.optimize import brute
     grid = (slice(1, 3, 1), slice(1, 3, 1), slice(1, 3, 1))
     brute(objfunc, grid, args=(exog, endog), finish=None)
    

Make sure you call brute with finish=None.

  1. You may obtain pvalues from ARIMAResults. So a sort of step-forward algorithm is easy to implement where the degree of the model is increased across the dimension which obtains lowest p-value for the added parameter.

  2. Use ARIMAResults.predict to cross-validate alternative models. The best approach would be to keep the tail of the time series (say most recent 5% of data) out of sample, and use these points to obtain the test error of the fitted models.