arch.unitroot.PhillipsPerron

class arch.unitroot.PhillipsPerron(y: ndarray | DataFrame | Series, lags: int | None = None, trend: 'n' | 'c' | 'ct' = 'c', test_type: 'tau' | 'rho' = 'tau')[source]

Phillips-Perron unit root test.

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 Newey-West estimator of the long-run covariance. If omitted or None, the lag length is set automatically to 12 * (nobs/100) ** (1/4), rounded up.

trend: 'n' | 'c' | 'ct' = 'c'

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

  • ”n” - No trend components

  • ”c” - Include a constant

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

test_type: 'tau' | 'rho' = 'tau'

The test to use when computing the test statistic. Not case sensitive. “tau” is based on the t-stat and “rho” uses a test based on nobs times the re-centered regression coefficient.

Raises:
  • TypeError – If y cannot be converted to numbers, lags is not an integer, or trend or test_type is not a str.

  • ValueError – If y is not 1-d or contains NaN or inf, lags is negative, or trend or test_type is not one of the options.

  • InfeasibleTestException – If y has too few observations for trend, or lags (the default number of lags if it is None) is larger than the number of observations in y minus 1. This is also a ValueError.

Notes

The null hypothesis of the Phillips-Perron (PP) test 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.

Unlike the ADF test, the regression estimated includes only one lag of the dependent variable, in addition to trend terms. Any serial correlation in the regression errors is accounted for using a long-run variance estimator (currently Newey-West).

See Philips and Perron for details [3]. See Hamilton [1] for more on PP tests. Newey and West contains information about long-run variance estimation [2]. The p-values are obtained through regression surface approximation using the methodology of MacKinnon [4] and [5], only using many more simulations.

If the p-value is close to significant, then the critical values should be used to judge whether to reject the null.

References

Examples

>>> from arch.unitroot import PhillipsPerron
>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.macrodata.load().data
>>> inflation = np.diff(np.log(data["cpi"]))
>>> pp = PhillipsPerron(inflation)
>>> print(f"{pp.stat:0.4f}")
-8.1356
>>> print(f"{pp.pvalue:0.4f}")
0.0000
>>> pp.lags
15
>>> pp = PhillipsPerron(inflation, trend="ct")
>>> print(f"{pp.stat:0.4f}")
-8.2022
>>> print(f"{pp.pvalue:0.4f}")
0.0000
>>> pp = PhillipsPerron(inflation, trend="ct", test_type="rho")
>>> print(f"{pp.stat:0.4f}")
-120.3271
>>> print(f"{pp.pvalue:0.4f}")
0.0000

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.

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 for the specification used in the test.

stat

The test statistic for a unit root.

test_type

The test type returned by stat.

trend

The deterministic trend term used in the test.

valid_trends

List of valid trend terms.

y

The data used in the test statistic.