2024

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 within each group must be independent of each other.

  2. Normality: The raw data random variables must be normally distributed for all factors.

  3. Sphericity: The variances of the differences between all possible pairs of within-subject factors must be equal.

Homogeneity of Variance versus sphericity

  • Homogeneity of Variance: Equality of variances across between-subjects factors.

  • Sphericity: Equality of variances of the pairwise differences among within-subjects factors.

  • The distinction is one of within- vs between-subjects factors and also one of pairwise differences vs direct differences.

  • In a repeated measure one-way ANOVA homogeneity of variance is not an issue because we are comparing differences within subjects.

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 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.