# testing if timeseries is stationary

I'm trying to run adf.test on the time series below which exhibits a clear 24 hour seasonal pattern. The results of the adf.test seem to imply that the data is stationary. If the data has a strong seasonal pattern shouldn't the adf.test imply that it is non-stationary? I used TBATS to forecast the data and it picked the pattern up very clearly. I've posted some sample data below. I'm new to forecasting so any advice is very much appreciated.

Code:

library(forecast)
library(tseries)
tsCustCount <- ts(na.approx(ds$CustCount), frequency = 24) adf.test(tsCustCount, alternative = "stationary") Output: Augmented Dickey-Fuller Test data: tsCustCount Dickey-Fuller = -17.541, Lag order = 28, p-value = 0.01 alternative hypothesis: stationary Warning message: In adf.test(tsCustCount, alternative = "stationary") : p-value smaller than printed p-value Data: dput(ds$CustCount[1:144])
c(3, 3, 1, 4, 1, 3, 2, 3, 2, 4, 1, 1, 5, 6, 8, 5, 2, 7, 7, 3,
2, 2, 2, 1, 3, 2, 3, 1, 1, 2, 1, 1, 3, 2, 2, 2, 3, 7, 5, 6, 8,
7, 3, 5, 6, 6, 8, 4, 2, 1, 2, 1, NA, NA, 4, 2, 2, 4, 11, 2, 8,
1, 4, 7, 11, 5, 3, 10, 7, 1, 1, NA, 2, NA, NA, 2, NA, NA, 1,
2, 3, 5, 9, 5, 9, 6, 6, 1, 5, 3, 7, 5, 8, 3, 2, 6, 3, 2, 3, 1,
NA, NA, 3, 2, 2, 4, 6, 2, 4, 10, 3, 10, 5, 8, 6, 6, NA, 4, 3,
6, 2, 4, 1, 2, NA, 2, 3, NA, 2, 2, 8, 4, 8, 5, 6, 7, 5, 6, 3,
6, 6, 7, 6, 2)
• What packages are pulling in na.approx and adf.test? Mar 11, 2016 at 1:42
• na.approx is from forecast and adf.test is from tseries. Mar 11, 2016 at 3:26
• Voting to migrate to Cross Validated. However, the Augmented Dickey-Fuller test is for the presence of a unit root, not all forms of nonstationarity. You can try auto.arima to see that your time series (sample) could be described as containing seasonal, AR, and MA affects. Mar 11, 2016 at 18:35

Seasonality means that your data is non-stationary in the sense that the means of the series will vary across seasons. However your data can still be stationary in the sense that you can expect the same mean for the same season in different periods. This seems to be that case looking at your sample data.

If you are trying to determine whether your data is stationary in order to decide whether to difference or not, I would consider the data stationary in that sense.

• Ok thank you, whether I needed to difference my data before trying to fit a model was the main thing I was trying to figure out. Mar 11, 2016 at 19:49
• You can also check with ndiffs(tsCustCount) or if you fit your data with a an arima model like fit <- auto.arima(tsCustCount) you'll see a seasonal component but no differencing. Mar 11, 2016 at 20:28