arch.unitroot.DFGLS

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

Elliott, Rothenberg and Stock’s ([ers]) GLS detrended Dickey-Fuller.

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: 'c' | 'ct' = 'c'

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

  • ”c” - Include a constant

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

max_lags: int | None = None

The maximum number of lags to use when selecting lag length. When using automatic lag length selection, the lag is selected using OLS detrending rather than GLS detrending ([pq]). 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 ([np])

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 at least 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 observations. This is also a ValueError.

Notes

The null hypothesis of the Dickey-Fuller GLS 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.

DFGLS differs from the ADF test in that an initial GLS detrending step is used before a trend-less ADF regression is run.

Critical values and p-values when trend is “c” are identical to the ADF. When trend is set to “ct”, they are from novel simulations.

References

[ers]

Elliott, G. R., T. J. Rothenberg, and J. H. Stock. 1996. Efficient tests for an autoregressive unit root. Econometrica 64: 813-836

[pq]

Perron, P., & Qu, Z. (2007). A simple modification to improve the finite sample properties of Ng and Perron’s unit root tests. Economics letters, 94(1), 12-19.

[np]

Ng, S., and P. Perron. 2001. “Lag Length Selection and the Construction of Unit Root Tests with Good Size and Power.” Econometrica 69, 1519-1554.

Examples

>>> from arch.unitroot import DFGLS
>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.macrodata.load().data
>>> inflation = np.diff(np.log(data["cpi"]))
>>> dfgls = DFGLS(inflation)
>>> print(f"{dfgls.stat:0.4f}")
-2.7611
>>> print(f"{dfgls.pvalue:0.4f}")
0.0059
>>> dfgls.lags
2
>>> dfgls = DFGLS(inflation, trend = "ct")
>>> print(f"{dfgls.stat:0.4f}")
-2.9036
>>> print(f"{dfgls.pvalue:0.4f}")
0.0447

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.