← Back to modules

Analysis of Variance

One-way ANOVA, the F-test, multiple comparisons, and two-way ANOVA.

ANOVA extends the two-sample tt-test to compare three or more group means simultaneously. Running multiple tt-tests would inflate the Type I error rate; ANOVA controls it with a single FF-test.

The key insight is partitioning total variability: ANOVA asks whether the variability between groups is large relative to the variability within groups. If yes, at least one mean differs.

One-way ANOVA handles one categorical factor; two-way ANOVA handles two factors and can detect interactions between them.

One-way ANOVA

One-way ANOVA tests H0:μ1=μ2==μkH_0: \mu_1 = \mu_2 = \cdots = \mu_k (all kk group means are equal) against HaH_a: at least one pair of means differs. It replaces the multiple tt-test approach, which would inflate the Type I error rate.

Partitioning variability: SStotal=SSbetween+SSwithinSS_{\text{total}} = SS_{\text{between}} + SS_{\text{within}}. SSbetween=jnj(xˉjxˉ)2SS_{\text{between}} = \sum_j n_j(\bar{x}_j - \bar{x})^2 measures how much group means vary around the grand mean. SSwithin=ji(xijxˉj)2SS_{\text{within}} = \sum_j \sum_i (x_{ij}-\bar{x}_j)^2 measures variability within each group.

The FF-statistic: F=MSbetween/MSwithinF = MS_{\text{between}}/MS_{\text{within}} where MS=SS/dfMS = SS/df. dfbetween=k1df_{\text{between}} = k-1, dfwithin=Nkdf_{\text{within}} = N-k (total observations NN, groups kk). Under H0H_0, FFk1,NkF \sim F_{k-1,\,N-k}.

Interpretation: a large FF means the between-group variation is large relative to within-group noise — the group means differ more than chance would predict. Reject H0H_0 if F>Fα,k1,NkF > F_{\alpha, k-1, N-k} (critical value from FF-table).

The ANOVA table summarises the decomposition: Source, SS, df, MS, FF, pp-value. Each row represents one source of variability.

Helpful?

Assumptions of ANOVA

Independence: all observations are independent within and across groups. Violated by repeated measures on the same subjects (use repeated-measures ANOVA instead).

Normality: each group's population is approximately normally distributed. ANOVA is robust to moderate violations when group sizes are equal and nj5n_j \geq 5. Check with Q-Q plots of residuals.

Homoscedasticity (equal variances): all groups share the same variance σ2\sigma^2. Check with Levene's test or by comparing the largest to smallest sample standard deviation (ratio 2\leq 2 is a common rule of thumb). Welch's one-way ANOVA does not require equal variances.

If assumptions are seriously violated, consider transforming the data (e.g., log-transform for right-skewed data) or using the Kruskal-Wallis test (the non-parametric alternative to one-way ANOVA).

Helpful?

Post-hoc tests and multiple comparisons

A significant FF-test tells you at least one mean differs — not which pairs. Post-hoc tests identify specific differences while controlling the family-wise error rate (FWER).

Tukey's HSD (Honest Significant Difference): tests all (k2)\binom{k}{2} pairwise comparisons and controls the FWER at α\alpha exactly. It is the most commonly used post-hoc method for balanced designs.

Bonferroni correction: for mm comparisons, use α/m\alpha/m for each test. Simple and widely applicable, but more conservative (lower power) than Tukey's when mm is large.

Scheffé's method: allows any contrast (not just pairwise) while controlling FWER. Most conservative but most flexible.

Planned contrasts: if specific comparisons are hypothesised in advance (before seeing data), they can be tested at level α\alpha without correction. Only pre-specified comparisons qualify.

Helpful?

Two-way ANOVA

Two-way ANOVA has two categorical factors AA (with aa levels) and BB (with bb levels). It tests three hypotheses: the main effect of AA, the main effect of BB, and the A×BA\times B interaction.

An interaction A×BA\times B means the effect of AA on the response depends on the level of BB (and vice versa). When an interaction is significant, interpret main effects cautiously — they may be misleading averages of varying effects.

The total SS is partitioned: SStotal=SSA+SSB+SSAB+SSerrorSS_{\text{total}} = SS_A + SS_B + SS_{AB} + SS_{\text{error}}. Each has an associated FF-ratio and pp-value.

Two-way ANOVA with replication (more than one observation per cell) is needed to estimate SSerrorSS_{\text{error}} and test the interaction. Without replication, you must assume no interaction exists.

Balanced designs (equal cell sizes) simplify computation and interpretation; unbalanced designs require more care with the order of entering terms (Type I vs. Type III sums of squares).

Helpful?