arch.unitroot.ADF

class arch.unitroot.ADF(y: ndarray | DataFrame | Series, lags: int | None = None, trend: 'n' | 'c' | 'ct' | 'ctt' = 'c', max_lags: int | None = None, method: 'aic' | 'bic' | 't-stat' | 'maic' = 'aic', low_memory: bool | None = None)[source]

Augmented Dickey-Fuller unit root test.

Parameters:
y: ndarray | DataFrame | Series

The data to test for a unit root.

lags: int | None = None

The number of lags to use in the ADF regression. If omitted or None, method is used to automatically select the lag length with no more than max_lags lags included.

trend: 'n' | 'c' | 'ct' | 'ctt' = 'c'

The trend component to include in the test. Not case sensitive.

  • ”n” - No trend components

  • ”c” - Include a constant

  • ”ct” - Include a constant and linear time trend

  • ”ctt” - Include a constant and linear and quadratic time trends

max_lags: int | None = None

The maximum number of lags to use when selecting lag length. If omitted or None, the maximum number of lags is 12 * (nobs/100) ** (1/4), rounded up, reduced when needed in short samples.

method: 'aic' | 'bic' | 't-stat' | 'maic' = 'aic'

The method to use when selecting the lag length. Not case sensitive.

  • ”aic” - Select the minimum of the Akaike IC

  • ”bic” - Select the minimum of the Schwarz/Bayesian IC

  • ”t-stat” - Select the largest lag length for which the t-statistic of the last lag is significant, using a cut-off of 1.645 for the absolute value of the t-statistic

  • ”maic” - Select the minimum of Ng and Perron’s modified Akaike IC ([5])

low_memory: bool | None = None

Flag indicating whether to use a low memory implementation of the lag selection algorithm. The low memory algorithm is slower than the standard algorithm but will use 2-4% of the memory required for the standard algorithm. This options allows automatic lag selection to be used in very long time series. If None, the low memory algorithm is used when the series has more than 100,000 observations.

Raises:
  • TypeError – If y cannot be converted to numbers, lags or max_lags is not an integer, low_memory is not a bool or None, or trend or method is not a str.

  • ValueError – If y is not 1-d or contains NaN or inf, lags or max_lags is negative, or trend or method is not one of the options.

  • InfeasibleTestException – If y has too few observations for trend, or lags or max_lags is larger than the observations can support. A regression with lags lags needs at least 3 + 2 * lags + the number of trend terms observations. This is also a ValueError.

Notes

The null hypothesis of the Augmented Dickey-Fuller is that there is a unit root, with the alternative that there is no unit root. If the pvalue is above a critical size, then the null cannot be rejected and the series appears to be a unit root.

The p-values are obtained through regression surface approximation from MacKinnon (1994) using the updated 2010 tables. If the p-value is close to significant, then the critical values should be used to judge whether to reject the null.

The autolag option and maxlag for it are described in Greene [1]. See Hamilton [2] for more on ADF tests. Critical value simulation based on MacKinnon [3] and [4].

References

Examples

>>> from arch.unitroot import ADF
>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.macrodata.load().data
>>> inflation = np.diff(np.log(data["cpi"]))
>>> adf = ADF(inflation)
>>> print(f"{adf.stat:0.4f}")
-3.0931
>>> print(f"{adf.pvalue:0.4f}")
0.0271
>>> adf.lags
2
>>> adf = ADF(inflation, trend="ct")
>>> print(f"{adf.stat:0.4f}")
-3.2111
>>> print(f"{adf.pvalue:0.4f}")
0.0822

Methods

summary()

Summary of test, containing statistic, p-value and critical values.

Properties

alternative_hypothesis

The alternative hypothesis.

critical_values

The critical values of the test.

lags

The number of lags used in the model.

max_lags

The maximum lags used when automatically selecting lag length.

nobs

The number of observations used when computing the test statistic.

null_hypothesis

The null hypothesis.

pvalue

The p-value for the test statistic.

regression

The OLS regression results from the ADF model estimated.

stat

The test statistic for a unit root.

trend

The deterministic trend term used in the test.

valid_trends

List of valid trend terms.

y

The data used in the test statistic.