DPredict · Guide test 201
Zivot–Andrews test
Tests a unit root allowing a single endogenously selected structural break under the alternative.
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 = Zivot–Andrews (one break).
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 · Zivot–Andrews test
Each error carries φ × the previous one; 1 is a random walk.
Extra lags of Δy that soak up short-run dynamics.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how t* varies across samples when H₀ is true, min t over breaks, random walks of length 60 (Monte Carlo null: 999 samples simulated under H₀ (seed 20261107)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .074).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- 1 after the candidate break date
- the most negative t over all break dates
The verdict
t* = −4.73, p = .074
p > α = .050: compatible with H₀
Searching over break dates moves the null left; the simulated reference accounts for the search. The break date is an estimate, not a finding.
- Statistic
- −4.733
- p-value
- 0.0740
Zivot–Andrews test on 60 (x, y) pairs: t* = −4.73, p = .074. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: unit root without the modeled stationary break; H1: trend stationarity with one unknown break.
Assumptions
A single-break specification and suitable innovations; trim endpoint candidates and select lags under the stated algorithm.
Formula
Parameters and notation
DU=I(t>τ); DT=(t−τ)I(t>τ); choose intercept, trend or both break terms. T is the trimmed candidate set.
Structure of the method
Construct break dummies for each permitted candidate date, estimate the corresponding augmented unit-root regression, and retain the most negative lagged-level t statistic. Searching the break location is part of the statistic, so a fixed-break ADF reference does not apply. Break-intercept, break-trend, and combined models answer different alternatives.
Estimated and nuisance parameters
Deterministic and short-run coefficients are fitted for every candidate; the minimizing break date is selected from the data. The selected date is not an externally known event and does not automatically carry an ordinary confidence interval or causal interpretation.
Settings and design choices
Prespecify break type, endpoint trimming, candidate date grid, augmentation lag method, and sample period. Implementations can use different lag-selection shortcuts or candidate sets; match those settings before expecting equal Python/R results. A one-break search is not a multiple-break estimator.
Fitting and adaptation
Repeat the entire break search and any lag selection during a simulation intended to reproduce the null statistic. If an event date was known independently, a fixed-break formulation may be more appropriate. Changing the sample after inspecting the selected date introduces another selection layer requiring disclosure.
Sensitivity and robustness
Endpoint breaks, multiple changes, outliers, evolving variance, and persistent short-run dynamics can impair power or size. A selected date may reflect model approximation rather than a genuine structural event. The standard null/alternative treatment of breaks is specific to ZA; do not generalize its result to every unit-root model with arbitrary breaks.
How to use and calibrate
Use Zivot–Andrews critical values for the selected break model, accounting for the search.
Example application
Distinguish a persistent series with one break from a unit-root process.
Interpretation and pitfalls
Watch out
A one-break model cannot represent every structural change; an ordinary fixed-break ADF p value is invalid after searching.
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.
Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x=np.cumsum(rng.normal(size=160))
from statsmodels.tsa.stattools import zivot_andrews
print(zivot_andrews(x,maxlag=4,regression="c",autolag=None))
Output
(np.float64(-3.851067632998106), np.float64(0.44589276666795513), {'1%': np.float64(-5.27644), '5%': np.float64(-4.81067), '10%': np.float64(-4.56618)}, 4, np.int64(42))Validated — Executed successfully in the validation environment · needs urca
set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.za(x,model="intercept",lag=4)))
Output
################################
# Zivot-Andrews Unit Root Test #
################################
Call:
lm(formula = testmat)
Residuals:
Min 1Q Median 3Q Max
-2.65468 -0.64818 -0.00984 0.69689 2.60060
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.444206 0.210083 -2.114 0.03617 *
y.l1 0.891445 0.030707 29.030 < 2e-16 ***
trend -0.005530 0.003043 -1.817 0.07124 .
y.dl1 -0.068569 0.079567 -0.862 0.39021
y.dl2 0.177363 0.079748 2.224 0.02767 *
y.dl3 0.127542 0.081188 1.571 0.11834
y.dl4 0.122930 0.081448 1.509 0.13337
du 1.022090 0.354092 2.887 0.00448 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9679 on 147 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.928, Adjusted R-squared: 0.9246
F-statistic: 270.7 on 7 and 147 DF, p-value: < 2.2e-16
Teststatistic: -3.5352
Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
Potential break point at position: 128Sources
- urca — urca · ur.zaAuthor documentation/source reviewed: urca 1.3-4.search.r-project.org
- ur.zasearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 201, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT201.