Ng-Perron Test

The Ng-Perron Test of Ng and Perron (2001) is a set of four statistics, \(\text{MZ}_{\alpha}\), \(\text{MZ}_{t}\), MSB and \(\text{MP}_{T}\), that modify the Phillips-Perron statistics and apply them to the GLS-detrended series of Elliott, Rothenberg and Stock (1996). The unit root tests with good power reject far too often when the errors have a large negative moving-average term; Ng and Perron combined GLS detrending with a modified information criterion for the lag length, which keeps the size close to the nominal level in that case while keeping the power.

The formula for the Ng-Perron Test starts from the GLS-detrended series \(y_{d}\): the series minus its constant (and trend), estimated on quasi-differences at the local alternative bar(alpha), with bar(c) = -7 with a constant and -13.5 with a constant and trend:

\[\bar{\alpha} = 1 + \frac{\bar{c}}{T}\] \[y_{\alpha,t} = y_{t} - \bar{\alpha} \cdot y_{t-1}\] \[\hat{\delta} = (Z'_{\alpha} \cdot Z_{\alpha})^{-1} \cdot Z'_{\alpha} \cdot Y_{\alpha}\] \[y_{d,t} = y_{t} - z'_{t} \cdot \hat{\delta}\]

An autoregression of the changes of the detrended series with k lagged changes gives the long-run variance \(s_{\text{AR}}^{2}\), and kappa sums the squared lagged levels:

\[\Delta y_{d,t} = b_{0} \cdot y_{d,t-1} + \sum_{j=1}^{k} b_{j} \cdot \Delta y_{d,t-j} + e_{t}\] \[s_{\text{AR}}^{2} = \frac{\hat{\sigma}_{k}^{2}}{\left(1 - \sum_{j=1}^{k} \hat{b}_{j}\right)^{2}}\] \[\kappa = \frac{\sum_{t=2}^{T} y_{d,t-1}^{2}}{T^{2}}\]

The four statistics combine the last detrended value, kappa and \(s_{\text{AR}}^{2}\) (the first \(\text{MP}_{T}\) with a constant, the second with a trend):

\[\text{MZ}_{\alpha} = \frac{\frac{y_{d,T}^{2}}{T} - s_{\text{AR}}^{2}}{2 \cdot \kappa}\] \[\text{MSB} = \sqrt{\frac{\kappa}{s_{\text{AR}}^{2}}}\] \[\text{MZ}_{t} = \text{MZ}_{\alpha} \cdot \text{MSB}\] \[\text{MP}_{T} = \frac{\bar{c}^{2} \cdot \kappa - \frac{\bar{c} \cdot y_{d,T}^{2}}{T}}{s_{\text{AR}}^{2}}\] \[\text{MP}_{T} = \frac{\bar{c}^{2} \cdot \kappa + \frac{(1 - \bar{c}) \cdot y_{d,T}^{2}}{T}}{s_{\text{AR}}^{2}}\]

The lag length k minimises the modified AIC, with every k up to the maximum \(k_{\text{max}}\) fitted on the same sample:

\[\tau(k) = \frac{\hat{b}_{0}^{2} \cdot \sum y_{d,t-1}^{2}}{\hat{\sigma}_{k}^{2}}\] \[\text{MAIC}(k) = \ln\left(\hat{\sigma}_{k}^{2}\right) + \frac{2 \cdot (\tau(k) + k)}{T - k_{\text{max}}}\]

Where \(y_{t}\) is the level of the series, T the number of observations, \(z_{t}\) the deterministic terms (1, or 1 and t with a trend) and \(Z_{\alpha}\) and \(Y_{\alpha}\) their quasi-differences and those of the series, \(b_{j}\) the coefficients and hat(sigma_k)^2 the residual variance of the autoregression with k lags. All four statistics reject the unit root when they lie below the asymptotic critical values of Ng and Perron (2001), Table 1, and only critical values are published, so there are no p-values. The four usually agree; \(\text{MZ}_{t}\) is the counterpart of the ADF statistic.

A unit root test asks whether a series wanders like a random walk, where every shock moves its level for good, or is stationary and returns to its mean or trend after a shock. The tests share the same null hypothesis, a unit root (a random walk, not mean-reverting), against the alternative that the series is stationary. Testing for it is a standard first step before modelling a price, spread or rate with mean-reverting methods, which assume stationarity, and before regressing one trending series on another, where a unit root in both makes the regression spurious. The tests differ in how they handle autocorrelated errors, structural breaks and the constant and trend, and in their power against a series that reverts only slowly. Not rejecting the unit root does not prove it: on a short sample a slowly reverting series and a random walk are hard to tell apart. The KPSS test swaps the null and the alternative and is the usual complement.

Also known as: Ng-Perron tests, MZa, MZt, MSB, MPT, modified unit root tests.

In the Finance Toolkit this is get_unit_root_test with method="ng_perron", the same function as Unit Root Test.

Example · EURUSD, USDJPY, GBPUSD · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_unit_root_test:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["EURUSD", "USDJPY", "GBPUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.econometrics.get_unit_root_test(method="ng_perron")

Which returns:

Using Your Own Data

get_unit_root_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:

from financetoolkit import Economics, Econometrics

economics = Economics(start_date="2000-01-01")

unemployment = economics.get_unemployment_rate(
    countries=["United States", "Germany"], period="monthly"
)

econometrics = Econometrics(data=unemployment, changes="difference")

econometrics.get_unit_root_test()

References

  • Paper Elliott, G., Rothenberg, T.J. and Stock, J.H. (1996). “Efficient Tests for an Autoregressive Unit Root.” Econometrica, 64(4), 813-836.
  • Paper Ng, S. and Perron, P. (2001). “Lag Length Selection and the Construction of Unit Root Tests with Good Size and Power.” Econometrica, 69(6), 1519-1554.
Share