Repeated-Measures ANOVA Practice: Reaction Time Across the Day

A note on AI tools: You may use AI assistants (ChatGPT, Claude, etc.) to help debug your R code — that’s a realistic professional skill. You may not use AI to generate your interpretations. Every write-up sentence must reflect your own reading of the output. If you use AI for any part of this assignment, note where at the end.

The dataset

A simulated study measures 120 participants’ reaction time on the same cognitive task at three points in the same day: morning, afternoon, and evening. This is teaching data (simulated for this course), not a published study.

Variable Description Type
participant_id Subject identifier Factor (ID, not a factor of interest)
time_of_day Morning, afternoon, or evening Factor (3 levels, within-subject)
reaction_time Reaction time in ms Numeric (continuous)
data <- read.csv("https://jkoxford-a11y.github.io/awesomesaucestats/data/attention_rm.csv")

The data are already in long format — one row per participant per time point (360 rows: 120 participants × 3 times).

Part 1: Setup

str(data)
data$time_of_day <- factor(data$time_of_day, levels = c("morning", "afternoon", "evening"))
data$participant_id <- as.factor(data$participant_id)
table(data$time_of_day)
  1. Confirm each time point has the same number of observations. Why does that number equal the number of participants, not something smaller?

Predict before you compute. Do you expect reaction time to get faster, slower, or stay about the same across the day? Write your prediction down.

aggregate(reaction_time ~ time_of_day, data = data, FUN = mean)
aggregate(reaction_time ~ time_of_day, data = data, FUN = sd)
  1. Report the mean and SD reaction time at each time point. How does this compare to your prediction?

Part 2: Why This Needs Repeated-Measures ANOVA, Not aov()

  1. A classmate suggests just running aov(reaction_time ~ time_of_day, data = data), since it’s one outcome and one factor. Explain, in your own words, why this is the wrong tool for this dataset even though the formula would run without error.

Part 3: Running the Repeated-Measures ANOVA

library(afex)
model <- aov_ez(
  id = "participant_id",
  dv = "reaction_time",
  within = "time_of_day",
  data = data
)
summary(model)
  1. Report the F-statistic, both df, and the p-value for the effect of time_of_day.
  2. afex reports a Mauchly’s test for sphericity in the full output. Is sphericity violated here (is Mauchly’s test significant)? If so, which correction does afex apply automatically, and do you need to do anything about it yourself?

Part 4: Effect Size and Follow-up

# Generalized eta-squared (ges) is already in the summary(model) table above.

library(emmeans)
emmeans(model, pairwise ~ time_of_day, adjust = "tukey")
  1. Report generalized η² (ges). Classify it as small, medium, or large by the course’s conventions, and report it regardless of the result’s significance.
  2. Look at the standard errors on the three pairwise contrasts (morning–afternoon, morning–evening, afternoon–evening). They should look very small relative to the SDs you reported in Part 1. Explain why: what does a small within-person contrast SE tell you about how consistent each individual’s own change across the day was, and how does that connect to the “why pairing matters” argument from the paired t-test chapter?

Part 5: Reporting

Write a complete APA-style paragraph reporting this one-way repeated-measures ANOVA: the F-test with df and p, generalized η², whether a sphericity correction was needed, and the pattern of pairwise differences.

  1. This chapter also covers mixed ANOVA (a between-subjects factor combined with a within-subjects factor). This dataset doesn’t have a between-subjects factor. What variable would need to be added to this dataset to turn this into a mixed-ANOVA analysis, and what new question would that let you ask?