2 variances test: F test, Levene and Bonett compared

Updated

The 2 variances test checks whether two groups have different standard deviations: two machines, two suppliers, two settings. Consistency often matters as much as the average, and a change that leaves the mean alone can still double the spread. The classic F test compares the ratio of the two sample variances; Levene's test (in its Brown–Forsythe form) and Bonett's method do the same job without relying on normal data.

When to use it

  • Comparing the consistency of two machines, lines, operators or material lots.
  • Checking whether a process change reduced variation, which a t-test on the means cannot show.
  • Deciding whether two groups can be pooled, or whether a capability study must treat them separately.
  • For three or more groups, use the test for equal variances.

How it works

Hypotheses, with σ₁ and σ₂ the two process standard deviations:

  • H₀: σ₁ = σ₂ (the ratio σ₁/σ₂ = 1).
  • H₁: σ₁ ≠ σ₂, or σ₁ > σ₂, or σ₁ < σ₂.

F test. With sample standard deviations s₁ and s₂:

F = s₁² / s₂², df = (n₁ − 1, n₂ − 1)

The two-sided p-value is twice the smaller tail of the F distribution. The confidence interval for the ratio of standard deviations is:

√( F / F(1 − α/2; n₁ − 1, n₂ − 1) ) ≤ σ₁/σ₂ ≤ √( F / F(α/2; n₁ − 1, n₂ − 1) )

The F test is exact for normal data and the most powerful choice when that holds. It is also very sensitive to non-normality: heavy tails or skewness can produce a small p-value when the spreads are equal.

Levene's test, Brown–Forsythe version. Replace each value by its absolute distance from its own group median, zᵢⱼ = |xᵢⱼ − median_j|, and run a one-way ANOVA F test on the z values. A group with more spread has larger distances. Using the median instead of the mean makes the test robust to skewed and heavy-tailed data. The degrees of freedom are (1, n₁ + n₂ − 2).

Bonett's method builds a confidence interval for σ₁/σ₂ that adjusts for the kurtosis of the pooled data. It has nearly the accuracy of the F test on normal data and stays reliable when the data are not normal, and it comes with a matching confidence interval for the ratio, which Levene's test does not provide.

Assumptions for all three: independent observations within and between groups.

Example

A molding shop runs the same 4-cavity tool on two presses: Press A, an older hydraulic machine, and Press B, a newer all-electric one. Part weight is a good indicator of fill consistency. The process engineer weighs 15 parts from each press, all from the same cavity, in grams:

Press A (g)Press B (g)
24.66, 24.44, 24.53, 24.58, 24.77, 24.54, 24.58, 24.60, 24.67, 24.54, 24.46, 24.48, 24.62, 24.73, 24.7424.56, 24.56, 24.65, 24.51, 24.63, 24.56, 24.66, 24.69, 24.61, 24.66, 24.59, 24.58, 24.61, 24.65, 24.58
Part weight by press24.524.624.7Part weight (g)Press APress B
Part weight by press
PressNMeanStDev
A1524.5960.1023
B1524.6070.0497

Test H₀: σ_A = σ_B, two-sided, α = 0.05:

  • F test: F = 0.1023² / 0.0497² = 4.24 with (14, 14) df. Upper tail = 0.0053, so the two-sided p-value is 0.011.
  • 95% CI for σ_A/σ_B: the ratio of standard deviations is 2.06. With F(0.975; 14, 14) = 2.979 and F(0.025; 14, 14) = 0.336, the interval is √(4.24/2.979) = 1.19 to √(4.24/0.336) = 3.56.
  • Levene (Brown–Forsythe): the mean absolute distance from the median is 0.081 g for Press A and 0.041 g for Press B. The ANOVA on these distances gives F = 5.69 with (1, 28) df and p = 0.024.

Anderson–Darling tests on each press give p = 0.82 and p = 0.57, so the F test's normality assumption is reasonable here, and its smaller p-value can be trusted.

How to read the results

  • Both tests reject H₀: Press A's part weight varies more than Press B's. The means are almost the same (24.596 against 24.607 g), so a t-test would have found nothing.
  • The interval says Press A's standard deviation is between about 1.2 and 3.6 times Press B's. Even at the low end, that is a real difference in fill consistency.
  • In molding terms, a weight spread twice as large usually shows up as more short shots, flash or dimensional variation. Check the hydraulic press's check ring, injection velocity control and cushion consistency before blaming the tool.
  • When the tests disagree, trust the F test only if both groups look normal; otherwise go with Levene or Bonett.

Common mistakes

  • Using the F test on non-normal data. With skewed or heavy-tailed data, it raises false alarms. The p-value does not get better with larger samples.
  • Reading "no significant difference" as "same spread". Variance tests have low power: with 15 per group, a 1.5-to-1 ratio of standard deviations is often missed.
  • Mixing cavities. Parts from different cavities have different mean weights. Mixing them inflates the spread of one press and hides the real comparison.
  • Testing variances only to choose the t-test. If you use Welch's 2-sample t-test, you do not need a variance test first.

Frequently asked questions

Which test for two variances should I use?

If the data in both groups are close to normal, the F test is the most powerful. If not, or if you are not sure, use Levene's (Brown–Forsythe) test or Bonett's method. Bonett's has the advantage of a matching confidence interval for the ratio.

Why does Levene's test use the median?

The original Levene test used distances from the group mean. Brown and Forsythe showed that distances from the median keep the test accurate for skewed and heavy-tailed data, with little loss of power for normal data.

Can I compare standard deviations instead of variances?

Yes. The hypotheses σ₁ = σ₂ and σ₁² = σ₂² are the same. Report the ratio of standard deviations, since it is in the units of the data.

How many samples do I need?

More than most people expect. To detect a 1.5-to-1 ratio of standard deviations with 80% power, the F test needs about 50 per group (with 15 per group its power is only about 30%), and the robust tests need more. See sample size for 2 variances.

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