ADescribe · Guide test 092
Bartlett homogeneity of variance test
Tests equality of several variances; strongly affected by departures from normality.
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 = Bartlett's test.
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 · Bartlett homogeneity of variance 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 K² 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 = .080).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- pooled variance
- group variances
The verdict
K²(2) = 5.06, p = .080
p > α = .050: compatible with H₀
Most powerful for normal data, badly misleading for non-normal data: a significant Bartlett test often just means heavy tails.
- Statistic
- 5.062
- p-value
- 0.0796
Bartlett homogeneity of variance test on Group 1: n = 15; Group 2: n = 15; Group 3: n = 15: K²(2) = 5.06, p = .080. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: k normal populations have equal variances.
Assumptions
Independent normal samples; sufficient observations in each group.
Formula
Parameters and notation
sp²=Σ(nj−1)sj²/(N−k), N=Σnj.
Structure of the method
Pool group variances with their residual degrees-of-freedom weights, compare the log pooled variance with the weighted logs of individual variances, and apply Bartlett’s finite-sample correction. The resulting statistic uses an approximate chi-square reference for equality across normal populations.
Estimated and nuisance parameters
Estimate a separate mean and variance per group and a common pooled variance under the null. Group sizes enter both the likelihood contrast and correction. Every included group needs enough observations for a variance; zero within-group variability can make logarithms degenerate.
Settings and design choices
Prespecify the grouping, missing-value exclusions, and significance level. Unequal group sizes are allowed by the formula but can interact with nonnormality. Do not confuse this procedure with a Bartlett test on a correlation matrix or choose it only after a normality pretest passes.
Fitting and adaptation
Recompute all group means, variances, and pooled quantities for a new dataset. A parametric calibration check simulates independent Gaussian groups at the observed sizes under a common variance and repeats the full calculation. Classical refitting replaces neural fine-tuning.
Sensitivity and robustness
Shape departures can trigger rejection even when population variances are equal. Outliers and heavy tails disproportionately affect sample variances and logarithms. A nonsignificant result does not establish equivalence; report group variability estimates and intervals, and consider a robust dispersion analysis suited to the scientific target.
How to use and calibrate
Use χ²k−1 approximately; a large statistic suggests variance heterogeneity.
Example application
Check variance homogeneity in a scientifically defensible normal model.
Interpretation and pitfalls
Watch out
Nonnormality can cause rejection even with equal variances. This is not Bartlett’s correlation matrix sphericity 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
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.bartlett(*groups))
Output
BartlettResult(statistic=np.float64(4.031447844288386), pvalue=np.float64(0.13322392469941502))
Validated — Executed successfully in the validation environment · needs Base/standard library
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(bartlett.test(value~group,d))
Output
Bartlett test of homogeneity of variances data: value by group Bartlett's K-squared = 0.48519, df = 2, p-value = 0.7846
Sources
- R stats — R stats · bartlett.teststat.ethz.ch
- bartlett.teststat.ethz.ch
- 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 092, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT092.