Skip to content

DPredict · Guide test 198

Phillips–Perron test

Tests a unit root with nonparametric adjustments for serial correlation and heteroskedasticity.

Runs in CodeSplashPython (calls R) example not runR example validated

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

60
0.000
0.80

Each error carries φ × the previous one; 1 is a random walk.

0.0
0.050

Your data

Simulated with a known ρ

If H₀ were true

Z(τ) = −2.76
  1. The reference: how Z(τ) varies across samples when H₀ is true, Dickey–Fuller τ with a constant (MacKinnon (1994) response surface (asymptotic)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .063).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Z(τ)=σ^2λ^2  tρ^−λ^2−σ^22λ^⋅1n−2∑(yt−yˉ)2Z(\tau) = \sqrt{\tfrac{\hat\sigma^2}{\hat\lambda^2}}\;t_{\hat\rho} - \dfrac{\hat\lambda^2 - \hat\sigma^2}{2\hat\lambda}\cdot\dfrac{1}{\sqrt{n^{-2}\sum(y_t - \bar y)^2}}

With your numbers

tρ^=(−2.69),Z(τ)=(−2.76),ℓ=3t_{\hat\rho} = (-2.69),\qquad Z(\tau) = (-2.76),\qquad \ell = 3
σ^2\hat\sigma^2
residual variance of y_t ~ y_{t−1}
λ^2\hat\lambda^2
long-run (Newey–West) variance with ℓ lags
tρ^t_{\hat\rho}
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 H0.

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

Zτ=γ^0/ω^2 tρ−ω^2−γ^02ω^2DD=T−2∑ty~t−12\begin{gathered}Z_\tau=\sqrt{\widehat\gamma_0/\widehat\omega^2}\,t_\rho-\frac{\widehat\omega^2-\widehat\gamma_0}{2\sqrt{\widehat\omega^2D}}\\[5pt] D=T^{-2}\sum_t\widetilde y_{t-1}^2\end{gathered}

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.

Python · invokes R

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()
R

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.576321

Sources

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.