How to check in R if time series is stationary?

Before we can fit an ARIMA model, our time series has to be stationary. Time series is stationary if its mean level and variance stay steady over time, or as explained by Hyndman and Athana­sopou­los (2013): “[a] stationary time series is one whose properties do not depend on the time at which the series is observed”.

In this post, we will demonstrate several tools and tests to check stationary. We will employ  a time series of monthly property prices per m² in Amsterdam, between September 2008 and July 2013. The following graph displays the original series. Our analysis will be run in R, with the packages ‘fpp‘ and ‘forecast


And here is the series after log transformation and seasonal differenced..

Time Series in log and 12 diff

Now we are going to check stationary. We will start with the ACF and PACF graphs and check significant lags. Each of these graphs can be drawn with the following commands:



Both graphs have a few significant lags but these die out quickly, so we can conclude our series is stationary.

Other tests are also available in these R packages to check stationary.

The Ljung-Box test examines whether there is significant evidence for non-zero correlations at lags 1-20. Small p-values (i.e., less than 0.05) suggest that the series is stationary.

Screen shot 2


The Augmented Dickey–Fuller (ADF) t-statistic test: small p-values suggest the data is stationary and doesn’t need to be differenced stationarity.

Screen shot 1


The Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test; here accepting the null hypothesis means that the series is stationarity, and small p-values suggest that the series is not stationary and a differencing is required.

Screen shot 3


All the tests indicate that our time series is stationary, so it’s time to move on to the next step and fit an ARIMA model..


Further reading:

Makridakis  Spyros, Wheelwright  Steve C. and Hyndman Rob J. (1998) Forecasting –  Methods and Applications, 3rd ed., John Wily and Sons, Inc.

* Hyndman Rob J. and Athana­sopou­los George (2013) Forecasting: Principles and Practice, OTexts



Happy Analysing!

Questions? Comments? Drop us a line..