Levene’s Test of Variances
Introduction
Levene’s test checks whether variances are equal across groups. It is used before or alongside ANOVA to verify the homogeneity-of-variance assumption. Compared to Bartlett’s test, it is robust to non-normality.
Prerequisites
One-way ANOVA, variance.
Theory
For \(k\) groups, replace each observation by its absolute deviation from the group mean (Levene original) or median (Brown-Forsythe / median-based Levene), then run a one-way ANOVA on the transformed values:
\[W = \frac{(N - k) \sum_i n_i (\bar{Z}_i - \bar{Z})^2}{(k - 1) \sum_i \sum_j (Z_{ij} - \bar{Z}_i)^2},\]
where \(Z_{ij}\) is the absolute deviation. Under \(H_0\) of equal variances, \(W \sim F_{k-1, N-k}\).
The median-based Levene (Brown-Forsythe) is robust to non-normality and recommended as the default.
Assumptions
- Independent observations.
- Appropriate deviation centre (median for non-normal data).
No normality assumption.
R Implementation
library(car)
set.seed(2026)
df <- data.frame(
group = factor(rep(c("A", "B", "C"), each = 40)),
y = c(rnorm(40, 50, 5),
rnorm(40, 55, 12),
rnorm(40, 52, 5))
)
# Levene's test (median-based, default in car)
leveneTest(y ~ group, data = df, center = median)
# Mean-based (original)
leveneTest(y ~ group, data = df, center = mean)
# Bartlett's test (for comparison; assumes normality)
bartlett.test(y ~ group, data = df)Output & Results
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 2 16.98 3.1e-07
117
Bartlett test of homogeneity of variances
Bartlett's K-squared = 35.2, df = 2, p-value = 2.3e-08
Strong evidence of unequal variances. For ANOVA, switch to Welch’s F-test.
Interpretation
“Levene’s test indicated significant heterogeneity of variance across groups (F(2, 117) = 16.98, p < 0.001); Welch’s ANOVA was used for the mean comparison.”
Practical Tips
- Use median-based Levene by default; it is robust to non-normality.
- A routine pre-test is discouraged: conditionally choosing between Student and Welch ANOVA inflates Type I error. Just default to Welch.
- With very small \(n_i\), Levene has low power; violations may be missed.
- Bartlett assumes normality and is very sensitive to its violation; avoid it for real data.
- For repeated-measures designs, a Levene-style test is not applicable directly; inspect residual plots.