adf.test | R Documentation |
Performs the Augmented Dickey-Fuller test for the null hypothesis
of a unit root of a univarate time series x
(equivalently, x
is a
non-stationary time series).
adf.test(x, nlag = NULL, output = TRUE)
x |
a numeric vector or univariate time series. |
nlag |
the lag order with default to calculate the test statistic. See details for the default. |
output |
a logical value indicating to print the test results in R console.
The default is |
The Augmented Dickey-Fuller test incorporates
three types of linear regression models. The first type (type1
) is a linear model
with no drift and linear trend with respect to time:
dx[t] = \rho*x[t-1] + \beta[1]*dx[t-1] + ... + \beta[nlag - 1]*dx[t - nlag + 1]
+e[t],
where d
is an operator of first order difference, i.e.,
dx[t] = x[t] - x[t-1]
, and e[t]
is an error term.
The second type (type2
) is a linear model with drift but no linear trend:
dx[t] = \mu + \rho*x[t-1] + \beta[1]*dx[t-1] + ... +
\beta[nlag - 1]*dx[t - nlag + 1] +e[t].
The third type (type3
) is a linear model with both drift and linear trend:
dx[t] = \mu + \beta*t + \rho*x[t-1] + \beta[1]*dx[t-1] + ... +
\beta[nlag - 1]*dx[t - nlag + 1] +e[t].
We use the default nlag = floor(4*(length(x)/100)^(2/9))
to
calcuate the test statistic.
The Augmented Dickey-Fuller test statistic is defined as
ADF = \rho.hat/S.E(\rho.hat),
where \rho.hat
is the coefficient estimation
and S.E(\rho.hat)
is its corresponding estimation of standard error for each
type of linear model. The p.value is
calculated by interpolating the test statistics from the corresponding critical values
tables (see Table 10.A.2 in Fuller (1996)) for each type of linear models with given
sample size n
= length(x
).
The Dickey-Fuller test is a special case of Augmented Dickey-Fuller test
when nlag
= 2.
A list containing the following components:
type1 |
a matrix with three columns: |
type2 |
same as above for the second type of linear model. |
type3 |
same as above for the third type of linear model. |
Missing values are removed.
Debin Qiu
Fuller, W. A. (1996). Introduction to Statistical Time Series, second ed., New York: John Wiley and Sons.
pp.test
, kpss.test
, stationary.test
# ADF test for AR(1) process
x <- arima.sim(list(order = c(1,0,0),ar = 0.2),n = 100)
adf.test(x)
# ADF test for co2 data
adf.test(co2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.