2

I generate some data like [1, 6, 1, 6, 1, 6] and add noises under normal distribution. I use arma_order_select_ic to select order. Then aic_min_order is used to fit the ARMA model. Sometime the model works well. But sometimes it raises ValueError.

ValueError: The computed initial AR coefficients are not stationary

Here is my code.

import statsmodels.api as sm
import numpy as np
x = [1 if i%2 == 0 else 6 for i in range(50)]
eta = np.random.normal(0, 0.01, 50)
x = x + eta
res = sm.tsa.stattools.arma_order_select_ic(x, ic=['aic']) 
print res.aic_min_order
model = sm.tsa.ARMA(x, res.aic_min_order).fit(disp = 0)
print model.predict(45, 55)

Do I miss something or ARMA don't fit this kind of data?

BlueMandora
  • 154
  • 1
  • 6

1 Answers1

3

ARMA is designed for stationary processes and by default imposes stationarity on the parameter estimates.

Your data is not stationary, i.e. it the lag polynomial has a seasonal unit root. The usual treatment is to use seasonal differencing or a deterministic seasonal pattern for example with dummy variables or splines.

Statsmodels has currently no automatic season detection and model selection, but SARIMAX can be used for seasonal integrated ARMA processes.

Josef
  • 21,998
  • 3
  • 54
  • 67
  • Thank you. But I thought arma_order_select_ic do the model selection job. If statsmodels has currently no automatic model selection, what actually arma_order_select_ic do? – BlueMandora Feb 26 '17 at 03:23
  • 1
    It selects the arma lag order p and q, but does not try to identify trend, differencing order, seasonality, outliers and similar. – Josef Feb 26 '17 at 14:16