DPredict · Guide test 198
Phillips–Perron test
Tests a unit root with nonparametric adjustments for serial correlation and heteroskedasticity.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Unit-root and stationarity tests — Does the series wander like a random walk (a unit root), or return to a mean or trend — and how many differences make it stationary?
In Unit-root and stationarity tests, choose Test = Phillips–Perron.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Phillips–Perron test
Each error carries φ × the previous one; 1 is a random walk.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how Z(τ) varies across samples when H₀ is true, Dickey–Fuller τ with a constant (MacKinnon (1994) response surface (asymptotic)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .063).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- residual variance of y_t ~ y_{t−1}
- long-run (Newey–West) variance with ℓ lags
- t ratio of ρ̂ − 1
The verdict
Z(τ) = −2.76, p = .063
p > α = .050: compatible with H₀
Same asymptotic null as the ADF τ. It handles heteroskedasticity well but can over-reject with strong negative MA errors.
- Statistic
- −2.765
- p-value
- 0.0635
Phillips–Perron test on 60 (x, y) pairs: Z(τ) = −2.76, p = .063. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: a unit root; H1: stationarity under the specified deterministic terms.
Assumptions
A regularly ordered time series with a specified deterministic component (none, intercept, or trend); innovations satisfy the selected unit-root test’s weak-dependence/moment conditions. Lag/bandwidth choices and breaks affect calibration.
Formula
Parameters and notation
Fit yt on yt−1 and deterministic terms. γ̂0 is residual variance; ω̂² is HAC long-run variance; ỹt−1 is the lagged level residualized on deterministic terms. tρ tests ρ=1.
Structure of the method
Fit a basic autoregression with the chosen deterministic terms, estimate short-run residual variance and a heteroskedasticity/autocorrelation-consistent long-run variance, and correct a coefficient or t-shaped statistic. The nonparametric correction replaces explicit ADF-style difference-lag augmentation but still needs a suitable weak-dependence approximation.
Estimated and nuisance parameters
Autoregressive and deterministic coefficients, residual variance, and long-run covariance are estimated. The distinction between Z-alpha and Z-tau changes the statistic; a generic Z label does not imply a standard normal reference distribution.
Settings and design choices
Choose deterministic model, statistic variant, HAC kernel and bandwidth or a documented short/long rule, sample handling, and any automatic bandwidth algorithm. Data-selected bandwidths should be reported and reproduced during any calibration that relies on them.
Fitting and adaptation
Estimate the full regression and variance correction from the same defined series. For simulation, generate under the unit-root null and repeat both regression and long-run variance estimation. Do not reuse ordinary PP critical values for residuals from a fitted cointegrating regression; generated residuals require a cointegration-specific test.
Sensitivity and robustness
Strong negative moving-average errors, inaccurate long-run variance estimates, small samples, breaks, and long memory can impair finite-sample performance. Bandwidth changes can materially change conclusions. Compare plausible prespecified settings and residual diagnostics without reporting only the desired result. Rejection concerns a unit root under the maintained deterministic/error model, not complete stationarity in every practical sense.
How to use and calibrate
Use Phillips–Perron unit-root critical values with the selected deterministic model. Zα variants use a coefficient-bias correction instead.
Example application
Test a unit root while allowing weak residual serial correlation through HAC correction.
Interpretation and pitfalls
Watch out
Bandwidth/kernel choices matter; this is not a standard normal statistic despite the Z label.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Read the unit-root/stationarity statistic and its nonstandard critical values, not the auxiliary regression coefficient’s ordinary t p-value. Deterministic terms, bandwidth and lag selection must match before comparing implementations.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: urca
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.pp(x,type="Z-tau",model="constant",lags="short")))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs urca
set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.pp(x,type="Z-tau",model="constant",lags="short")))
Output
##################################
# Phillips-Perron Unit Root Test #
##################################
Test regression with intercept
Call:
lm(formula = y ~ y.l1)
Residuals:
Min 1Q Median 3Q Max
-2.58708 -0.70095 -0.03076 0.70701 2.58412
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.27797 0.15844 -1.754 0.0813 .
y.l1 0.95694 0.02198 43.538 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9974 on 157 degrees of freedom
Multiple R-squared: 0.9235, Adjusted R-squared: 0.923
F-statistic: 1896 on 1 and 157 DF, p-value: < 2.2e-16
Value of test-statistic, type: Z-tau is: -2.1171
aux. Z statistics
Z-tau-mu -1.8864
Critical values for Z statistics:
1pct 5pct 10pct
critical values -3.472387 -2.879651 -2.576321Sources
- urca — urca · ur.ppAuthor documentation/source reviewed: urca 1.3-4.search.r-project.org
- ur.ppsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 198, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT198.