When your research compares three or more groups, such as students from public, private and semi-government universities, you need analysis of variance, or ANOVA. It answers one question: are all the group means equal, or is at least one different? This article builds ANOVA from first principles and finishes with a complete calculation you can check against SPSS or R.
Why Not Just Run Several t-Tests?
With three groups you could run three t-tests (A vs B, A vs C, B vs C). The problem is that each test carries a 5% risk of a false positive. Across three tests the chance of at least one false positive rises to roughly
$$ 1 - 0.95^3 = 0.143 $$
or about 14%. With five groups (ten comparisons) it climbs to about 40%. ANOVA tests all the groups together in a single test, keeping the overall error rate at 5%.
The Logic: Splitting Up the Variation
ANOVA was developed by Ronald A. Fisher in the 1920s while he was analysing crop experiments at the Rothamsted agricultural station in England. His insight was that the total variation in the data can be split into two parts:
- Between-groups variation: how far the group means sit from the grand mean. This reflects the effect of the grouping variable, plus random noise.
- Within-groups variation: how far individual scores sit from their own group mean. This is pure random noise.
$$ SS_{\text{total}} = SS_{\text{between}} + SS_{\text{within}} $$
Each sum of squares is divided by its degrees of freedom to give a mean square (MS), and the ratio of the two mean squares is the F statistic:
$$ F = \frac{MS_{\text{between}}}{MS_{\text{within}}} $$
If the null hypothesis is true, both mean squares estimate the same noise, so F is close to 1. A large F suggests real differences between groups.
Assumptions
- Independence: each participant belongs to only one group and does not influence others.
- Normality: scores in each group are roughly normal (check Shapiro–Wilk or Q–Q plots; ANOVA is fairly robust with equal, moderate group sizes).
- Homogeneity of variance: groups have similar spreads (Levene's test). If this fails, report Welch's ANOVA with Games–Howell post hoc tests.
Worked Example: Three Teaching Methods
A researcher in Lahore compares three methods for teaching statistics to BS students, with four students per method. Final test scores:
| Method | Scores | Mean |
|---|---|---|
| A: Lecture | 70, 74, 72, 76 | 73 |
| B: Self-study | 65, 63, 68, 64 | 65 |
| C: Software-based | 80, 78, 84, 82 | 81 |
Here \( k = 3 \) groups, \( n = 4 \) per group, and \( N = 12 \).
Step 1: Grand Mean
All 12 scores sum to 876, so the grand mean is \( 876/12 = 73 \).
Step 2: Between-Groups Sum of Squares
$$ SS_B = \sum n_j(\bar{x}_j - \bar{x})^2 = 4(73-73)^2 + 4(65-73)^2 + 4(81-73)^2 $$
$$ SS_B = 4(0) + 4(64) + 4(64) = 512 $$
Step 3: Within-Groups Sum of Squares
Square each score's deviation from its own group mean:
- Method A: deviations −3, 1, −1, 3, giving \( 9+1+1+9 = 20 \).
- Method B: deviations 0, −2, 3, −1, giving \( 0+4+9+1 = 14 \).
- Method C: deviations −1, −3, 3, 1, giving \( 1+9+9+1 = 20 \).
So \( SS_W = 20 + 14 + 20 = 54 \). As a check, the total sum of squares about the grand mean is 566, and \( 512 + 54 = 566 \).
Step 4: Degrees of Freedom and Mean Squares
- \( df_B = k - 1 = 2 \), so \( MS_B = 512/2 = 256 \).
- \( df_W = N - k = 9 \), so \( MS_W = 54/9 = 6 \).
Step 5: The F Ratio
$$ F = \frac{256}{6} = 42.67 $$
The critical F value for (2, 9) df at \( \alpha = .05 \) is 4.26. Our F is far larger, and the exact p-value is below .001. We reject the null hypothesis that all three methods produce the same mean score.
Step 6: Effect Size
Eta squared tells us what proportion of the total variation is explained by the teaching method:
$$ \eta^2 = \frac{SS_B}{SS_T} = \frac{512}{566} = 0.90 $$
Ninety per cent is enormous; real classroom data typically give values between .01 and .20. Cohen's rough guide treats .01 as small, .06 as medium and .14 as large.
Step 7: Post Hoc Comparisons
A significant F only says "at least one mean differs." To find which, use Tukey's Honestly Significant Difference (HSD). With \( q = 3.95 \) from the studentised range table (3 groups, 9 df):
$$ HSD = q\sqrt{\frac{MS_W}{n}} = 3.95\sqrt{\frac{6}{4}} = 3.95 \times 1.225 = 4.84 $$
Any pair of means differing by more than 4.84 is significantly different:
- C − A = 8 (significant)
- A − B = 8 (significant)
- C − B = 16 (significant)
So the software-based method beats the lecture method, which in turn beats self-study.
The ANOVA Summary Table
| Source | SS | df | MS |
|---|---|---|---|
| Between groups | 512 | 2 | 256 |
| Within groups | 54 | 9 | 6 |
| Total | 566 | 11 |
This is the layout SPSS produces, with F = 42.67 and Sig. < .001 in extra columns.
Writing It Up in APA Style
A one-way ANOVA showed a significant effect of teaching method on test scores, F(2, 9) = 42.67, p < .001, η² = .90. Tukey HSD post hoc tests indicated that the software-based group (M = 81.00, SD = 2.58) scored significantly higher than the lecture group (M = 73.00, SD = 2.58), which scored significantly higher than the self-study group (M = 65.00, SD = 2.16), all ps < .05.
Running ANOVA in Software
- SPSS: Analyze → Compare Means → One-Way ANOVA, tick Descriptives, Homogeneity of variance and Tukey under Post Hoc.
- Stata:
oneway score method, tabulate. - Excel: Data Analysis ToolPak → ANOVA: Single Factor (no post hoc tests).
- R:
r
model <- aov(score ~ method, data = df)
summary(model)
TukeyHSD(model)
Beyond One-Way ANOVA
- Two-way ANOVA: two factors at once (e.g. teaching method and gender), including their interaction.
- Repeated-measures ANOVA: the same participants measured three or more times.
- ANCOVA: compares groups while controlling for a covariate such as pre-test scores.
- Kruskal–Wallis test: the non-parametric alternative when assumptions fail badly.
Did You Know?
- The F statistic is named in honour of Fisher; the name was proposed by George Snedecor in the 1930s.
- A one-way ANOVA with exactly two groups gives \( F = t^2 \), identical to the pooled independent t-test.
- ANOVA is a special case of linear regression with dummy-coded group variables.
Key Takeaways
- Use ANOVA, not multiple t-tests, when comparing three or more group means.
- F compares between-group variation with within-group variation; values near 1 suggest no effect.
- A significant F must be followed by post hoc tests such as Tukey HSD.
- Always report F, both df values, p and an effect size such as η².
Stuck on an ANOVA for your thesis or coursework? Get a clear, step-by-step solution from Amathify's experts and PhD scholars by messaging us on WhatsApp or using the Ask a Question form.
Stuck on a problem or assignment?
Our experts and PhD scholars solve maths, physics and chemistry — step by step.