Svetlana Matveeva
Svetlana Matveeva

Reputation: 11

TimeSeries Stationarity

I am working on python program for timeseries forecasting of number of events by date. For prediction I use ARIMA model. Now I have some results, but predicted values is not so good. First, I made my timeseries stationary. For this I used: check stationarity by Dickey-Fuller test(0,5), then used Box-Cox transformation and again check ed Dickey-Fuller value(0,3). Then I tried to find first order difference method. I didnt received good results. My question is how to deal with non-stationary time series. which methods should I use to make it stationary?

orange - input time series, blue - first order difference

Upvotes: 1

Views: 618

Answers (2)

Mehul Gupta
Mehul Gupta

Reputation: 1939

You can explore a number of methods to handle non stationarity of time series below: https://medium.com/analytics-vidhya/preprocessing-for-time-series-forecasting-3a331dbfb9c2?source=friends_link&sk=30aac82f09efbbe8f1b6549a8e367575

Key Points (for making stationary time series):

  • Self Lag Differencing — It can be taken as the difference between present series and lagged version of the series.The shift can be of the order 1,2,3,4,etc. For items where we don’t have any lagged version item, take them as NULL.

    Example — Let your dataframe be ‘Time’ and column with values be ‘Temperature’ indexed on date. So self differencing can be done like this:

    Time[‘Temperature_Diff’]=Time[‘Temperature’]-Time[‘Temperature’].shift(1) 
    

    if lagged version used is 1

    Time[‘Temperature_Diff’]=Time[‘Temperature’]-Time[‘Temperature’].shift(2)
    

    if lagged version used is 2

  • Log Self Differencing — It can be taken as the difference between present series and lagged version of the series. But you can just apply log transformation over the actual series.

  • Use statsmodels.tsa.seasonal.seasonal_decompose and it will give you three components-Trend, Seasonality and Residuals. Take these residuals and it will be our stationary time series for forecasting.

P.S.- The blogpost has been authored by me.

Upvotes: 0

Hans Musgrave
Hans Musgrave

Reputation: 7121

Many time series problems are intrinsically difficult, if not unlearnable -- especially if one wants to prevent overfitting and have some predictive power. If results are poor with a simple model, they aren't likely to be leaps and bounds better with a more complicated model.

Your first step ought to be incorporating external data sources and coming up with a theoretical model for your predictive task. Training a model on those stronger-signaled inputs should work better than on your raw data (if the task is learnable).

Upvotes: 1

Related Questions