dfgls#

cultivars.diagnostics.unit_roots.dfgls(endog, *, trend='c', lags=None, max_lags=None, method='maic')[source]#

Elliott-Rothenberg-Stock DF-GLS test of a unit root.

The deterministic terms are removed by generalized least squares under the local alternative \(\bar\alpha = 1 + \bar c / T\), with \(\bar c = -7\) for a constant and \(-13.5\) for a trend: the quasi-differenced series \(y_t - \bar\alpha y_{t-1}\) is regressed on the quasi-differenced deterministic terms, and the detrended series is \(y_t - \hat\beta^\top d_t\). The Dickey-Fuller regression is then run on the detrended series without deterministic terms. The result is close to the point-optimal test and far more powerful than ADF near the null, where the power of the Dickey-Fuller family collapses. The augmentation is chosen on the OLS-detrended series, as Perron and Qu (2007) recommend: on GLS-detrended data the modified AIC over-selects badly whenever the series is far from the null. Even so, on a series close to white noise the modified AIC still selects long augmentations and the statistic loses power; method="aic" or a fixed lags is the remedy there. Critical values are the authors’ asymptotic ones; no response surface exists, so pvalue is None.

Parameters:
  • endog (ArrayLike) – The series, (T,).

  • trend (str) – "c" or "ct".

  • lags (int | None) – Augmentation lags, at least 0, or None to select.

  • max_lags (int | None) – Largest augmentation under selection; default Schwert’s rule.

  • method (str) – Selection rule, as adf(); the modified AIC is the authors’ companion recommendation (Ng & Perron 2001).

Return type:

UnitRootTest

Returns:

The UnitRootTest named "DF-GLS" with pvalue=None and the asymptotic critical values.

Raises:

Note

With pvalue=None, reject() accepts only the tabulated levels 1%, 5%, and 10%. The asymptotic critical values are slightly liberal in short samples; at 100 observations the 5% size is nearer 6%.

See also

  • ng_perron() – the same detrending with the \(M\) statistics, better sized under moving-average errors.

  • adf() – the OLS-detrended original, with a p-value.

References

Elliott, G., Rothenberg, T. J., & Stock, J. H. (1996). Efficient tests for an autoregressive unit root. Econometrica, 64(4), 813-836.

Ng, S., & Perron, P. (2001). Lag length selection and the construction of unit root tests with good size and power. Econometrica, 69(6), 1519-1554.

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.

Example

A near-unit-root AR(1) that ADF rejects only narrowly is rejected comfortably here; the modified AIC’s long augmentation on white noise, and the remedy:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros(300)
>>> for t in range(1, 300):
...     y[t] = 0.9 * y[t - 1] + rng.standard_normal()
>>> test = dfgls(y)
>>> test.pvalue, test.reject(), test.critical_values["5%"]
(None, True, -1.95)
>>> noise = rng.standard_normal(300)
>>> dfgls(noise).lags, dfgls(noise, method="aic").lags
(9, 0)