Hypothesis TestingTopic #29 of 33

Analysis of Variance (ANOVA)

Comparing multiple group means: F-statistic, between and within group variance.

Overview

ANOVA tests whether the means of three or more groups are significantly different. It compares variance between groups to variance within groups.

One-Way ANOVA

Hypotheses

  • H0H_0: μ1=μ2=μ3==μk\mu_1 = \mu_2 = \mu_3 = \cdots = \mu_k (all means equal)
  • H1H_1: At least one mean is different

The F-Statistic

F=MSBMSW=Between-group varianceWithin-group varianceF = \frac{MSB}{MSW} = \frac{\text{Between-group variance}}{\text{Within-group variance}}

Large FF → Evidence of differences between groups

ANOVA Table

SourceSSdfMSF
BetweenSSBk1k - 1MSB=SSBk1MSB = \frac{SSB}{k-1}MSBMSW\frac{MSB}{MSW}
WithinSSWNkN - kMSW=SSWNkMSW = \frac{SSW}{N-k}
TotalSSTN1N - 1

Where:

  • kk = number of groups
  • NN = total number of observations

Sum of Squares Formulas

Total Sum of Squares

SST=(xijxˉ)2SST = \sum (x_{ij} - \bar{x})^2

Between-Group Sum of Squares

SSB=ni(xˉixˉ)2SSB = \sum n_i (\bar{x}_i - \bar{x})^2

Within-Group Sum of Squares

SSW=(xijxˉi)2SSW = \sum \sum (x_{ij} - \bar{x}_i)^2

Relationship

SST=SSB+SSWSST = SSB + SSW

Assumptions

  1. Independence of observations
  2. Normal distributions in each group
  3. Equal variances (homogeneity of variance)

Example

Three teaching methods, student scores:

Method AMethod BMethod C
85, 90, 7892, 88, 9575, 70, 80
n1=3n_1 = 3n2=3n_2 = 3n3=3n_3 = 3
xˉ1=84.33\bar{x}_1 = 84.33xˉ2=91.67\bar{x}_2 = 91.67xˉ3=75\bar{x}_3 = 75

Grand mean: xˉ=85+90+78+92+88+95+75+70+809=83.67\bar{x} = \frac{85+90+78+92+88+95+75+70+80}{9} = 83.67

SSB=3(84.3383.67)2+3(91.6783.67)2+3(7583.67)2SSB = 3(84.33-83.67)^2 + 3(91.67-83.67)^2 + 3(75-83.67)^2 =3(0.44)+3(64)+3(75.11)=1.32+192+225.33=418.65= 3(0.44) + 3(64) + 3(75.11) = 1.32 + 192 + 225.33 = 418.65 SSW=(8584.33)2+(9084.33)2+(7884.33)2+=170.67SSW = (85-84.33)^2 + (90-84.33)^2 + (78-84.33)^2 + \cdots = 170.67 MSB=418.652=209.33MSB = \frac{418.65}{2} = 209.33 MSW=170.676=28.44MSW = \frac{170.67}{6} = 28.44 F=209.3328.44=7.36F = \frac{209.33}{28.44} = 7.36

Critical F0.05,2,6=5.14F_{0.05, 2, 6} = 5.14

7.36>5.147.36 > 5.14 \Rightarrow Reject H0H_0

At least one teaching method differs significantly.

Post-Hoc Tests

If ANOVA rejects H0H_0, use post-hoc tests to identify which pairs differ:

TestUse Case
Tukey's HSDAll pairwise comparisons
BonferroniFew specific comparisons
SchefféComplex comparisons
Fisher's LSDLiberal, more Type I error

Effect Size: Eta-Squared

η2=SSBSST\eta^2 = \frac{SSB}{SST}
η2\eta^2Interpretation
0.01Small
0.06Medium
0.14Large

Two-Way ANOVA

For two factors (A and B):

SST=SSA+SSB+SSAB+SSWSST = SS_A + SS_B + SS_{AB} + SSW

Tests:

  • Main effect of Factor A
  • Main effect of Factor B
  • Interaction effect (A×BA \times B)

Assumptions Check

  • Normality: Shapiro-Wilk test, Q-Q plots
  • Equal variances: Levene's test, Bartlett's test

When to Use

SituationTest
2 groupst-test
3+ groupsOne-way ANOVA
2 factorsTwo-way ANOVA
Repeated measuresRepeated measures ANOVA