hide long namesshow long names
hide short namesshow short names
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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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: τ, τμ or ττ, 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, yt, for t=1,2,,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 τ constructed as
τ = β^1 σ11  
where  is the difference operator, with yt = yt- yt-1 , and where β^1 and σ11 are the least squares estimate and associated standard error for β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 τμ 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 ττ constructed as
ττ = β^1 σ11  
The distributions of the three test statistics; τ, τμ and ττ, 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:     type int64int32nag_int scalar
The type of unit test for which the probability is required.
type=1
A unit root test will be performed and τ returned.
type=2
A unit root test with drift will be performed and τμ returned.
type=3
A unit root test with drift and deterministic time trend will be performed and ττ returned.
Constraint: type=1, 2 or 3.
2:     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: p>0.
3:     yn – double array
y, the time series.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array y.
n, the length of the time series.
Constraints:
  • if type=1, n>2p;
  • if type=2, n>2p+1;
  • if type=3, n>2p+2.

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=11
Constraint: type=1, 2 or 3.
   ifail=21
Constraint: p>0.
   ifail=31
Constraint:
  • if type=1, n>2p;
  • if type=2, n>2p+1;
  • if type=3, n>2p+2.
   ifail=41
On entry, the design matrix used in the estimation of β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.
   ifail=42
σ11=0, therefore depending on the sign of β^1, a large positive or negative value has been returned.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

None.

Further Comments

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