Levene's Test for Equal Variances
This guide shows you how to check whether two or more groups have the same variance, using Levene's test and the more robust Brown-Forsythe variant, so you can decide which t-test or ANOVA to trust.
What the test does and why it matters
Many everyday tests assume that the groups you compare share the same spread. A pooled two-sample t-test and a classic one-way ANOVA both rest on this assumption of homogeneity of variance. If one group is far more variable than another, those tests can report a p-value that is simply wrong.
Levene's test checks that assumption directly. Take the demo data: group A is 4, 5, 6, 5, 4 and group B is 2, 8, 3, 9, 4. Both average 4.8, so a test of means finds nothing. But group A has variance 0.7 while group B has variance 9.7, roughly 14 times larger. Levene's test is built to catch exactly that difference in spread.
The idea is simple. Convert each observation into a distance from its group center, then run an ANOVA on those distances. If one group's distances are systematically larger, the group is more spread out, and the test flags it.
When to use it, and when not to
Reach for Levene's test as a preflight check before a pooled t-test or an ANOVA. If it comes back non-significant, the equal-variance assumption is reasonable and you can use the pooled versions. If it comes back significant, switch to a method that does not assume equal variance, such as Welch's t-test or Welch's ANOVA.
If you already plan to use Welch's t-test or a nonparametric method, you may not need Levene's test at all. Welch does not assume equal variances, so testing for them first only adds a decision step. Many statisticians now default to Welch and skip the pretest.
Do not use Levene's test on paired data or on counts that violate independence. Each observation must belong to exactly one group, and the groups must be independent samples. For heavily skewed data, prefer the median-centred Brown-Forsythe variant described below.
The formula and the intuition behind it
Let group i have n_i observations Y_{ij}, with k groups and N observations in total. Define a spread score for each point:
Here \bar{Y}_i is the center of group i. For the original Levene test it is the group mean. For the Brown-Forsythe variant it is the group median, which is far less sensitive to outliers and skew.
Now run a one-way ANOVA on the Z_{ij} values. The test statistic is:
In this expression \bar{Z}_i is the mean spread score within group i, and \bar{Z} is the mean spread score across all points. The numerator measures how much the group spread scores differ from each other. The denominator measures the leftover variation within groups. When groups have equal variance, the two are comparable and W stays near 1. When one group is much wider, its \bar{Z}_i jumps up and W grows.
Under the null hypothesis of equal variances, W follows an F distribution with k-1 and N-k degrees of freedom.
A worked example with the demo data
Two groups, equal means, unequal spread
Use the demo data: group A 4, 5, 6, 5, 4 and group B 2, 8, 3, 9, 4. Here k = 2, n_1 = n_2 = 5, and N = 10. This walkthrough uses the mean-centred Levene test.
- Group means: \bar{Y}_A = 4.8 and \bar{Y}_B = 5.2.
- Absolute deviations for A:
|4-4.8|=0.8,0.2,1.2,0.2,0.8. Mean \bar{Z}_A = 0.64. - Absolute deviations for B:
|2-5.2|=3.2,2.8,2.2,3.8,1.2. Mean \bar{Z}_B = 2.64. - Overall mean of the Z scores: \bar{Z} = 1.64.
- Between-group sum of squares:
5(0.64-1.64)^2 + 5(2.64-1.64)^2 = 5 + 5 = 10. - Within-group sum of squares: for A,
0.848; for B,4.352; total5.2. - Assemble the statistic: W = \frac{8}{1} \cdot \frac{10}{5.2} = 15.38.
With degrees of freedom 1 and 8, an F statistic of 15.38 gives a p-value of about 0.0044. That is well below 0.05, so you reject equal variances. The two groups do differ in spread, exactly as the raw variances (0.7 versus 9.7) suggested.
Explore how one wide group shifts the result
Reading and interpreting the output
The calculator reports the test statistic W, the two degrees of freedom, and a p-value. It shows both the mean-centred Levene value and the median-centred Brown-Forsythe value.
- Null hypothesis
- All group variances are equal. A large p-value (say above
0.05) means you keep this assumption. - Alternative hypothesis
- At least one group's variance differs. A small p-value means you reject equal variances and should use a variance-robust test.
- Brown-Forsythe value
- The same statistic computed around group medians. Trust this one when your data are skewed or contain outliers.
A useful mental scale: for the demo data the Brown-Forsythe version uses medians 5 and 4, giving deviations that still put group B far ahead, so its p-value also lands below 0.05. When the mean- and median-centred results disagree, report the Brown-Forsythe result, because it is the more reliable of the two.
Common mistakes
A non-significant Levene result does not prove equal variances. It only fails to find a difference. With small samples the test has low power: five points per group can easily miss a real two-fold difference in variance.
Three errors show up often. First, treating a significant Levene result as a reason to abandon the analysis. It is not. It just tells you to switch to Welch's method, which handles unequal variances. Second, running the mean-centred test on skewed data. Skew inflates the mean-centred statistic and produces false positives, so use Brown-Forsythe there. Third, confusing this with a normality check. Levene's test says nothing about whether the data are normal; for that, use the Normality Test Battery.
Related calculators
Once you have checked variances, move to the test that answers your actual question. For two groups, use the t-Test Calculator, which offers both pooled and Welch versions. For three or more groups, use the One-Way ANOVA Calculator. If variances differ badly and the data are skewed, the rank-based Mann-Whitney U Test and Kruskal-Wallis H Test sidestep the variance assumption entirely. To turn any F or t statistic into a p-value by hand, use the P-value Calculator.
Frequently asked questions
What is the difference between Levene's test and the Brown-Forsythe test?
They use the same formula. Levene's original test measures each point's distance from its group mean, while Brown-Forsythe measures distance from the group median. The median version resists outliers and skew, so it is the safer default. For the demo data both flag unequal variances.
What p-value threshold should I use?
Most people use 0.05. Below that, reject equal variances and use Welch's t-test or ANOVA. Above it, the equal-variance assumption is acceptable. Because the decision only changes which test you run next, the exact cutoff rarely matters much.
Can I run Levene's test on two groups only?
Yes. With two groups it is a valid alternative to an F-ratio-of-variances test, and it is more robust to non-normal data. The demo example uses exactly two groups and returns W = 15.38 with a p-value of about 0.0044.
Why did my t-test and Levene's test disagree?
They test different things. A t-test compares means; Levene's test compares spreads. The demo groups have identical means (both 4.8) yet very different variances, so a test of means finds nothing while Levene's test finds a clear difference.