T-test vs ANOVA: which test should you use to compare means?
Both compare group means. The difference is how many groups you have and how your experiment is structured.
Two groups: the t-test
A t-test asks whether the means of two groups differ by more than you'd expect from random variation. Control vs treated, wild type vs knockout: if there are exactly two groups, a t-test is the standard choice.
Three or more groups: one-way ANOVA
Once you have three or more groups, such as vehicle and two doses, use a one-way analysis of variance. ANOVA tests a single question first: is there any difference among the group means?
Why not just run several t-tests?
Each t-test carries its own 5% chance of a false positive. With three groups there are three pairwise comparisons, and the chance of at least one false positive rises to about 14% (1 − 0.95³). With six groups there are fifteen comparisons, and that chance exceeds 50%. ANOVA followed by a corrected post hoc test keeps the overall error rate where you set it.
Two independent variables: two-way ANOVA
If your design crosses two factors, such as genotype and treatment, a two-way ANOVA tests both factors and their interaction: whether the effect of treatment depends on genotype. Interactions are often the most interesting result, and separate one-way analyses can't detect them.
The same subjects measured repeatedly
When each animal, patient or culture is measured more than once, for example at several timepoints, the measurements are not independent. Use a paired t-test for two timepoints and a repeated-measures ANOVA for more. Designs that mix between-group and within-subject factors need a mixed-design ANOVA.
Assumptions to check
- Independence: observations in different groups don't influence each other.
- Approximate normality of the data within each group, or of the residuals.
- Similar variances across groups, or a version of the test that doesn't assume them, such as Welch's.
If normality clearly fails, a non-parametric equivalent is usually the better choice.
Quick summary
- Two independent groups: unpaired t-test
- Two measurements on the same subjects: paired t-test
- Three or more independent groups: one-way ANOVA with a post hoc test
- Two crossed factors: two-way ANOVA
- Repeated measurements over time: repeated-measures or mixed-design ANOVA