Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Statsmodel ARIMA start [stationarity]

I just began working on time series analysis using statsmodels. I have a dataset with dates and values (for about 3 months). I am facing some issues with providing the right order to the ARIMA model. I am looking to adjust for trends and seasonality and then compute outliers.

My 'values' are not stationary and statsmodel says that I have to either induce stationarity or provide some differencing to make it work. I played around with different ordering (without understanding deeply about the consequences of changing p,q and d).

When I introduce 1 for differencing, I get this error:

ValueError: The start index -1 of the original series has been differenced away

When I remove the differencing by having my order as (say) order = (2,0,1), I get this error:

    raise ValueError("The computed initial AR coefficients are not "
ValueError: 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.
>>> 

Any help on how to induce stationarity (or a link to a nice tutorial) would be helpful. And, also, tests of stationarity (like, http://www.maths.bris.ac.uk/~guy/Research/LSTS/TOS.html) would be useful.

Update: I am reading through ADF test:

http://statsmodels.sourceforge.net/stable/generated/statsmodels.tsa.stattools.adfuller.html

Thanks! PD.

like image 798
user1717931 Avatar asked Jun 19 '14 22:06

user1717931


1 Answers

To induce stationarity:

  1. de-seasonalize (remove seasonality)
  2. de-trend (remove trend)

There are several ways to achieve stationarity of a time series - Box-Cox family of transformations, Differencing etc., Choice of method depends on the data. Below are the commonly used tests for stationarity.

Tests for stationarity: 1. Augmented Dickey-Fuller test 2. KPSS test KPSS python code

like image 152
Bussller Avatar answered Oct 21 '22 19:10

Bussller