# 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)


## migrated from stackoverflow.comMar 20 '16 at 18:59

This question came from our site for professional and enthusiast programmers.

• What packages are pulling in na.approx and adf.test? – thelatemail Mar 11 '16 at 1:42
• na.approx is from forecast and adf.test is from tseries. – modLmakur Mar 11 '16 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. – A. Webb Mar 11 '16 at 18:35

• 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. – Rick Arko Mar 11 '16 at 20:28