arch.unitroot.ADF

class arch.unitroot.ADF(y, lags=None, trend='c', max_lags=None, method='AIC', low_memory=None)[source]

Augmented Dickey-Fuller unit root test

Parameters
  • y ({ndarray, Series}) -- The data to test for a unit root

  • lags (int, optional) -- 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 are included.

  • trend ({'nc', 'c', 'ct', 'ctt'}, optional) -- The trend component to include in the ADF test 'nc' - No trend components 'c' - Include a constant (Default) 'ct' - Include a constant and linear time trend 'ctt' - Include a constant and linear and quadratic time trends

  • max_lags (int, optional) -- The maximum number of lags to use when selecting lag length

  • method ({'AIC', 'BIC', 't-stat'}, optional) -- The method to use when selecting the lag length 'AIC' - Select the minimum of the Akaike IC 'BIC' - Select the minimum of the Schwarz/Bayesian IC 't-stat' - Select the minimum of the Schwarz/Bayesian IC

  • low_memory (bool) -- 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, use automatic selection of algorithm.

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 that there 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.

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('{0:0.4f}'.format(adf.stat))
-3.0931
>>> print('{0:0.4f}'.format(adf.pvalue))
0.0271
>>> adf.lags
2
>>> adf.trend='ct'
>>> print('{0:0.4f}'.format(adf.stat))
-3.2111
>>> print('{0:0.4f}'.format(adf.pvalue))
0.0822

References

*

Greene, W. H. 2011. Econometric Analysis. Prentice Hall: Upper Saddle River, New Jersey.

Hamilton, J. D. 1994. Time Series Analysis. Princeton: Princeton University Press.

MacKinnon, J.G. 1994. "Approximate asymptotic distribution functions for unit-root and cointegration bootstrap. Journal of Business and Economic Statistics 12, 167-76.

§

MacKinnon, J.G. 2010. "Critical Values for Cointegration Tests." Queen's University, Dept of Economics, Working Papers. Available at https://ideas.repec.org/p/qed/wpaper/1227.html

Methods

summary()

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

Properties

alternative_hypothesis

The alternative hypothesis

critical_values

Dictionary containing critical values specific to the test, number of observations and included deterministic trend terms.

lags

Sets or gets the number of lags used in the model.

max_lags

Sets or gets 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

Returns the p-value for the test statistic

regression

Returns the OLS regression results from the ADF model estimated

stat

The test statistic for a unit root

trend

Sets or gets the deterministic trend term used in the test.

valid_trends

List of valid trend terms.

y

Returns the data used in the test statistic