ng_perron#

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

Ng-Perron \(M\) tests of a unit root on a GLS-detrended series.

With \(\tilde y_t\) the GLS-detrended series and \(s^2_{AR}\) the autoregressive spectral density estimate at frequency zero, the four statistics are

\[MZ_\alpha = \frac{T^{-1} \tilde y_T^2 - s^2_{AR}} {2 T^{-2} \sum_{t} \tilde y_{t-1}^2}, \qquad MSB = \Bigl(\frac{T^{-2} \sum_t \tilde y_{t-1}^2}{s^2_{AR}}\Bigr)^{1/2}, \qquad MZ_t = MZ_\alpha \times MSB,\]

and \(MP_T\) the modified point-optimal statistic. \(MZ_t\) is the primary record; the other three travel as companions. The autoregressive spectral estimate replaces the kernel estimate the Phillips-Perron test uses, and with the modified AIC choosing the augmentation the tests keep their size under a large negative moving-average root, where ADF and Phillips-Perron over-reject badly. The augmentation is chosen on the OLS-detrended series (Perron & Qu 2007) and the statistics computed on the GLS-detrended one. Critical values are asymptotic; pvalue is None.

The modified AIC is built for the neighbourhood of the null. Far from it, on a series close to white noise, its penalty is dominated by the level coefficient and it selects long augmentations that cost the \(M\) statistics most of their power; method="aic" or a fixed lags is the remedy when the series is plainly stationary, at the price of size under a negative moving-average root.

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

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

  • lags (int | None) – Augmentation for the spectral estimate, 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(); default the modified AIC.

Return type:

UnitRootTest

Returns:

The \(MZ_t\) UnitRootTest named "Ng-Perron MZ_t" with \(MZ_\alpha\), \(MSB\), and \(MP_T\) as companions; every record has pvalue=None and its own asymptotic critical values, all four rejecting in the lower tail.

Raises:

Note

\(MSB\) and \(MP_T\) are positive statistics that reject when small, which the lower-tail flag carries; their critical values are read in the same direction as the negative ones.

See also

  • dfgls() – the \(t\) statistic on the same detrended series.

  • phillips_perron() – the kernel-corrected original the \(M\) tests improve on.

References

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., & Ng, S. (1996). Useful modifications to some unit root tests with dependent errors and their local asymptotic properties. Review of Economic Studies, 63(3), 435-463.

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

The four statistics on a stationary AR(1), all rejecting:

>>> 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 = ng_perron(y)
>>> test.name, test.reject(), test.lags
('Ng-Perron MZ_t', True, 0)
>>> [(c.name, c.reject()) for c in test.companions]
[('MZ_a', True), ('MSB', True), ('MP_T', True)]