Skip to Main Content Skip to Search
Product Documentation

adftest - Augmented Dickey-Fuller test

Syntax

Description

example

h = adftest(Y) returns a logical with the rejection decision from testing the null hypothesis of a unit root in a univariate time series, Y.

example

h = adftest(Y,Name,Value) returns the rejection decision for the null hypothesis with additional options specified by one or more Name,Value pair arguments.

  • If any Name,Value argument is a vector, then adftest(Y,Name,Value) treats each element as a separate test, returning a vector of rejection decisions.

  • If any Name,Value argument is a vector, then all Name,Value arguments specified must be vectors of equal length or length one.

  • If any Name,Value argument is a row vector, then adftest(Y,Name,Value) returns a row vector.

example

[h,pValue,stat,cValue,reg] = adftest(___) returns the p-value, test statistic, critical value, and a structure of regression statistics for the hypothesis test.

  • If any Name,Value argument is a vector, then adftest(Y,Name,Value) returns a vector of equal length for each specified output.

Examples

Dickey-Fuller Test Without Augmentation

Test Canadian inflation rate (based on CPI) for a unit root using the default autoregression model with no added difference terms.

Load the Canadian inflation rate data.

load Data_Canada
Y = Dataset.INF_C;

Test for a unit root.

h = adftest(Y)
h =

     0

The test fails to reject the null hypothesis of a unit root against the autoregressive alternative.

Conduct an Augmented Dickey-Fuller Test Using the Trend-Stationary Alternative

Test log GDP data for a unit root using a trend-stationary alternative with 0 to 2 lagged differences.

Load the GDP data, and calculate the log.

load Data_GDP;
Y = log(Data);

Test for a unit root using three lag choices.

h = adftest(Y,'model','TS','lags',0:2)
h =

     0     0     0

The test fails to reject the null hypothesis of a unit root against the trend-stationary alternative for all three lags.

Choose the Number of Lags in the Augmented Model

Test log GDP data for a unit root using a trend-stationary alternative with 0 to 2 lagged differences. Look at the regression statistics for the alternative models to choose the best number of lags.

Load the GDP data, and calculate the log.

load Data_GDP;
Y = log(Data);

Test for a unit root using three lag choices. Output the regression statistics for the alternative model.

[h,~,~,~,reg] = adftest(Y,'model','TS','lags',0:2);

The output reg is an array of three data structures, corresponding to each alternative model.

Display the names of the coefficients included in each of the three alternatives.

reg.names
ans = 

    'c'
    'd'
    'a'


ans = 

    'c'
    'd'
    'a'
    'b1'


ans = 

    'c'
    'd'
    'a'
    'b1'
    'b2'

The first model has no added difference terms (a lag of 0), the second model has one difference term (a lag of 1), and the third model has two difference terms (a lag of 2).

Display the t statistics and corresponding p-values for each coefficient in the three alternative models.

[reg(1).tStats.t reg(1).tStats.pVal]
ans =

    2.0533    0.0412
    1.8842    0.0608
   61.4717    0.0000
[reg(2).tStats.t reg(2).tStats.pVal]
ans =

    2.9026    0.0041
    2.7681    0.0061
   64.1396    0.0000
    5.6514    0.0000
[reg(3).tStats.t reg(3).tStats.pVal]
ans =

    3.2568    0.0013
    3.1249    0.0020
   62.7825    0.0000
    4.7586    0.0000
    1.7615    0.0795

The coefficient on the first difference term is significantly different from zero, but the coefficient on the second term is not. This suggests augmenting the model with 1 lag is adequate.

Compare the BIC for each of the three alternatives.

reg.BIC
ans =

  -1.4774e+03


ans =

  -1.4966e+03


ans =

  -1.4878e+03

The alternative model augmented with one difference term has the best (that is, the smallest) BIC value.

Input Arguments

Y

Univariate time series
vector

Univariate time series, specified as a column vector. The last element is the most recent observation. adftest ignores NaNs, which indicate missing observations.

Data Types: double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'lags',0:2,'alpha',0.1 specifies three tests at lags 0, 1, and 2, all conducted at the 0.1 significance level

'alpha'

Significance level
0.05 (default) | scalar | vector

Nominal significance levels for the hypothesis tests, specified as the comma-separated pair consisting of 'alpha' and a scalar or vector. All values of alpha must be between 0.001 and 0.999.

Example: 'alpha',0.01

Data Types: double

'lags'

Model lags
0 (default) | nonnegative integer | vector of nonnegative integers

The number of lagged changes of Y to include in the model, specified as the comma-separated pair consisting of 'lags' and nonnegative integer or vector of nonnegative integers.

Example: 'lags',[0,1,2]

Data Types: double

'model'

Model variant
'AR' (default) | 'ARD' | 'TS'

Model variant, specified as the comma-separated pair consisting of 'model' and a string or cell vector of strings with these possible values:

'AR'Autoregressive model variant, which specifies a test of the null model

against the alternative model

with AR(1) coefficient,

'ARD'Autoregressive model with drift variant, which specifies a test of the null model

against the alternative model

with drift coefficient, c, and AR(1) coefficient,

'TS'Trend-stationary model variant, which specifies a test of the null model

against the alternative model

with drift coefficient, c, deterministic trend coefficient, δ, and AR(1) coefficient,

Example: 'model',{'AR','ARD'}

'test'

Test statistic
't1' (default) | 't2' | 'F'

Test statistic, specified as the comma-separated pair consisting of 'test' and a string or cell vector of strings with these possible values:

't1'Standard t statistic,

computed using the OLS estimate of the AR(1) coefficient, and its standard error (se), in the alternative model.

The test assesses the significance of the restriction,

't2'Lag-adjusted, unstudentized t statistic,

computed using the OLS estimates of the AR(1) coefficient and stationary coefficients in the alternative model. N is the effective sample size, adjusted for lags and missing values.

The test assesses the significance of the restriction,

'F'F statistic for assessing the significance of a joint restriction on the alternative model.
  • For model variant 'ARD', the restrictions are and c = 0.

  • For model variant 'TS', the restrictions are and δ = 0.

An F statistic is invalid for model variant 'AR'.

Example: 'test','t2'

Output Arguments

h

Test rejection decisions
logical | vector of logicals

Test rejection decisions, returned as a logical or vector of logicals with length equal to the number of tests conducted.

  • h = 1 indicates rejection of the unit-root null in favor of the alternative model.

  • h = 0 indicates failure to reject the unit-root null.

pValue

Test statistic p-values
scalar | vector

Test statistic p-values, returned as a scalar or vector with length equal to the number of tests conducted.

  • If the test statistic is 't1' or 't2', p-values are left-tail probabilities.

  • If the test statistic is 'F', p-values are right-tail probabilities.

stat

Test statistics
scalar | vector

Test statistics, returned as a scalar or vector with length equal to the number of tests conducted. adftest computes test statistics using OLS estimates of the coefficients in the alternative model.

cValue

Critical values
scalar | vector

Critical values, returned as a scalar or vector with length equal to the number of tests conducted.

  • If the test statistic is 't1' or 't2', critical values are for left-tail probabilities.

  • If the test statistic is 'F', critical values are for right-tail probabilities.

reg

Regression statistics
data structure | data structure array

Regression statistics for OLS estimation of coefficients in the alternative model, returned as a data structure or data structure array with length equal to the number of tests conducted.

Each data structure has the following fields.

FieldDescription
numLength of input series with NaNs removed
sizeEffective sample size, adjusted for lags
namesRegression coefficient names
coeffEstimated coefficient values
seEstimated coefficient standard errors
CovEstimated coefficient covariance matrix
tStatst statistics of coefficients and p-values
FStatF statistic and p-value
yMuMean of the lag-adjusted input series
ySigmaStandard deviation of the lag-adjusted input series
yHatFitted values of the lag-adjusted input series
resRegression residuals
DWStatDurbin-Watson statistic
SSRRegression sum of squares
SSEError sum of squares
SSTTotal sum of squares
MSEMean square error
RMSEStandard error of the regression
RSqR2 statistic
aRSqAdjusted R2 statistic
LLLoglikelihood of data under Gaussian innovations
AICAkaike information criterion
BICBayesian (Schwarz) information criterion
HQCHannan-Quinn information criterion

Definitions

Augmented Dickey-Fuller Test for a Unit Root

The Augmented Dickey-Fuller test assesses the null hypothesis of a unit root using the model

where

The null hypothesis of a unit root is

Under the alternative hypothesis,

Variants of the model allow for different growth characteristics. The model with δ = 0 has no trend component, and the model with c = 0 and δ = 0 has no drift or trend.

A test that fails to reject the null hypothesis, fails to reject the possibility of a unit root.

Algorithms

See Also

i10test | kpsstest | lmctest | pptest | vratiotest

Related Examples

More About

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS