Skip to main content

Levene Test for Equality of Variances

NIST/SEMATECH Section 1.3.5.10 Levene Test for Equality of Variances

What It Is

The Levene test assesses whether multiple groups have equal variances without requiring the data to be normally distributed. It applies a one-factor ANOVA to the absolute deviations of observations from their group means (or medians).

When to Use It

Use the Levene test as a robust alternative to Bartlett's test when the data may not be normally distributed. Since Bartlett's test is sensitive to non-normality, the Levene test is preferred in practice for verifying the homogeneity of variance assumption before ANOVA. The median-based variant (Brown-Forsythe) provides additional robustness against heavy-tailed or skewed distributions.

How to Interpret

The Levene W statistic follows an approximate F-distribution with (k-1, N-k) degrees of freedom under the null hypothesis of equal variances. If W exceeds the F critical value, reject equal variances. When comparing the mean-based and median-based variants, the median version is more robust to outliers but slightly less powerful for normal data. A significant Levene test suggests that standard ANOVA assumptions are violated, and a Welch ANOVA or non-parametric test should be used instead.

Assumptions and Limitations

The Levene test requires independent observations but does not require normality, making it applicable to a broader range of distributions. It does assume that the groups are independent and that the sample sizes are reasonably balanced for optimal power.

Reference: NIST/SEMATECH e-Handbook, Section 1.3.5.10

Formulas

Levene W Statistic

W=(Nk)(k1)j=1knj(ZˉjZˉ)2j=1ki=1nj(ZijZˉj)2W = \frac{(N-k)}{(k-1)} \cdot \frac{\sum_{j=1}^{k} n_j (\bar{Z}_{j\cdot} - \bar{Z}_{\cdot\cdot})^2}{\sum_{j=1}^{k}\sum_{i=1}^{n_j}(Z_{ij} - \bar{Z}_{j\cdot})^2}

An F-statistic computed on the transformed values Z_ij = |x_ij - x-bar_j|. The test is equivalent to a one-way ANOVA on absolute deviations.

Absolute Deviation Transform (Mean)

Zij=xijxˉjZ_{ij} = |x_{ij} - \bar{x}_j|

Each observation is replaced by its absolute deviation from its group mean. This is the original Levene formulation, best suited for symmetric, moderate-tailed distributions.

Brown-Forsythe Variant (Median)

Zij=xijx~jZ_{ij} = |x_{ij} - \tilde{x}_j|

Uses the group median instead of the mean. More robust against skewed and heavy-tailed distributions and is generally recommended as the default choice.

Trimmed Mean Variant

Zij=xijxˉjZ_{ij} = |x_{ij} - \bar{x}_j'|

Uses the 10% trimmed mean of each group. A compromise that performs well for heavy-tailed distributions such as the Cauchy.

Python Example

import numpy as np
from scipy import stats
# Three groups with potentially different variances
group1 = np.array([23.1, 24.3, 22.8, 23.9, 24.0, 23.5])
group2 = np.array([20.4, 29.9, 27.1, 22.3, 30.8, 25.7])
group3 = np.array([28.2, 27.5, 29.1, 28.0, 28.7, 27.9])
# Levene test (mean-based, default)
stat_mean, p_mean = stats.levene(group1, group2, group3, center='mean')
print(f"Levene (mean): W={stat_mean:.4f}, p={p_mean:.6f}")
# Brown-Forsythe (median-based, more robust)
stat_med, p_med = stats.levene(group1, group2, group3, center='median')
print(f"Brown-Forsythe: W={stat_med:.4f}, p={p_med:.6f}")
print(f"\nEqual variances (alpha=0.05): {p_mean > 0.05}")