2025

Introduction

  • One-way ANOVA (Analysis of Variance) is used to determine if there are any differences between the means of at least two (but usually three or more) independent groups based on one categorical independent variable.

  • A one-way repeated measures ANOVA is used to test for differences in the means of two or more groups when observations from that group are obtained from the same subjects.

Between-subjects versus within-subjects factors

  • All the same trade-offs we described for t-tests also apply here.

  • Advantage: individual differences possibly reduced as a source of between-group differences.

  • Advantage: sample size is not divided between conditions so can require fewer subjects.

  • Disadvantage: fewer subjects \(\rightarrow\) smaller degrees of freedom \(\rightarrow\) higher / fatter tails \(\rightarrow\) less power.

Intuition for repeated measures ANOVA

  • The intuition for a repeated measures ANOVA is the same as that for a factorial ANOVA.

  • If the means are all the same (i.e., \(H_0\) is true), then between-group and within-group variation will be very similar.

  • Between-level variability is smaller in a repeated measures design because subjects tend to be similar to themselves.

  • Thus, we require less between-level differences in variability for repeated measures designs than for independent samples designs.

  • One-way ANOVA:

    \[F = \frac{MS_{between-levels}}{MS_{within-levels}}\]

  • One-way repeated measures ANOVA:

    \[F = \frac{MS_{between-levels}}{MS_{within-levels} - MS_{between-subjects}}\]

Formal treatment

  • \(k\) is the number of factor levels
  • \(n\) is the number of subjects
  • \(x_{ij}\) is observation from factor level \(i\) and subject \(j\)

\[ \begin{align} SS_{between-levels} &= n \sum_{i=1}^k (\bar{x_{i \bullet}} - \bar{x_{\bullet \bullet}})^2 \\ SS_{within-levels} &= \sum_{i=1}^k \sum_{j=1}^n (x_{ij} - \bar{x_{i \bullet}})^2 \\ SS_{between-subject} &= k \sum_{j=1}^n (\bar{x_{\bullet j}} - \bar{x_{\bullet \bullet}})^2 \\ SS_{error} &= SS_{within-levels} - SS_{between-subject} \\ \end{align} \]

  • The nomenclature \(SS_{error}\) will make more sense in the coming lectures.

One-Way ANOVA Table (for independent groups)

Source Df SS MS F P(>F)
Between groups \(k-1\) see above \(\frac{SS_{between}}{Df_{between}}\) \(\frac{MS_{between}}{MS_{within}}\)
Within groups \(N-k\) see above \(\frac{SS_{within}}{Df_{within}}\)
Total \(N-1\) see above

One-Way Repeated Measures ANOVA Table

Source Df SS MS F P(>F)
Within-subjects \(k-1\) see above \(\frac{SS_{within}}{Df_{within}}\) \(\frac{MS_{within}}{MS_{error}}\)
Error \((k-1)(n-1)\) see above \(\frac{SS_{error}}{Df_{error}}\)
Total \(nk-1\) see above

Repeated measures ANOVA data

##      level subject     score
##     <fctr>  <fctr>     <num>
##  1:      1       1 11.262954
##  2:      1       2  9.673767
##  3:      1       3 11.329799
##  4:      1       4 11.272429
##  5:      1       5 10.414641
##  6:      2       1 18.460050
##  7:      2       2 19.071433
##  8:      2       3 19.705280
##  9:      2       4 19.994233
## 10:      2       5 22.404653
## 11:      3       1 30.763593
## 12:      3       2 29.200991
## 13:      3       3 28.852343
## 14:      3       4 29.710538
## 15:      3       5 29.700785

Repeated measures ANOVA using ez

## Use the function `ezANOVA()` from the `ez` package to
## perform a repeated measures ANOVA
d[, subject := factor(subject)]
d[, level := factor(level)]
aov_res <- ezANOVA(
  data=d, ## where the data is located
  dv=score, ## the dependent variable
  wid=subject, ## the repeated measure indicator column
  within = .(level), ## a list of repeated measures factors
  type = 3 ## type of sums of squares desired
)

## $ANOVA
##   Effect DFn DFd        F            p p<.05      ges
## 2  level   2   8 370.7886 1.297461e-08     * 0.985266
## 
## $`Mauchly's Test for Sphericity`
##   Effect         W         p p<.05
## 2  level 0.5279246 0.3835816      
## 
## $`Sphericity Corrections`
##   Effect      GGe        p[GG] p[GG]<.05       HFe        p[HF] p[HF]<.05
## 2  level 0.679313 2.305263e-06         * 0.9073176 5.770786e-08         *

Reporting the results

We performed a one-way repeated measures ANOVA to examine the effect of the factor “level” on the dependent variable. This analysis revealed a significant main effect of the factor “level” (\(F(2, 8) = 370.79, p < .001, \eta^2 = .985\)). The effect size, as measured by generalized eta-squared, indicated that approximately 98.5% of the variance in the dependent variable could be attributed to the effect of level, suggesting a strong effect.

Mauchly’s test for sphericity was conducted to examine the assumption of sphericity in the repeated measures design. The test was not significant (\(W = 0.528, p = .384\)), indicating that the assumption of sphericity was not violated for the factor “level.” As such we above reported the results without any sphericity correction.

Repeated measure ANOVA assumptions

  1. Independence: Observations must be independent between subjects.

    • Repeated measures violate independence within subjects, and this is accounted for in the model.
  2. Normality: The residuals (i.e., differences between observed values and condition means) are assumed to be normally distributed within each level of the within-subject factor.

  3. Sphericity: The variances of the pairwise differences between all levels of the within-subject factor must be equal.

    • This is a stronger assumption than homogeneity of variance.
    • Violations can be detected via Mauchly’s test, and corrected using Greenhouse-Geisser or Huynh-Feldt adjustments.

Homogeneity of Variance versus sphericity

  • Homogeneity of Variance: Assumes equal variances across groups in between-subjects designs.
    • Applies when comparing independent groups.
  • Sphericity: Assumes equal variances of the pairwise differences among levels of a within-subjects factor.
    • Specific to repeated measures or within-subjects ANOVA.
  • The distinction reflects both:
    • The type of factor: between vs within subjects,
    • The nature of the assumption: variances vs variances of differences
  • In a one-way repeated measures ANOVA, homogeneity of variance is not relevant, because all comparisons are within subjects. Instead, sphericity is the key assumption.

Sphericity is about differences

Mauchly’s Test for Sphericity and Sphericity Corrections

  • We won’t cover these in detail in this unit.

  • Rather, we just trust that ez will do the right thing for us.

  • If sphericity is violated, the ez package will automatically apply a correction to the degrees of freedom.

  • The correction is what you should report – if sphericity is violated – if you use this analysis in a paper.

Balance and types of sums of squares

  • Different types of sums of squares only produce different results when the design is unbalanced.

  • We will keep it simple: Always use type III sums of squares for every kind of ANOVA we cover in this unit.

Question

The plot below shows the variances of pairwise differences among three within-subject conditions (A, B, C) in a repeated measures design.

What assumption of repeated measures ANOVA does this violate?

This plot shows unequal variances of the pairwise differences among within-subject conditions, which violates the sphericity assumption. Sphericity requires these variances to be approximately equal. If violated, the F-test for the within-subject factor may be invalid unless corrected (e.g., using Greenhouse-Geisser).

Question

Below are histograms of observed scores from three within-subject conditions in a repeated measures experiment.

What assumption might be violated, and why is it relevant?

The histogram for Condition B shows strong skewness, suggesting a violation of the normality assumption. In repeated measures ANOVA, normality of residuals (equivalent to normality of scores within each condition) is assumed. This could affect validity, especially with small sample sizes.

Question

The plot below shows the spread of scores across three conditions in a repeated measures design. It looks like one condition has a higher variance.

Does this violate a core assumption of repeated measures ANOVA?

Although the variances differ across conditions, this is not a violation of homogeneity of variance, which applies only to between-subjects designs. In repeated measures ANOVA, the key assumption is sphericity, not equal variances across conditions. The assumption we’d need to test is whether the variances of pairwise differences are equal.