I am a total beginner with time series analysis. I use R. I understand that time series data need to be stationary for analyses like cross-correlation or modeling.

I am, however, struggling with determining if my data is stationary. I have data sets with air pollution measurements per hour for 2 weeks per data set. I want to analyse the data per 2 weeks and per day.

I could not really say based on the normal plots if the data is stationary or non-stationary.

I plotted the ACFs for both 2 weeks and 1 day both without and with differencing.

For the 2 week period (second plot is differenced data). ACF plot of data of 2 week period; second plot is differenced data

For a 1 day period (second plot is differenced data). ACF plot of data of 1 day period; second plot is differenced data

I would say (with my very limited knowledge) that the first graphs of both periods do not look stationary, but the differenced data looks like white noise.

I looked a little into the ADF and KPSS test, but my statistical knowledge is not very big, so I do not understand the theory behind it. Also, I do understand how to choose the appropriate k for the ADF test, but when changing k I saw that I can make the p-value lower than 0.05 if I choose the "right" k.

My questions are:

  1. Are the ACF plots of non-differenced data already enough reason to difference the data (because it looks non-stationary)? (taking into account that I am very much a beginner and prefer the easiest method that is acceptable..)

  2. If this is not enough, should I also perform the KPSS and ADF test, and if yes, how should I choose the k for the ADF test?


  1. Also, I tried to calculate the cross-correlation (with Ccf()) and found that the differenced data has, on the few instances I tested it on, a lower correlation than the non-differenced data. I would be interested in understanding why this is the case.



2 Answers 2


I'm a little confused about what your data is but, based on the above information, it does appear to be stationary. This is because there is relatively little persistence in the ACF, meaning that the autocorrelations do not consistently remain close to 1 (see here for a textbook example of a non-stationary ACF).

However there is really no substitute for performing a proper statistical test. ADF is a good start here. Broadly speaking, the theory behind it is that you re-write a time-series model in such a way that the first term on the right-hand-side contains all the (autoregressive) parameters of your time series model. As you probably know, non-stationarity occurs when the sum of the parameters in a model is 1, so you then perform a regression on this rewritten model to test whether that first parameter is equal to 1. Below I provide an example using an AR(2) model.

Let's assume the model you are trying to specify for your data is AR(2):

$$y_t = \psi_1y_{t-1} + \psi_2y_{t-2} + \epsilon_t $$

Now add and subtract $\psi_2y_{t-1}$ to the right-hand side to get:

$$y_t = (\psi_1 + \psi_2)y_{t-1} + \psi_2y_{t-2} - \psi_2y_{t-1} + \epsilon_t $$

Now note that the 2nd and third terms can be rewritten as a differenced term and that we can rewrite $\psi_1 + \psi_2$ as $\beta$. Then what we get is:

$$y_t = \beta y_{t-1} - \psi_2\Delta y_{t-1} + \epsilon_t $$

As explained above you then run an OLS regression that tests whether $\beta = 0$ or not.

A more generalised form of the ADF test can be found here, though hopefully the above has provided some intuition.

In terms of your results, I would recommend running the ADF test with multiple lags to see if there is a consistent pattern in your results. If you want to choose the k for the optimal number of lags, the typical approach is to calculate the AIC or BIC for different numbers of lags and choose the k that results in a model with the lowest AIC or BIC.


Unnecessary differencing or filtering can inject structure (see Slutsky Effect) . Sometimes a series can have a shift in the mean causing "non-statioanarity" ..the correct remedy is to neither difference or de-trend but to "de-mean" or use a Level Shift variable/filter to render the residual series stationary.

Sometimes there is more than 1 trend requiring a number of trend variables/filters .... none of which have to start at the beginning if the series. Analysis will tell you which of these three approaches

differencing de-meaning de-trending are suitable for your data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.