Test for equal variances: Bartlett, Levene and Brown-Forsythe

Updated

A test for equal variances checks whether several groups have the same spread. In quality work the spread is often the real problem: four filling heads can share the same average fill while one of them scatters twice as much. The test also checks an assumption of one-way ANOVA, which pools the variances of all groups. The common versions are Bartlett's test, Levene's test and its median-based form, the Brown–Forsythe test.

When to use it

  • You compare machines, heads, cavities, operators or suppliers on consistency rather than on average.
  • You plan a one-way ANOVA and want to know whether pooling the variances is reasonable.
  • You want to confirm that a change (a new valve, a new fixture) reduced variation across several lines.
  • You have two groups only? The 2 variances test is the same idea for a pair.

How it works

All three tests have the same hypotheses: H₀, every group has the same variance, against H₁, at least one differs.

Bartlett's test compares the pooled variance with the individual ones on a log scale. With k groups, nᵢ values and variance sᵢ² in group i, N values in all and pooled variance sₚ²:

T = [ (N − k)·ln(sₚ²) − Σ (nᵢ − 1)·ln(sᵢ²) ] / C, C = 1 + [ Σ 1/(nᵢ − 1) − 1/(N − k) ] / (3(k − 1))

T is compared with a chi-square distribution with k − 1 degrees of freedom. Bartlett's test is the most powerful of the three when the data are normal, but it is very sensitive to non-normality: heavy tails or an outlier can make it reject even when the variances are equal.

Levene's test turns spread into a mean: for each value it computes the absolute deviation from its group mean, zᵢⱼ = |yᵢⱼ − ȳᵢ|, and runs a one-way ANOVA on those deviations. A group with more spread has larger deviations on average.

The Brown–Forsythe test does the same with deviations from the group median, zᵢⱼ = |yᵢⱼ − ỹᵢ|. Using the median makes it robust to skewed data and outliers, and it is the usual default when you do not know whether the data are normal.

When the overall test rejects, a multiple comparisons approach tells you which groups differ: it tests each pair of groups and adjusts the p-values for the number of pairs, so that the chance of any false difference stays at α. In this article each pair is compared with a Brown–Forsythe test (a two-sample t-test on the absolute deviations from the medians) and the p-values are multiplied by the number of pairs (Bonferroni). Other implementations use different pairwise statistics, such as ones based on Bonett's robust interval for a standard deviation; the logic is the same. A good display also shows a confidence interval for each group's standard deviation, adjusted for the number of groups.

Example

A bottling line has four filling heads on a 500 mL product. A technician weighs ten consecutive bottles from each head and converts to volume (mL):

HeadFill volume (mL)StDev
1501.3, 501.9, 498.5, 500.4, 501.3, 501.6, 501.0, 501.7, 500.7, 500.90.972
2500.7, 499.5, 499.7, 500.8, 500.0, 501.6, 501.7, 502.1, 500.5, 501.70.918
3498.9, 499.0, 500.6, 501.0, 497.6, 497.4, 501.1, 498.9, 502.7, 501.21.732
4500.8, 500.7, 501.3, 500.4, 501.4, 500.1, 500.3, 499.9, 501.0, 500.50.495
Fill volume by filling head498500502Fill volume (mL)Head 1Head 2Head 3Head 4
Fill volume by filling head
TestStatisticDFP
Bartlett12.5130.006
Levene (mean)F = 6.523, 360.001
Brown–Forsythe (median)F = 6.143, 360.002

All three agree: the heads do not share one variance.

Which heads differ? Bonferroni-adjusted 95% confidence intervals for each head's standard deviation (normal theory, each at 98.75%) are 0.61 to 2.15 mL for head 1, 0.57 to 2.03 for head 2, 1.08 to 3.83 for head 3 and 0.31 to 1.09 for head 4. The pairwise Brown–Forsythe tests, with p-values multiplied by 6:

PairSD ratioAdjusted P
3 vs 43.500.003
2 vs 30.530.110
1 vs 30.560.124
2 vs 41.850.336
1 vs 41.961.000
1 vs 21.061.000

How to read the results

  • Start with the robust test. Brown–Forsythe's p = 0.002 does not depend on normality, so the difference in spread is real.
  • Bartlett agrees here, which also suggests no gross departure from normality. When Bartlett rejects and Brown–Forsythe does not, suspect outliers or heavy tails before you suspect the variances.
  • The pairwise tests point to head 3 against head 4. Head 3 scatters about 3.5 times as much as head 4. Heads 1 and 2 sit in between and cannot be separated from either with ten bottles each.
  • Act on the worst head. Head 3's standard deviation of 1.7 mL is what drives underfills. A worn valve seal or a nozzle drip is a typical cause; inspect it first.
  • For the ANOVA on means, unequal variances like these call for Welch's ANOVA rather than the classic F test.

Common mistakes

  • Using Bartlett's test on non-normal data. It reacts to the shape of the distribution as much as to the spread. Check with a normality test or use Brown–Forsythe.
  • Reading a large p-value as proof of equal variances. With five or six values per group, even a threefold difference in standard deviation can go undetected.
  • Comparing ranges by eye on a boxplot and stopping there. A boxplot is a good start, but one outlier can make a box look wide.
  • Running unadjusted pairwise tests. Six pairs at 5% each give a much higher chance of a false difference.
  • Forgetting the time order. A head whose variation comes from drift needs a control chart, not just a variance test.

Frequently asked questions

Which test should I use: Bartlett or Levene?

Use Brown–Forsythe (Levene with medians) by default, because it holds up when the data are not normal. Use Bartlett when you are confident the data are normal; it then has more power.

What is the difference between Levene's test and Brown–Forsythe?

Levene's original test uses absolute deviations from the group means; Brown–Forsythe uses deviations from the group medians, which makes it more robust to skewness and outliers. Many people call both "Levene's test".

Do I need equal variances for one-way ANOVA?

The classic F test assumes them, but it tolerates moderate differences when group sizes are equal. With clearly unequal variances, and especially with unequal group sizes, use Welch's ANOVA.

How many observations per group do I need?

More than for comparing means. For two normal groups compared with an F test at α = 0.05, ten values each give about 88% power to detect a threefold ratio between standard deviations, while a ratio of 1.5 needs about 50 per group for 80% power.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab