Let $Y_t = \rho Y_{t-1} + \epsilon_t$ and $Y_0$ be some constant.

I generated a time series data for the above model like this

for(i in 1:100)

Plot of the time series data y_t

The above is a plot of the same. Now to test the stationarity of this series I used the adf.test function from the package tseries in R. For the above model a Dickey Fuller Test (i.e adf test with 0 lag) should be enough (and appropriate too) to test for stationarity. However the output of the following code :

> adf.test(y,k = 0)

    Augmented Dickey-Fuller Test

data:  y
Dickey-Fuller = -3.4732, Lag order = 0, p-value = 0.04793
alternative hypothesis: stationary

Tells that the null hypothesis is rejected at %5 level and the series is stationary. While from the plot the series is clearly NOT stationary.


If run your code many times and check how often you get a pvalue less than 5%:

S <- 10000
rejections <- rep(NA, S)
for (s in 1:S){
  for(i in 1:100){
  reject <- (adf.test(y,k = 0)$p.value <= 0.05)
  rejections[s] <- reject
mean(rejections, na.rm=TRUE)

You see that the adf test does its job, it only incorrectly rejects the null of not stationary about 5% of the time.

The data you posted is obviously non-stationary because it seems to have a linear trend - but the ADF implemented in adf.test uses a model that allows for a constant and a linear trend term. So if these are taken out, it can happen that the data then looks stationary.

  • $\begingroup$ thanks for pointing out that tseries::adf.test implementation forces a constant and a linear term. I used the urca::df after reading your answer and now things are working fine :) $\endgroup$ – Vishaal Sudarsan Sep 3 '19 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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