3
$\begingroup$

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

y=rnorm(1,5,1)
for(i in 1:100)
  y=append(y,tail(y,1)+rnorm(1,1,1))

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 the 5% level and the series is stationary. While from the plot the series is clearly NOT stationary. Can someone explain what's going on?

$\endgroup$

2 Answers 2

3
$\begingroup$

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){
  y=rnorm(1,5,1)
  for(i in 1:100){
      y=append(y,tail(y,1)+rnorm(1,1,1))
  }
  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.

$\endgroup$
1
  • $\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$ Sep 3, 2019 at 13:24
0
$\begingroup$

The adf.test() from the TsSeries package runs the test under the assumption that there is a constant AND a trend. After considering those in your data the time series would most likely be stationary. The adf.test() from the aTSA function uses all three DF type tests including the one for no drift no constant, which would most likely result in non-stationary in your case. But I do not know why the adf.test() function is limited to only one case (trend and drift).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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