Levene’s test
Variances (spread) · Three or more independent groups · reference distribution: F(k−1, N−k)
When to use it
Check whether two or more groups have the same variance, for example before an ANOVA.
Null hypothesis
All variances are equal.
Assumptions
- Independent groups
Test statistic
W = \dfrac{(N - k) \sum_j n_j (\bar{Z}_j - \bar{Z})^2}{(k - 1) \sum_j \sum_i (Z_{ij} - \bar{Z}_j)^2}How to report it
F(2, 42) = 1.36, p = .27
In R and Python
R
library(car)
leveneTest(y ~ group, data = df, center = mean) # center = median is Brown-Forsythe
Python
stats.levene(a, b, c, center="mean") # "median" is Brown-Forsythe
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Brown-Forsythe, with deviations from the median (more robust)
- Bartlett, more powerful but requires normality
Where it sits in the catalog
Variances (spread). They compare how spread out the data are, not the center. Useful on their own, as in quality control, and to check the equal-variance assumption of other tests.
Three or more independent groups. Several groups of different individuals, tested at once: one test per pair would inflate the type I error.
In the decision tree
- What do you want to do? Compare groups, or one group with a reference value
- What kind of response did you measure? The spread, not the center
- How many groups or measurements? Two independent groups
- Are the data normal? No, or it cannot be assured
- What do you want to do? Compare groups, or one group with a reference value
- What kind of response did you measure? The spread, not the center
- How many groups or measurements? Three or more independent groups
- What do you want to do? Check an assumption or the distribution of the data
- What do you want to check? Whether the groups have the same variance
It also appears alongside other tests:
- To check an assumption before One-way ANOVA, Two-way ANOVA.