Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_uni_dickey_fuller_unit (g13aw)

## Purpose

nag_tsa_uni_dickey_fuller_unit (g13aw) returns the (augmented) Dickey–Fuller unit root test.

## Syntax

[ts, ifail] = g13aw(type, p, y, 'n', n)
[ts, ifail] = nag_tsa_uni_dickey_fuller_unit(type, p, y, 'n', n)

## 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. nag_tsa_uni_dickey_fuller_unit (g13aw) 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
 $∇yt = β1 yt-1 + ∑ i=1 p-1 δi ∇ yt-i +εt$
is fit and the test statistic $\tau$ constructed as
 $τ = β^1 σ11$
where $\nabla$ is the difference operator, with $\nabla {y}_{t}={y}_{t}-{y}_{t-1}$, and where ${\stackrel{^}{\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
 $∇yt = β1 yt-1 + ∑ i=1 p-1 δi ∇ yt-i +α +εt$
is fit and the test statistic ${\tau }_{\mu }$ constructed as
 $τμ = β^1 σ11$
To test for a unit root with drift and deterministic time trend the regression model
 $∇yt = β1 yt-1 + ∑ i=1 p-1 δi ∇ yt-i +α +β2t +εt$
is fit and the test statistic ${\tau }_{\tau }$ constructed as
 $ττ = β^1 σ11$
The distributions of the three test statistics; $\tau$, ${\tau }_{\mu }$ and ${\tau }_{\tau }$, are nonstandard. An associated probability can be obtained from nag_stat_prob_dickey_fuller_unit (g01ew).

## 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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{type}$int64int32nag_int scalar
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:     $\mathrm{p}$int64int32nag_int scalar
$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:     $\mathrm{y}\left({\mathbf{n}}\right)$ – double array
$y$, the time series.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the dimension of the array y.
$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$.

### Output Parameters

1:     $\mathrm{ts}$ – double scalar
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=11$
Constraint: ${\mathbf{type}}=1$, $2$ or $3$.
${\mathbf{ifail}}=21$
Constraint: ${\mathbf{p}}>0$.
${\mathbf{ifail}}=31$
Constraint:
• 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$.
${\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 ${\stackrel{^}{\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.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

None.

None.

## 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.
```function g13aw_example

fprintf('g13aw example results\n\n');

% Test type
type = int64(1);

% Order of the AR process
p = int64(1);

% Time series
y = [ -217; -177; -166; -136; -110;  -95;  -64;  -37;  -14;  -25;
-51;  -62;  -73;  -88; -113; -120;  -83;  -33;  -19;   21;
17;   44;   44;   78;   88;  122;  126;  114;   85;   64];

% Calculate the Dickey-Fuller test statistic
[ts,ifail] = g13aw(type,p,y);

% The p-value routine can issue a warning, but still return
% sensible results, so save current warning state and turn warnings on
warn_state = nag_issue_warnings();
nag_issue_warnings(true);

% Get the associated p-value
n = int64(size(y,1));
[pvalue,~,ifail] = g01ew(type,n,ts);

% Reset the warning state to its initial value
nag_issue_warnings(warn_state);

% Print the results
fprintf('Dickey-Fuller test statistic     = %6.3f\n', ts);
fprintf('associated p-value               = %6.3f\n', pvalue);

```
```g13aw example results

Dickey-Fuller test statistic     = -2.540
associated p-value               =  0.013
```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015