ADescribe · Guide test 093
Levene test
Tests variance equality using group deviations from their means.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Equal spread tests — Do two or more groups have the same spread?
In Equal spread tests, choose Test = Levene's original (mean-centered).
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 · Levene test
Group i has true mean (i − 1) × spread.
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how W 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 = .259).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- absolute deviation from the group mean
The verdict
F(2, 42) = 1.40, p = .259
p > α = .050: compatible with H₀
A one-way ANOVA on absolute deviations. The mean-centered version is the original; the median-centered version (Brown–Forsythe) is more robust.
- Statistic
- 1.397
- p-value
- 0.2586
Levene test on Group 1: n = 15; Group 2: n = 15; Group 3: n = 15: F(2, 42) = 1.40, p = .259. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: groups have equal dispersion as represented by mean absolute centered deviations.
Assumptions
Independent groups; finite absolute deviations. Comparable shapes support interpretation as equal scale/variance. Exact normal ANOVA theory does not generally apply to transformed deviations.
Formula
Parameters and notation
cj is the group mean; k groups,N observations. This is ANOVA on absolute centered deviations.
Structure of the method
Estimate each group mean, convert observations into absolute deviations from that mean, and run a one-way ANOVA contrast on the transformed deviations. The familiar F ratio is computationally an ANOVA statistic, but its usual reference is approximate because centers were estimated from the same data.
Estimated and nuisance parameters
Estimate group means, transformed group means, and within-group variation of absolute deviations. The inferential target is dispersion represented by expected absolute centered deviation; identifying it with variance equality needs an appropriate common-shape model rather than arbitrary distributions with equal variances.
Settings and design choices
Explicitly set center=mean because some software defaults to median centering. Choose group definitions and missing-value rules in advance. If a trimmed variant is wanted, state the trimming fraction and call it a different centering variant rather than silently changing the Levene specification.
Fitting and adaptation
Re-estimate group centers and reconstruct deviations whenever data change. A resampling scheme must reproduce the chosen centering step and be justified for its null; ordinary label permutation requires exchangeability, which is stronger than equal variances with different means. No neural fine-tuning applies.
Sensitivity and robustness
Means remain sensitive to outliers, and small groups produce strongly dependent transformed deviations. Unequal shapes can change expected absolute deviations despite equal variances. Report group sample sizes and dispersion estimates, and avoid claiming that nonsignificance proves a common error variance for every later model.
How to use and calibrate
Use an approximate Fk−1,N−k reference or a justified resampling scheme.
Example application
Compare dispersion across treatment groups.
Interpretation and pitfalls
Watch out
Center choice matters. Brown–Forsythe here is the median-centered variance test, distinct from the means test in entry 15.
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
Variance/scale homogeneity, not a test of equal means. Center choice distinguishes Levene from its median-centered Brown–Forsythe version.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
groups = [rng.normal(m,1,20) for m in (0,.4,.8)]
print(stats.levene(*groups,center="mean"))
Output
LeveneResult(statistic=np.float64(3.193284098252484), pvalue=np.float64(0.048474357978205894))
Validated — Executed successfully in the validation environment · needs car
set.seed(2026)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(car::leveneTest(value~group,d,center=mean))
Output
Levene's Test for Homogeneity of Variance (center = mean)
Df F value Pr(>F)
group 2 0.0203 0.9799
57Sources
- SciPy — SciPy · levenedocs.scipy.org
- scipy.stats.levenedocs.scipy.org
- leveneTestsearch.r-project.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 093, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT093.