NAG Library Routine Document
g13awf (uni_dickey_fuller_unit)
1
Purpose
g13awf returns the (augmented) Dickey–Fuller unit root test.
2
Specification
Fortran Interface
Real (Kind=nag_wp)  ::  g13awf  Integer, Intent (In)  ::  type, p, n  Integer, Intent (Inout)  ::  ifail  Real (Kind=nag_wp), Intent (In)  ::  y(n) 

C Header Interface
#include nagmk26.h
double 
g13awf_ (const Integer *typ, const Integer *p, const Integer *n, const double y[], Integer *ifail) 

3
Description
If the root of the characteristic equation for a time series is one then that series is said to have a unit root. Such series are nonstationary. g13awf returns one of three types of (augmented) Dickey–Fuller test statistic: $\tau $, ${\tau}_{\mu}$ or ${\tau}_{\tau}$, used to test for a unit root, a unit root with drift or a unit root with drift and a deterministic time trend, respectively.
To test whether a time series,
${y}_{t}$, for
$\mathit{t}=1,2,\dots ,n$, has a unit root, the regression model
is fitted and the test statistic
$\tau $ constructed as
where
$\nabla $ is the difference operator, with
$\nabla {y}_{t}={y}_{t}{y}_{t1}$, and where
${\hat{\beta}}_{1}$ and
${\sigma}_{11}$ are the least squares estimate and associated standard error for
${\beta}_{1}$ respectively.
To test for a unit root with drift the regression model
is fit and the test statistic
${\tau}_{\mu}$ constructed as
To test for a unit root with drift and deterministic time trend the regression model
is fit and the test statistic
${\tau}_{\tau}$ constructed as
The distributions of the three test statistics;
$\tau $,
${\tau}_{\mu}$ and
${\tau}_{\tau}$, are nonstandard. An associated probability can be obtained from
g01ewf.
4
References
Dickey A D (1976) Estimation and hypothesis testing in nonstationary time series PhD Thesis Iowa State University, Ames, Iowa
Dickey A D and Fuller W A (1979) Distribution of the estimators for autoregressive time series with a unit root J. Am. Stat. Assoc. 74 366 427–431
5
Arguments
 1: $\mathbf{type}$ – IntegerInput

On entry: the type of unit test for which the probability is required.
 ${\mathbf{type}}=1$
 A unit root test will be performed and $\tau $ returned.
 ${\mathbf{type}}=2$
 A unit root test with drift will be performed and ${\tau}_{\mu}$ returned.
 ${\mathbf{type}}=3$
 A unit root test with drift and deterministic time trend will be performed and ${\tau}_{\tau}$ returned.
Constraint:
${\mathbf{type}}=1$, $2$ or $3$.
 2: $\mathbf{p}$ – IntegerInput

On entry: $p$, the degree of the autoregressive (AR) component of the Dickey–Fuller test statistic. When $p>1$ the test is usually referred to as the augmented Dickey–Fuller test.
Constraint:
${\mathbf{p}}>0$.
 3: $\mathbf{n}$ – IntegerInput

On entry: $n$, the length of the time series.
Constraints:
 if ${\mathbf{type}}=1$, ${\mathbf{n}}>2{\mathbf{p}}$;
 if ${\mathbf{type}}=2$, ${\mathbf{n}}>2{\mathbf{p}}+1$;
 if ${\mathbf{type}}=3$, ${\mathbf{n}}>2{\mathbf{p}}+2$.
 4: $\mathbf{y}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayInput

On entry: $y$, the time series.
 5: $\mathbf{ifail}$ – IntegerInput/Output

On entry:
ifail must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit:
${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
 ${\mathbf{ifail}}=11$

On entry, ${\mathbf{type}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{type}}=1$, $2$ or $3$.
 ${\mathbf{ifail}}=21$

On entry, ${\mathbf{p}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{p}}>0$.
 ${\mathbf{ifail}}=31$

On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}>\u2329\mathit{\text{value}}\u232a$.
 ${\mathbf{ifail}}=41$

On entry, the design matrix used in the estimation of ${\beta}_{1}$ is not of full rank, this is usually due to all elements of the series being virtually identical. The returned statistic is therefore not unique and likely to be meaningless.
 ${\mathbf{ifail}}=42$

${\sigma}_{11}=0$, therefore depending on the sign of ${\hat{\beta}}_{1}$, a large positive or negative value has been returned.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
None.
8
Parallelism and Performance
g13awf is not threaded in any implementation.
None.
10
Example
In this example a Dickey–Fuller unit root test is applied to a time series related to the rate of the earth's rotation about its polar axis.
10.1
Program Text
Program Text (g13awfe.f90)
10.2
Program Data
Program Data (g13awfe.d)
10.3
Program Results
Program Results (g13awfe.r)