ANOVA (analysis of variance) is a test of whether the means of several groups differ. It compares how far apart the group means are with how much values vary inside each group, giving a single ratio: the F statistic. A significant ANOVA tells you that at least one group mean differs, not which one: you need a post hoc test for that.
A one-way ANOVA has one grouping factor, such as three fertiliser treatments. A two-way ANOVA has two factors and also tests whether they interact. ANOVA is most useful once you have three or more groups. Running a separate t-test for every pair instead quickly inflates your chance of a false positive.
What is ANOVA and when should you use it?
Use ANOVA when you have one continuous outcome (a weight, a score, a reaction time) and want to compare its mean across groups. Despite the name, ANOVA compares means: it uses the variation in your data to do it. The grouping variable is called a factor, and its settings are its levels. In an experiment comparing three temperatures, temperature is the factor and each temperature is a level.
The test sets up two hypotheses:
- Null hypothesis: all the group means are equal in the population.
- Alternative hypothesis: the means are not all the same.
ANOVA can be used with two or more groups. With exactly two, a t-test compares the two means directly.
It isn’t the right tool for every question. If your outcome is a category (passed or failed, yes or no), you need something like the chi-square test. If you want to know how strongly two continuous variables are linearly related, that’s a question for Pearson correlation, not ANOVA.
Why not just run several t-tests?
Because every extra test is another chance of a false positive, also called a type I error: rejecting a null hypothesis that’s true. If there’s no real difference, each comparison at the 0.05 level still has a 5% chance of finding one. Run several and those chances build up.
| Number of comparisons | Chance of at least one false positive |
|---|---|
| 1 | 0.05 |
| 2 | 0.098 |
| 3 | 0.143 |
| 6 | 0.265 |
Source: Kim (2017), Korean Journal of Anesthesiology. The figures treat each test as independent.
With three groups you’d need three pairwise t-tests, and your overall false-positive risk can climb to about 14%, nearly three times the 5% you chose. ANOVA asks one question of all the groups at once, so the overall risk stays at the level you chose. Our guide to the statistical treatment of data explains type I and type II errors.
One-way vs two-way vs repeated-measures ANOVA
ANOVA is a family of tests, and which one you need depends on two things: how many factors you have, and whether the same people (or samples) are measured more than once. A one-way ANOVA has one factor; a two-way ANOVA has two.
| Type | Design | What it tests | Example |
|---|---|---|---|
| One-way ANOVA | One factor, independent groups | Whether the group means differ | Plant weight under a control and two treatments |
| Two-way ANOVA | Two factors, independent groups | Each factor’s effect, plus whether the two factors interact | Plant weight by treatment and by watering level |
| Repeated-measures ANOVA | The same participants measured several times | Whether the mean changes across the measurements | Pain scores at three time points in the same patients |
A two-way ANOVA tests three null hypotheses at once: no difference across the levels of factor A, none across the levels of factor B, and no interaction between A and B. An interaction means the effect of one factor depends on the level of the other.
Common mistake: analysing repeated measurements with an ordinary one-way ANOVA. When the same people are measured more than once, the variation between people and the variation within each person need to be treated separately. Repeated-measures ANOVA does that, and it adds its own assumption, called sphericity.
How ANOVA works: the formula
ANOVA splits the total variation in your data into two parts:
- Between-groups variation: how far each group mean sits from the overall mean.
- Within-groups variation: how far each value sits from its own group’s mean.
In symbols, SStotal = SSbetween + SSwithin, where SS means sum of squares. Each part is divided by its degrees of freedom to give a mean square (MS):
- MSbetween = SSbetween / (k − 1), where k is the number of groups
- MSwithin = SSwithin / (N − k), where N is the total number of observations
The F statistic, named after the statistician Ronald Fisher, is the ratio of the two: F = MSbetween / MSwithin. If the population means really are equal, the two mean squares should be similar and F should be close to 1. The further apart the group means are, compared with the noise inside the groups, the larger F gets.
A worked one-way ANOVA example
This example uses the dried weights of 30 plants: 10 grown under a control condition and 10 under each of two treatments. The data come from Dobson’s 1983 textbook. They ship with the R software as the PlantGrowth dataset, so you can check every number below yourself.
Step 1: Work out the means
| Group | Weights (10 plants) | Total | Mean |
|---|---|---|---|
| Control | 4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14 | 50.32 | 5.032 |
| Treatment 1 | 4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69 | 46.61 | 4.661 |
| Treatment 2 | 6.31, 5.12, 5.54, 5.50, 5.37, 5.29, 4.92, 6.15, 5.80, 5.26 | 55.26 | 5.526 |
The overall (grand) mean is 152.19 ÷ 30 = 5.073.
Step 2: Between-groups sum of squares
For each group, square the gap between its mean and the grand mean, then multiply by the group size (10):
- Control: 10 × (5.032 − 5.073)² = 0.017
- Treatment 1: 10 × (4.661 − 5.073)² = 1.697
- Treatment 2: 10 × (5.526 − 5.073)² = 2.052
SSbetween = 3.766, with k − 1 = 2 degrees of freedom.
Step 3: Within-groups sum of squares
For each plant, square the gap between its weight and its own group mean, then add them up within each group. That gives 3.060 for the control group, 5.669 for treatment 1 and 1.763 for treatment 2.
SSwithin = 10.492, with N − k = 30 − 3 = 27 degrees of freedom.
Step 4: Mean squares and F
| Source | Sum of squares | df | Mean square | F |
|---|---|---|---|---|
| Between groups | 3.766 | 2 | 1.883 | 4.85 |
| Within groups | 10.492 | 27 | 0.389 | |
| Total | 14.258 | 29 |
Source: our calculation from the PlantGrowth data; R gives the same values.
F = 1.8832 ÷ 0.3886 = 4.85. (Divide the rounded mean squares in the table and you’ll get 4.84; software works with the unrounded values.)
Step 5: Is it significant?
Compare F with the critical value of the F distribution for 2 and 27 degrees of freedom. The table value is 3.354 at the 5% level and 5.488 at the 1% level. Our F of 4.85 is above the first and below the second, so 0.01 < p < 0.05. Statistical software gives the exact value: p = 0.016.
Because p is below 0.05, you reject the null hypothesis: the three group means are not all equal. ANOVA alone can’t tell you which pairs of groups differ. Treatment 2’s mean is the highest and treatment 1’s the lowest, but you need a post hoc test to know which differences are statistically significant.
Step 6: Effect size
A p-value tells you how surprising your data would be if there were no effect, not how big the effect is. One effect size for ANOVA is eta squared (η²), the share of the total variation that the groups explain:
η² = SSbetween ÷ SStotal = 3.766 ÷ 14.258 = 0.26
So in this sample, the groups account for about 26% of the variation in plant weight.
Which groups differ? Post hoc tests
A post hoc test ("after the fact") compares the groups in pairs once ANOVA has found a difference. It keeps the overall false-positive risk under control while it does so.
- Bonferroni correction: divide your significance level by the number of comparisons. With three groups at 0.05, each pairwise test uses 0.05 ÷ 3 = 0.017.
- Tukey’s HSD (honestly significant difference): compares every pair of means at once using the studentised range distribution. With equal group sizes, its overall confidence level is exactly the one you set.
With equal group sizes (10 here), Tukey’s HSD is q × √(MSwithin ÷ n), where n is the number in each group. The studentised range value q for three groups and 27 degrees of freedom at the 5% level is 3.506, so:
HSD = 3.506 × √(0.389 ÷ 10) = 0.69
At the 5% level, for all three comparisons together, any pair of means more than 0.69 apart differs significantly. If your groups are different sizes, Tukey’s method still works, but the standard error is worked out separately for each pair. That version is sometimes called the Tukey–Kramer method.
| Comparison | Difference in means | Bigger than 0.69? |
|---|---|---|
| Treatment 2 vs treatment 1 | 0.865 | Yes |
| Treatment 2 vs control | 0.494 | No |
| Treatment 1 vs control | 0.371 | No |
Source: our calculation; q from a published studentised range table.
Only one pair differs significantly: the two treatments. Neither treatment differs significantly from the control, which is easy to miss if you stop at the ANOVA. Software running the same Tukey test gives adjusted p-values of 0.012, 0.198 and 0.391 for these three pairs, matching the hand calculation.
ANOVA assumptions (and what to do if they fail)
ANOVA is a parametric test, so it relies on three assumptions:
- Independence: each observation is independent of the others.
- Normality: the values in each group come from a roughly normal distribution. The Shapiro–Wilk test is one way to check.
- Equal variances: the groups have similar spread. Levene’s test checks this.
A practical rule of thumb covers the last one. ANOVA’s results will still be valid if the largest group standard deviation is less than twice the smallest. In the plant data the standard deviations are 0.583 (control), 0.794 (treatment 1) and 0.443 (treatment 2). The largest is 1.8 times the smallest, so the rule is met.
If the assumptions don’t hold, you have options:
- Unequal variances: if the largest standard deviation is twice the smallest or more, the rule of thumb no longer covers you, and the F test itself may be unreliable, not only the comparisons after it. When the spread grows with the group mean, analysing the logarithm of your outcome can often fix this. For the pairwise step, use a post hoc method that doesn’t assume equal variances, such as Games–Howell, rather than Tukey.
- Non-normal data: use the Kruskal–Wallis test, a nonparametric alternative that compares the groups’ medians using ranks instead of raw values.
Is your outcome a Likert-type rating? Our guide to analysing Likert scale data explains when parametric tests such as ANOVA are defensible and when to use non-parametric ones.
Before you analyse: decide on your post hoc method in advance, and say which you used.
How to report ANOVA results (APA style)
Here is a write-up for the plant example. It gives the F statistic with both degrees of freedom, the exact p-value, an effect size and then the post hoc results:
A one-way ANOVA showed that dried plant weight differed across the three conditions, F(2, 27) = 4.85, p = .016, η² = .26. Tukey’s HSD showed that plants under treatment 2 (M = 5.53) were heavier than those under treatment 1 (M = 4.66), p = .012. Neither treatment differed significantly from the control (M = 5.03; p = .198 for treatment 2 and p = .391 for treatment 1).
The APA numbers and statistics guide gives these general rules:
- Give F and other test statistics to two decimal places.
- Give exact p-values to two or three decimals, and write p < .001 for anything smaller.
- Leave out the zero before the decimal point for values that can’t exceed 1, such as p and η² (a proportion).
- Put statistical symbols such as F, p and M in italics, but not Greek letters such as η.
- Don’t repeat the same statistics in both the text and a table.
Next steps
Start by matching your design to the right ANOVA: one factor or two, independent groups or repeated measurements. Check the assumptions, run the test in your statistics software and follow a significant result with a post hoc test. Then adapt the plant example’s write-up above for your own ANOVA results.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods: Are the means equal?
- Kim TK (2017). Understanding one-way ANOVA using conceptual figures. Korean Journal of Anesthesiology
- Lee Y (2015). What repeated measures analysis of variances really tells us. Korean Journal of Anesthesiology
- Loughborough University mathematics learning support: Oneway analysis of variance
- R source: PlantGrowth data
- ETH Zurich course notes: Completely randomized designs
- STAT351 course notes: One way ANOVA
- NIST/SEMATECH e-Handbook: Critical values of the F distribution
- Purdue University: Critical values of the studentized range distribution
- NIST/SEMATECH e-Handbook: Tukey’s method
- NIST/SEMATECH e-Handbook: The Kruskal-Wallis test
- R effectsize package: Effect sizes for ANOVAs


