Skip to content
Prev 11562 / 15274 Next

Using adf.test to test time series stationarity of stock price

Hi Matthieu

For me it looks like adf.test does not correctly handle xts and/or zoo 
inputs due to the subsetting code:

 > adf.test(stock2[,1])

         Augmented Dickey-Fuller Test

data:  stock2[, 1]
Dickey-Fuller = 2.7174, Lag order = 12, p-value = 0.99
alternative hypothesis: stationary

Warning message:
In adf.test(stock2[, 1]) : p-value greater than printed p-value
 > adf.test(unclass(stock2[,1]))

         Augmented Dickey-Fuller Test

data:  unclass(stock2[, 1])
Dickey-Fuller = -2.4579, Lag order = 12, p-value = 0.3845
alternative hypothesis: stationary

At the time when adf.test was written neither xts nor zoo existed. A 
quick fix is to revise the documentation of adf.test: "x: a numeric 
vector."

Best regards
Adrian