ADescribe · Guide test 125
Lepage location and scale test
Combines rank information to detect differences in location, scale, or both between two groups.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Compare distributions (two or more groups) — Do the groups come from the same distribution — anywhere, not only in their centers?
In Compare distributions (two or more groups), choose Test = Lepage (location and scale).
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 · Lepage location–scale test
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how L varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .021).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- standardized Wilcoxon rank sum (location)
- standardized Ansari–Bradley statistic (scale)
The verdict
L(2) = 7.74, p = .021
p ≤ α = .050: reject H₀
A joint test: reject when the groups differ in center, spread or both. Look at the two parts to see which.
- Statistic
- 7.738
- p-value
- 0.0209
Lepage location–scale test on Group 1: n = 20; Group 2: n = 20: L(2) = 7.74, p = .021. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: two distributions are identical; alternatives include location and scale shifts.
Assumptions
Independent continuous samples; appropriate rank tie corrections if necessary.
Formula
Parameters and notation
ZW is standardized Wilcoxon rank sum; ZA is standardized Ansari–Bradley scale score. Under the continuous common null their asymptotic covariance is zero.
Structure of the method
Compute a standardized Wilcoxon location rank sum and an Ansari–Bradley scale-score sum, then add their squares. Under the continuous common null the components are asymptotically uncorrelated; joint permutation calibration avoids treating their finite-sample behavior as automatically independent.
Estimated and nuisance parameters
Pooled ranks and null means/variances of the score sums are calculated from group sizes or the conditional score population. No population location or scale model needs numerical maximum-likelihood fitting.
Settings and design choices
Specify tie handling, score standardization, exact versus Monte Carlo calibration and significance level. The location-plus-scale construction is fixed; choosing one component only after seeing results changes the inference.
Fitting and adaptation
Permute group membership while preserving sample sizes and recompute both standardized components together. For new data repeat ranking and calibration, rather than transferring a fitted distribution. If a global rejection leads to separate location/scale claims, use a prespecified simultaneous interpretation or adjusted follow-ups. A conventional chi-square-two reference is asymptotic.
Sensitivity and robustness
Ties can alter component covariance and require a documented convention. Different distribution shapes may complicate a clean location/scale interpretation. Small samples and unequal group sizes reduce approximation quality; clustered or paired observations are not valid for unrestricted label permutations.
How to use and calibrate
Use χ²2 asymptotically or joint label permutations. Large L rejects.
Example application
Detect a treatment effect that may change location, dispersion, or both.
Interpretation and pitfalls
Watch out
A rejection does not identify which component changed; inspect both with appropriate simultaneous interpretation.
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
Direct Lepage statistic combining standardized Wilcoxon location and Ansari–Bradley scale components, with label-permutation calibration. Continuous inputs avoid complications in defining scale scores at ties.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: base R
# 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<-rnorm(20);y<-rnorm(25,.3,1.2)
lepage<-function(a,b) {n<-length(a);m<-length(b);N<-n+m;r<-rank(c(a,b));s<-pmin(r,N+1-r);W<-sum(r[seq_len(n)]);A<-sum(s[seq_len(n)]);zw<-(W-n*mean(r))/sqrt(n*m*var(r)/N);za<-(A-n*mean(s))/sqrt(n*m*var(s)/N);zw^2+za^2}
T<-lepage(x,y);pool<-c(x,y);n<-length(x);set.seed(2026);B<-999
null<-replicate(B,{z<-sample(pool);lepage(z[seq_len(n)],z[-seq_len(n)])})
print(c(statistic=T,p=(1+sum(null>=T))/(B+1)))
"""
# 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 Base/standard library
set.seed(2026)
x<-rnorm(20);y<-rnorm(25,.3,1.2)
lepage<-function(a,b) {n<-length(a);m<-length(b);N<-n+m;r<-rank(c(a,b));s<-pmin(r,N+1-r);W<-sum(r[seq_len(n)]);A<-sum(s[seq_len(n)]);zw<-(W-n*mean(r))/sqrt(n*m*var(r)/N);za<-(A-n*mean(s))/sqrt(n*m*var(s)/N);zw^2+za^2}
T<-lepage(x,y);pool<-c(x,y);n<-length(x);set.seed(2026);B<-999
null<-replicate(B,{z<-sample(pool);lepage(z[seq_len(n)],z[-seq_len(n)])})
print(c(statistic=T,p=(1+sum(null>=T))/(B+1)))
Output
statistic p 6.309133 0.042000
Sources
- NSM3 — NSM3 · pLepageAuthor documentation/source reviewed: NSM3 1.20.search.r-project.org
- pLepagesearch.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 125, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT125.