DPredict · Guide test 234
Lanzante change point test
Uses ranks to assess a shift in central tendency within a series.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Change-point tests (level shifts) — Did the level of the series jump at some point — and if so, when, and by how much?
In Change-point tests (level shifts), choose Test = Lanzante (ranks + Wilcoxon).
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 · Lanzante change-point 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 K varies across samples when H₀ is true, 4,999 random orderings of the series (permutation null of max|Uₜ|, which pays for choosing the split).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .033).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- ranks of the series
- the split where the rank-sum process peaks; Lanzante compares the halves with a Wilcoxon test
- compared with random orderings of the series, which pays for choosing the split
The verdict
K = 197, p = .033
p ≤ α = .050: reject H₀
Robust to outliers and skew. The Wilcoxon p at the chosen split is too small because the split was picked to look different; the permutation p accounts for that.
- Statistic
- 197.000
- p-value
- 0.0332
Lanzante change-point test on 40 (x, y) pairs: K = 197, p = .033. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: no location shift; H1: a shift at a data-selected point.
Assumptions
Independent observations under a single-shift model; robust rank comparisons with suitable shape/symmetry assumptions for the selected second-stage test.
Formula
Parameters and notation
Split at k̂, then apply a Wilcoxon–Mann–Whitney or robust rank-order comparison to the segments; this is the documented Lanzante workflow.
Structure of the method
Use a rank-based cumulative criterion to select a split, then perform the specified two-sample rank/location comparison on the selected segments. The first-stage search and second-stage comparison are one adaptive algorithm; calibrating only the final comparison as though the split were fixed omits selection.
Estimated and nuisance parameters
Estimate ranks, the maximizing split, and the segment comparison statistic; optional segment medians summarize magnitude. No neural parameters or universal change-point probability is fitted. A printed two-sample p value refers to its own conditional setup and is not automatically a valid global scan p value.
Settings and design choices
Choose second-stage Wilcoxon versus robust rank-order procedure, eligible split sizes, one/two-sided interpretation, and a full-procedure calibration plan. If ties or small segments violate the chosen comparison’s assumptions, use a documented alternative. A search constraint changes the null distribution and must be retained in resamples.
Fitting and adaptation
For valid global inference under exchangeability, permute the original values, rerun split selection, rerun the segment test, and compare a prespecified final score. For serial dependence, choose a different justified null/resampling design. This is recalibration of a selection algorithm, not ordinary fine-tuning or a new model architecture.
Sensitivity and robustness
Inspect ties, distribution-shape differences, multiple changes, trend, and unstable split location. Robustness to outlying values does not remove time dependence or post-selection bias. Preserve the baseline caution that the cited package’s reported second-stage p value is not automatically search-adjusted; it should not be presented as globally exact.
How to use and calibrate
For valid global significance, calibrate the entire search-plus-comparison algorithm by null permutations or a justified search-adjusted method.
Example application
Find a resistant candidate discontinuity in a climate record.
Interpretation and pitfalls
Watch out
The cited trend function reports the post-selection two-sample p value. That naive p value does not account for choosing the split; treat it cautiously rather than as a globally calibrated test.
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
Keep observations in temporal order. Serial correlation and seasonality can invalidate the default independent-error calibration; do not treat the selected change point as known in advance.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: trend
# 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<-seq_len(60)*.02+rnorm(60)
print(trend::lanzante.test(x))
"""
# 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()
Not run — Syntax checked; runtime not verified in the final environment · needs trend
set.seed(2026)
x<-seq_len(60)*.02+rnorm(60)
print(trend::lanzante.test(x))
Sources
- trend — trend · lanzante.testAuthor documentation/source reviewed: trend 1.1.10.search.r-project.org
- lanzante.testsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final 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 234, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT234.