Augmented Dickey-Fuller test

## Syntax

``h = adftest(y)``
``````[h,pValue,stat,cValue] = adftest(y)``````
``StatTbl = adftest(Tbl)``
``[___] = adftest(___,Name=Value)``
``[___,reg] = adftest(___)``

## Description

example

````h = adftest(y)` returns the rejection decision `h` from conducting an augmented Dickey-Fuller test for a unit root in a univariate time series `y`.```

example

``````[h,pValue,stat,cValue] = adftest(y)``` also returns the p-value `pValue`, test statistic `stat`, and critical value `cValue` of the test.```

example

````StatTbl = adftest(Tbl)` returns the table `StatTbl` containing variables for the test results, statistics, and settings from conducting an augmented Dickey-Fuller test for a unit root in the last variable of the input table or timetable `Tbl`. To select a different variable in `Tbl` to test, use the `DataVariable` name-value argument.```

example

````[___] = adftest(___,Name=Value)` uses additional options specified by one or more name-value arguments, using any input-argument combination in the previous syntaxes. `adftest` returns the output-argument combination for the corresponding input arguments.Some options control the number of tests to conduct. The following conditions apply when `adftest` conducts multiple tests: `adftest` treats each test as separate from all other tests.If you specify `y`, all outputs are vectors.If you specify `Tbl`, each row of `StatTbl` contains the results of the corresponding test. For example, `adftest(Tbl,DataVariable="GDP",Alpha=0.025,Lags=[0 1])` conducts two tests, at a level of significance of 0.025, for the presence of a unit root in the variable `GDP` of the table `Tbl`. The first test includes `0` lagged difference terms in the AR model, and the second test includes `1` lagged difference term in the AR model.```

example

````[___,reg] = adftest(___)` additionally returns a structure of regression statistics for the hypothesis test `reg`.```

## Examples

collapse all

Test a time series for a unit root using the default autoregressive model without augmented difference terms. Input the time series data as a numeric vector.

Load the Canadian inflation rate data and extract the CPI-based inflation rate `INF_C`.

```load Data_Canada y = DataTable.INF_C;```

Test the time series for a unit root.

`h = adftest(y)`
```h = logical 0 ```

The result `h = 0` indicates that this test fails to reject the null hypothesis of a unit root against the autoregressive alternative.

Load Canadian inflation rate data and extract the CPI-based inflation rate `INF_C`.

```load Data_Canada y = DataTable.INF_C;```

Test the time series for a unit root. Return the test decision, $\mathit{p}$-value, test statistic, and critical value.

`[h,pValue,stat,cValue] = adftest(y)`
```h = logical 0 ```
```pValue = 0.3255 ```
```stat = -0.8769 ```
```cValue = -1.9476 ```

Test a time series, which is one variable in a table, for a unit root using the default autoregressive model without augmented difference terms.

Load Canadian inflation rate data, which contains yearly measurements on five time series variables in the table `DataTable`.

`load Data_Canada`

Test the long-term bond rate series `INT_L`, the last variable in the table, for a unit root.

`StatTbl = adftest(DataTable)`
```StatTbl=1×8 table h pValue stat cValue Lags Alpha Model Test _____ ______ _______ _______ ____ _____ ______ ______ Test 1 false 0.7358 0.24601 -1.9476 0 0.05 {'AR'} {'T1'} ```

`adftest` returns test results and settings in the table `StatTbl`, where variables correspond to test results (`h`, `pValue`, `stat`, and `cValue`) and settings (`Lags`, `Alpha`, `Model`, and `Test`), and rows correspond to individual tests (in this case, `adftest` conducts one test).

By default, `adftest` tests the last variable in the table. To select a variable from an input table to test, set the `DataVariable` option.

Test a time series for a unit root against a trend-stationary alternative augmented with lagged difference terms.

Load a GDP data set. Compute the log of the series.

```load Data_GDP; Y = log(Data);```

Test for a unit root against a trend-stationary alternative, augmenting the model with 0, 1, and 2 lagged difference terms.

`h = adftest(Y,Model="TS",Lags=0:2)`
```h = 1x3 logical array 0 0 0 ```

`adftest` treats the three lag choices as three separate tests, and returns a vector with rejection decisions for each test. The values `h = 0` indicate that all three tests fail to reject the null hypothesis of a unit root against the trend-stationary alternative.

Test a time series for a unit root against trend-stationary alternatives augmented with different numbers of lagged difference terms. Look at the regression statistics corresponding to each of the alternative models to choose how many lagged difference terms to include in the augmented model.

Load a US macroeconomic data set `Data_USEconModel.mat`. Compute the log of the GDP and include the result as a new variable called `LogGDP` in the data set.

```load Data_USEconModel DataTable.LogGDP = log(DataTable.GDP);```

Test for a unit root in the logged GDP series using three different choices for the number of lagged difference terms. Return the regression statistics for each alternative model.

```[StatTbl,reg] = adftest(DataTable,DataVariable="LogGDP",Model="TS",Lags=0:2); StatTbl```
```StatTbl=3×8 table h pValue stat cValue Lags Alpha Model Test _____ _______ __________ _______ ____ _____ ______ ______ Test 1 false 0.999 1.0247 -3.4302 0 0.05 {'TS'} {'T1'} Test 2 false 0.99565 -0.0020747 -3.4303 1 0.05 {'TS'} {'T1'} Test 3 false 0.99214 -0.21274 -3.4304 2 0.05 {'TS'} {'T1'} ```

`adftest` treats each of the three lag choices as separate tests, and returns results and settings for each test along the rows of the table `StatTbl`. `reg` is a 3-by-1 structure array containing regression statistics corresponding to each of the three alternative models.

Display the names of the coefficients, their $\mathit{t}$-statistics and corresponding $\mathit{p}$-values, and the BIC resulting from the regression of the three alternative models.

```model1 = array2table([reg(1).tStats.t reg(1).tStats.pVal], ... RowNames=reg(1).names,VariableNames=["tStat" "pValue"])```
```model1=3×2 table tStat pValue ________ ___________ c -0.43299 0.6654 d -1.2195 0.22383 a 167.66 8.5908e-255 ```
```model2 = array2table([reg(2).tStats.t reg(2).tStats.pVal], ... RowNames=reg(2).names,VariableNames=["tStat" "pValue"])```
```model2=4×2 table tStat pValue ________ ___________ c 0.35537 0.72262 d -0.13077 0.89607 a 185.44 1.0349e-263 b1 8.1646 1.7553e-14 ```
```model3 = array2table([reg(3).tStats.t reg(3).tStats.pVal], ... RowNames=reg(3).names,VariableNames=["tStat" "pValue"])```
```model3=5×2 table tStat pValue ________ ___________ c 0.52121 0.6027 d 0.089107 0.92907 a 184.56 1.7276e-261 b1 6.4983 4.6217e-10 b2 1.8871 0.060353 ```

The first model has no added difference terms, the second model has one difference term (`b1`), and the third model has two difference terms (`b1` and `b2`). These results indicate that the coefficient of the first difference term is significantly different from zero in both the second and third models, but the coefficient of the second term in the third model is not at a 0.05 significance level. This result suggests augmenting the model with one lagged difference term is adequate.

Compare the BIC for each of the three alternatives.

`reg.BIC`
```ans = -1.5114e+03 ```
```ans = -1.5589e+03 ```
```ans = -1.5496e+03 ```

Of the three alternative models, the model augmented with one lagged difference term is the best because it yields the lowest BIC.

## Input Arguments

collapse all

Univariate time series data, specified as a numeric vector. Each element of `y` represents an observation.

Data Types: `double`

Time series data, specified as a table or timetable. Each row of `Tbl` is an observation.

Specify a single series (variable) to test by using the `DataVariable` argument. The selected variable must be numeric.

Note

`adftest` removes missing observations, represented by `NaN` values, from the input series.

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose `Name` in quotes.

Example: `adftest(Tbl,DataVariable="GDP",Alpha=0.025,Lags=[0 1])` conducts two separate tests at a level of significance of `0.025` on the variable G`GDP` of the input table `Tbl`. The first test includes `0` lagged difference terms in the AR model, and the second test includes `1` lagged difference term in the AR model.

Number p of lagged difference terms to include in the AR model, specified as a nonnegative integer or vector of nonnegative integers.

`adftest` conducts a separate test for each element in `Lags`.

Example: `Lags=[0 1]` includes no lags in the AR model for the first test, and then includes Δyt – 1 in the AR model for the second test.

Data Types: `double`

Model variant, specified as a model variant name, or a string vector or cell vector of model names. This table contains the supported model variant names.

Model Variant NameDescription
`"AR"`

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

`${y}_{t}={y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t}$`

against the alternative model

`${y}_{t}=\varphi {y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t},$`

with AR(1) coefficient $\varphi <1.$

`"ARD"`

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

`${y}_{t}={y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t}$`

against the alternative model

`${y}_{t}=c+\varphi {y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t},$`

with drift coefficient c and AR(1) coefficient $\varphi <1.$

`"TS"`

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

`${y}_{t}=c+{y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t}$`

against the alternative model

`${y}_{t}=c+\delta t+\varphi {y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+{\beta }_{2}\Delta {y}_{t-2}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t},$`

with drift coefficient c, deterministic trend coefficient δ, and AR(1) coefficient $\varphi <1.$

`adftest` conducts a separate test for each model variant name in `Model`.

Example: `Model=["AR" "ARD"]` uses the stationary AR model as the alternative hypothesis for the first test, and then uses the stationary AR model with drift as the alternative hypothesis for the second test.

Data Types: `char` | `cell` | `string`

Test statistic, specified as a test name, or a string vector or cell vector of test names. This table contains the supported test names.

Test NameDescription
`"t1"`

Standard t statistic

`${t}_{1}=\frac{\stackrel{^}{\varphi }-1}{\text{SE}\left(\stackrel{^}{\varphi }\right)},$`

computed using the OLS estimate of the AR(1) coefficient $\stackrel{^}{\varphi }$ and its standard error SE($\stackrel{^}{\varphi }$), in the alternative model.

The test assesses the significance of the restriction, $\varphi -1=0.$

`"t2"`

`${t}_{2}=\frac{T\left(\stackrel{^}{\varphi }-1\right)}{1-{\stackrel{^}{\beta }}_{1}-\dots -{\stackrel{^}{\beta }}_{p}},$`

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

The test assesses the significance of the restriction, $\varphi -1=0.$

`"F"`

F statistic for assessing the significance of a joint restriction on the alternative model.

• For model variant (`Model` argument) `"ARD"`, the restrictions are$\varphi -1=0$ and c = 0.

• For model variant `"TS"`, the restrictions are$\varphi -1=0$ and δ = 0.

An F statistic is invalid for model variant `"AR"`.

`adftest` conducts a separate test for each test name in `Test`.

Example: `Test="F"` computes the F test statistic for all tests.

Data Types: `char` | `cell` | `string`

Nominal significance level for the hypothesis test, specified as a numeric scalar between `0.001` and `0.999` or a numeric vector of such values.

`adftest` conducts a separate test for each value in `Alpha`.

Example: `Alpha=[0.01 0.05]` uses a level of significance of `0.01` for the first test, and then uses a level of significance of `0.05` for the second test.

Data Types: `double`

Variable in `Tbl` to test, specified as a string scalar or character vector containing a variable name in `Tbl.Properties.VariableNames`, or an integer or logical vector representing the index of a name. The selected variable must be numeric.

Example: `DataVariable="GDP"`

Example: `DataVariable=[false true false false]` or `DataVariable=2` tests the second table variable.

Data Types: `double` | `logical` | `char` | `string`

Note

• When `adftest` conducts multiple tests, the function applies all single settings (scalars or character vectors) to each test.

• All vector-valued specifications that control the number of tests must have equal length.

• If you specify the vector `y` and any value is a row vector, all outputs are row vectors.

• A lagged and differenced time series has a reduced sample size. Absent presample values, if the test series yt is defined for t = 1,…,T, the lagged series yt– k is defined for t = k+1,…,T. The first difference applied to the lagged series yt– k further reduces the time base to k+2,…,T. With p lagged differences, the common time base is p+2,…,T and the effective sample size is T–(p+1).

## Output Arguments

collapse all

Test rejection decisions, returned as a logical scalar or vector with length equal to the number of tests. `adftest` returns `h` when you supply the input `y`.

• Values of `1` indicate rejection of the unit-root null model in favor of the alternative model.

• Values of `0` indicate failure to reject the unit-root null model.

Test statistic p-values, returned as a numeric scalar or vector with length equal to the number of tests. `adftest` returns `pValue` when you supply the input `y`.

• The p-value of test statistic (`Test`) `"t1"` or `"t2"` is a left-tail probability.

• The p-value of test statistic `"F"` is a right-tail probability.

When test statistics are outside tabulated critical values, `adftest` returns maximum (`0.999`) or minimum (`0.001`) p-values.

Test statistics, returned as a numeric scalar or vector with length equal to the number of tests. `adftest` returns `stat` when you supply the input `y`.

`adftest` computes test statistics using ordinary least squares (OLS) estimates of the coefficients in the alternative model.

Critical values, returned as a numeric scalar or vector with length equal to the number of tests. `adftest` returns `cValue` when you supply the input `y`.

• The critical value of test statistic (`Test`) `"t1"` or `"t2"` is for a left-tail probability.

• The critical value of test statistic `"F"` is for a right-tail probability.

Test summary, returned as a table with variables for the outputs `h`, `pValue`, `stat`, and `cValue`, and with a row for each test. `adftest` returns `StatTbl` when you supply the input `Tbl`.

`StatTbl` contains variables for the test settings specified by `Lags`, `Alpha`, `Model`, and `Test`.

Regression statistics from the OLS estimation of coefficients in the alternative model, returned as a structure array with number of records equal to the number of tests.

Each element of `reg` has the fields in this table. You can access a field using dot notation, for example, `reg(1).coeff` contains the coefficient estimates of the first test.

FieldDescription
`num`Length of input series with `NaN`s removed
`size`Effective sample size T, `num` adjusted for lags
`names`Regression coefficient names
`coeff`Estimated coefficient values
`se`Estimated coefficient standard errors
`Cov`Estimated coefficient covariance matrix
`tStats`t statistics of coefficients and p-values
`FStat`F statistic and p-value
`yMu`Mean of the lag-adjusted input series
`ySigma`Standard deviation of the lag-adjusted input series
`yHat`Fitted values of the lag-adjusted input series
`res`Regression residuals
`DWStat`Durbin-Watson statistic
`SSR`Regression sum of squares
`SSE`Error sum of squares
`SST`Total sum of squares
`MSE`Mean square error
`RMSE`Standard error of the regression
`RSq`R2 statistic
`aRSq`Adjusted R2 statistic
`LL`Loglikelihood of data under Gaussian innovations
`AIC`Akaike information criterion
`BIC`Bayesian (Schwarz) information criterion
`HQC`Hannan-Quinn information criterion

collapse all

### Augmented Dickey-Fuller Test for Unit Root

The augmented Dickey-Fuller test for a unit root assesses the null hypothesis of a unit root in the time series yt, where

`${y}_{t}=c+\delta t+\varphi {y}_{t-1}+{\beta }_{1}\Delta {y}_{t-1}+\dots +{\beta }_{p}\Delta {y}_{t-p}+{\epsilon }_{t},$`

and

• Δ is the differencing operator such that $\Delta {y}_{t}={y}_{t}-{y}_{t-1}.$

• p is the number of lagged difference terms (see `Lags`).

• c is the drift coefficient (see `Model`).

• δ is the deterministic trend coefficient (see `Model`).

• εt is a mean zero innovation process.

The null hypothesis of a unit root is

`${H}_{0}:\varphi =1.$`

Under the alternative hypothesis, $\varphi <1.$

Variants of the model allow for different growth characteristics (see `Model`). 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.

## Tips

• To draw valid inferences from the test, determine a suitable value for `Lags`.

One method is to begin with a maximum lag, such as the one recommended in [7], and then test down by assessing the significance of ${\stackrel{^}{\beta }}_{p}$, the coefficient of the largest lagged change in yt. The usual t statistic is appropriate, as returned in the `reg` output structure.

Another method is to combine a measure of fit, such as the SSR, with information criteria, such as AIC, BIC, and HQC. These statistics are also returned in the `reg` output structure. For more details, see [6].

• With a specific testing strategy in mind, determine the value of `Model` by the growth characteristics of yt. If you include too many regressors (see `Lags`), the test loses power; if you include too few regressors, the test is biased towards favoring the null model [4]. In general, if a series grows, the `"TS"` model (see `Model`) provides a reasonable trend-stationary alternative to a unit-root process with drift. If a series is does not grow, the `"AR"` and `"ARD"` models provide reasonable stationary alternatives to a unit-root process without drift. The `"ARD"` alternative model has a mean of c/(1 – a); the `"AR"` alternative model has mean 0.

## Algorithms

Dickey-Fuller statistics follow nonstandard distributions under the null hypothesis (even asymptotically). `adftest` uses tabulated critical values, generated by Monte Carlo simulations, for a range of sample sizes and significance levels of the null model with Gaussian innovations and five million replications per sample size. `adftest` interpolates critical values `cValue` and p-values `pValue` from the tables. Tables for tests of `Test` types `"t1"` and `"t2"` are identical to those for `pptest`. For small samples, tabulated values are valid only for Gaussian innovations. For large samples, values are also valid for non-Gaussian innovations.

## References

[1] Davidson, R., and J. G. MacKinnon. Econometric Theory and Methods. Oxford, UK: Oxford University Press, 2004.

[2] Dickey, D. A., and W. A. Fuller. "Distribution of the Estimators for Autoregressive Time Series with a Unit Root." Journal of the American Statistical Association. Vol. 74, 1979, pp. 427–431.

[3] Dickey, D. A., and W. A. Fuller. "Likelihood Ratio Statistics for Autoregressive Time Series with a Unit Root." Econometrica. Vol. 49, 1981, pp. 1057–1072.

[4] Elder, J., and P. E. Kennedy. "Testing for Unit Roots: What Should Students Be Taught?" Journal of Economic Education. Vol. 32, 2001, pp. 137–146.

[5] Hamilton, James D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.

[6] Ng, S., and P. Perron. "Unit Root Tests in ARMA Models with Data-Dependent Methods for the Selection of the Truncation Lag." Journal of the American Statistical Association. Vol. 90, 1995, pp. 268–281.

[7] Schwert, W. "Tests for Unit Roots: A Monte Carlo Investigation." Journal of Business and Economic Statistics. Vol. 7, 1989, pp. 147–159.

## Version History

Introduced in R2009b