Skip to content

DPredict · Guide test 231

Buishand range test

Tests a change in the mean using the range of cumulative deviations.

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

Do it in CodeSplash

In the app, set it up in Analyze with this method:

In Change-point tests (level shifts), choose Test = Buishand range.

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 · Buishand range test

50
0.000
0.00

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

1.0
0.050

Your data

Simulated with a known ρ

If H₀ were true

R/√n = 1.57
  1. The reference: how R/√n varies across samples when H₀ is true, R/√n of n = 50 normal values (Monte Carlo null: 1,999 samples simulated under H₀ (seed 20261107)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .044).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Sk=∑i≤k(yi−yˉ),Rn=max⁡kSk−min⁡kSksnS_k = \sum_{i \le k}(y_i - \bar y),\qquad \dfrac{R}{\sqrt n} = \dfrac{\max_k S_k - \min_k S_k}{s\sqrt n}

With your numbers

R/n=1.57,largest ∣Sk∣ at k=24R/\sqrt n = 1.57,\qquad \text{largest } |S_k| \text{ at } k = 24
SkS_k
adjusted partial sums
ss
sample SD

The verdict

R/√n = 1.57, p = .044

p ≤ α = .050: reject H₀

Assumes normal, independent data under H0; the reference is simulated from normal series of the same length.

Statistic
1.566
p-value
0.0440
Buishand range test on 50 (x, y) pairs: R/√n = 1.57, p = .044. The p-value is below α = .050, so the data are hard to reconcile with H0.

Buishand range test on 50 (x, y) pairs: R/√n = 1.57, p = .044. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: constant mean throughout the series; H1: a level shift.

Assumptions

Independent normal observations with common variance under the standard null; complete data and no unmodeled trend.

Formula

R=max⁡0≤k≤nSk−min⁡0≤k≤nSkDxnR=\frac{\max_{0\le k\le n}S_k-\min_{0\le k\le n}S_k}{D_x\sqrt n}

Parameters and notation

Sk=Σi≤k(xi−x̄),S0=0; Dx²=n⁻¹Σ(xi−x̄)². The range statistic is sometimes reported without √n; tables must match.

Structure of the method

Center the series by its full-sample mean, accumulate deviations, take the range between the largest and smallest cumulative values, and normalize with the selected standard deviation and sample-size convention. This produces one global homogeneity statistic, not a fitted segmentation model or a separate test for every cumulative point.

Estimated and nuisance parameters

Estimate the global mean and scale under the constant-mean null; cumulative extrema are observed statistics rather than free parameters. If a reference station or covariate adjustment is introduced, its fitted parameters belong to an upstream model and can change the null variance and simulation requirements.

Settings and design choices

Choose raw versus normalized reporting convention, full record or independently selected interval, and Monte Carlo replicate count/seed. The cited br.test estimates its p value by normal-null simulation. Normalizing by sqrt(n) is harmless only when the statistic and critical values use the same convention.

Fitting and adaptation

No neural fine-tuning applies. Fit the constant-mean null and simulate the complete centering/scaling/range calculation at the observed sample size, or use a documented matching table. If adapting to serially correlated data, replace the iid normal null with a justified method rather than interpreting more simulation replicates as a dependence correction.

Sensitivity and robustness

Inspect autocorrelation, skew/heavy tails, multiple shifts, gradual drift, and endpoint sensitivity. The global sample standard deviation must use squared deviations. A significant range identifies incompatibility with homogeneity but does not automatically estimate a precise physical break date or establish which external cause produced it.

How to use and calibrate

Use Buishand-specific critical values or normal-null Monte Carlo simulation at the observed n.

Example application

Check a measurement record for a mean discontinuity.

Interpretation and pitfalls

Watch out

Serial dependence and gradual trends can mimic shifts. The standard deviation requires squared deviations; some rendered manuals omit that square.

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.

Python · invokes R

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::br.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()
R

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::br.test(x))

Sources

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 231, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT231.