← Course home
MODULE 10 · FIRST-YEAR LEVEL

Comparing three or more groups: ANOVA

How can we compare several means at once?

70–90 minutesConcepts first, R optionalSynthetic data

Learning outcomes

Conceptual lesson

One-way ANOVA tests a null hypothesis that three or more group means are equal, comparing variation within groups to variation between groups. Its F statistic is a ratio of variance components. A statistically detectable overall difference does not by itself tell us which groups differ.

Consider independent observations, the error structure and group variances. Welch ANOVA may be suitable under unequal variances. Follow-up pairwise comparisons, such as Tukey's procedure, can address multiplicity; avoid choosing tests after seeing desirable results.

Start with group distributions and means. Effect sizes such as eta-squared quantify how much observed variation is associated with grouping in the model, not a causal effect. The fictional group labels are not interventions.

Worked research example

Plot fictional `score_post` values for groups A, B and C, then run `aov()`. Make explicit that groups are observational labels rather than randomly assigned interventions.

Common reasoning trap

“ANOVA was significant, so every group differs from every other group” is incorrect. The omnibus test may indicate at least one difference.

Independent practice

  1. State the null and alternative hypotheses for a one-way ANOVA.
  2. Interpret group summaries, boxplot and ANOVA together.
  3. Explain when follow-up comparisons are appropriate and why causal interpretation is limited.

Explain your reasoning, not only the number.

Optional R lab

Save the synthetic CSV in the working folder before running the script. Base R only.

CSV · Download R script

# Statistics Lab / ferdo — synthetic data (no real student records)
# Save stats_synthetic.csv in your working directory.
d <- read.csv("stats_synthetic.csv", stringsAsFactors = TRUE)
stopifnot(nrow(d) == 36, all(c("score_pre","score_post","group") %in% names(d)))
# Groups are observational labels: differences cannot establish a treatment effect.

boxplot(score_post ~ group, data=d, ylab="Post-quiz score")
fit <- aov(score_post ~ group, data=d)
summary(fit)
TukeyHSD(fit)
oneway.test(score_post ~ group, data=d) # Welch ANOVA

Stretch: mathematical track

Compare Welch ANOVA with equal-variance ANOVA when group variances differ substantially.

Exit ticket

Write one defensible claim and one limitation from this week's example.

Student workbook for this module

Four written problems, marking guide and a formative four-question quiz.

Open week 10 workbook →