[R] R-help Digest, Vol 170, Issue 29

Adrian Trapletti adrian at trapletti.org
Sun Apr 30 10:55:04 CEST 2017


> Message: 1
> Date: Fri, 28 Apr 2017 11:07:40 +0000
> From: T.Riedle <tr206 at kent.ac.uk>
> To: "R-help at r-project.org" <R-help at r-project.org>
> Subject: [R] Augmented Dickey Fuller test
> Message-ID: <1493377701072.16786 at kent.ac.uk>
> Content-Type: text/plain; charset="UTF-8"
>
> Dear all,
>
> I am trying to run an ADF test using the adf.test() function in the tseries package and the ur.df() function in the urca package. The results I get contrast sharply. Whilst the adf.test() indicates stationarity which is in line with the corresponding graph, the ur.df() indicates non-stationarity.
>

In a simple example I can't reproduce your finding. The test statistic
of adf.test() and ur.df() are identical:

> library(urca)
> library(tseries)
>
> set.seed(1)
>
> x <- rnorm(1000)  # no unit-root
> adf.test(x)

Augmented Dickey-Fuller Test

data:  x
Dickey-Fuller = -9.9291, Lag order = 9, p-value = 0.01
alternative hypothesis: stationary

Warning message:
In adf.test(x) : p-value smaller than printed p-value
> ur.df(x, lags=trunc((length(x)-1)^(1/3)), type="trend")

###############################################################
# Augmented Dickey-Fuller Test Unit Root / Cointegration Test #
###############################################################

The value of the test statistic is: -9.9291 32.869 49.2953

>
> y <- diffinv(x)   # contains a unit-root
> adf.test(y)

Augmented Dickey-Fuller Test

data:  y
Dickey-Fuller = -2.5115, Lag order = 9, p-value = 0.3618
alternative hypothesis: stationary

> ur.df(y, lags=trunc((length(y)-1)^(1/3)),  type="trend")

###############################################################
# Augmented Dickey-Fuller Test Unit Root / Cointegration Test #
###############################################################

The value of the test statistic is: -2.5115 2.4203 3.5281

>
>
> Why does this happen? Could anybody explain the adf.test() function in more detail? How does adf.test() select the number of lags is it AIC or BIC and how does it take an intercept and/or a trend into account?

?adf.test

Details

The general regression equation which incorporates a constant and a
linear trend is used and the t-statistic for a first order
autoregressive coefficient equals one is computed. The number of lags
used in the regression is k. The default value of
trunc((length(x)-1)^(1/3)) corresponds to the suggested upper bound on
the rate at which the number of lags, k, should be made to grow with
the sample size for the general ARMA(p,q) setup.

References

A. Banerjee, J. J. Dolado, J. W. Galbraith, and D. F. Hendry (1993):
Cointegration, Error Correction, and the Econometric Analysis of
Non-Stationary Data, Oxford University Press, Oxford.
S. E. Said and D. A. Dickey (1984): Testing for Unit Roots in
Autoregressive-Moving Average Models of Unknown Order. Biometrika 71,
599–607.

>
>
>
> Help is greatly appreciated.
>
>
>
> Thanks in advance.
>
>         [[alternative HTML version deleted]]
>

Best regards

Adrian

--
Adrian Trapletti

Steinstrasse 9b, 8610 Uster, Switzerland
P +41 44 994 56 30  |  M +41 79 103 71 31
adrian at trapletti.org  |  www.trapletti.org



More information about the R-help mailing list