Sample size for one-way ANOVA: power with several groups
Sample size for one-way ANOVA is the number of units per group needed so that a one-way ANOVA detects a given difference among several group means, such as cavities, machines or suppliers, with a chosen power. The power comes from the noncentral F distribution. Because many patterns of means are possible, the usual planning value is the difference between the largest and smallest means, taken in the least favorable arrangement.
When to use it
- You plan to compare three or more groups on a measured characteristic: mold cavities, spindles, operators, material lots.
- You can state the smallest difference between two group means that would matter.
- You want to know whether a proposed number of parts per group is enough, or how much the number of groups changes the answer.
How it works
With k groups of n units each and a common standard deviation σ, the ANOVA F statistic follows a noncentral F distribution with k − 1 and k(n − 1) degrees of freedom, and noncentrality
λ = n Σ (μᵢ − μ̄)² / σ²The power is P(F′ > F₁₋α, k−1, k(n−1)). Increase n until the power reaches the target.
You rarely know all k means in advance. The standard planning choice is the maximum difference Δ: two means differ by Δ and all the others sit halfway between them. That is the arrangement with the least power for a given Δ, so a design sized for it has at least the stated power for any pattern with the same spread. In that case Σ(μᵢ − μ̄)² = Δ²/2, and
λ = n Δ² / (2σ²)Only Δ/σ, k and n matter. With k = 2, the ANOVA is the 2-sample t test and gives the same answer.
Example
A four-cavity mold makes a plastic clip. Within each cavity, the critical width varies with σ ≈ 0.04 mm. A difference of 0.06 mm between any two cavities (Δ/σ = 1.5) would force a cavity-specific tool correction. Plan: one-way ANOVA at α = 0.05 with 80% power.
For n = 11 parts per cavity, λ = 11 × 0.06² / (2 × 0.04²) = 12.38, the degrees of freedom are 3 and 40, and F₀.₉₅,₃,₄₀ = 2.839. The power is P(F′ > 2.839) = 0.812. With 10 parts per cavity it is 0.765, so the answer is 11 parts per cavity, 44 in all.
A simulation of 200,000 experiments with cavity means at −0.03, +0.03, 0 and 0 mm and σ = 0.04 mm (NumPy, seed 31) rejected in 81.2% of them.
The least favorable pattern is the pessimistic case. If the four cavity means were evenly spread over the same 0.06 mm, the same 11 parts would give power 0.855; if two cavities sat at each extreme, 0.987.
How to read the results
- Eleven parts per cavity give at least an 81% chance of detecting a 0.06 mm spread between cavities, whatever the other two cavities do.
- More groups need more per group. For the same Δ/σ = 1.5, two groups need 9 per group, four need 11 and six need 13. The extra groups add little signal but use degrees of freedom and raise the critical F.
- Smaller differences cost much more. At Δ = 0.04 mm (Δ/σ = 1), 11 parts per cavity give only 44% power; 80% takes 23 per cavity.
- A significant ANOVA says only that some means differ. Plan the follow-up comparisons (Tukey, or an analysis of means against the overall mean) at the same time.
Common mistakes
- Using the standard deviation of all parts pooled together. That σ includes the cavity differences you are trying to detect. Use the within-group σ.
- Planning for the evenly spread pattern without saying so. It gives a smaller n, but less protection if the difference comes from one odd cavity.
- Unequal groups by accident. Losing parts from one cavity lowers power and makes the test more sensitive to unequal variances. Plan a few spares.
- Ignoring unequal variances. If one cavity is much more variable, check with a test for equal variances and consider Welch's ANOVA.
Frequently asked questions
What does "maximum difference" mean in a sample size calculation?
It is the difference between the largest and smallest group means you want to detect. The calculation assumes the worst arrangement of the other means for that spread, so the stated power is a minimum.
Why does the answer depend on the number of groups?
The test spreads its attention over all k − 1 comparisons. With more groups, a single large difference is diluted, and the critical F value changes with the degrees of freedom.
Can I use effect size f instead of Δ?
Yes. Cohen's f is √(Σ(μᵢ − μ̄)²/k)/σ, so λ = k n f². For the maximum-difference pattern, f = Δ/(σ√(2k)). Both describe the same thing; Δ is easier to relate to a specification.
How do I size a test on cavities when parts come in shots?
Each shot gives one part per cavity, so 11 shots give 11 parts per cavity. Spread the shots over time so that the within-cavity σ includes normal shot-to-shot variation.