F-test for two variances
Variances (spread) · Two independent samples · reference distribution: F(n₁−1, n₂−1)
When to use it
Compare the spread of two independent groups.
Null hypothesis
The variances are equal: σ₁² = σ₂².
Assumptions
- Independent groups
- Normal data (fragile without it)
Test statistic
F = \dfrac{s_1^2}{s_2^2}How to report it
F(15, 20) = 2.22, p = .097
In R and Python
R
var.test(a, b)
Python
f = a.var(ddof=1) / b.var(ddof=1)
p = 2 * min(stats.f.cdf(f, len(a) - 1, len(b) - 1), stats.f.sf(f, len(a) - 1, len(b) - 1))
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Levene, robust to non-normality
- Pitman-Morgan, with paired samples
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.
Two independent samples. Two groups of different individuals, unrelated to each other, such as treatment and control.
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? Yes