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.
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).
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)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)aov()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.library(afex)
model <- aov_ez(
id = "participant_id",
dv = "reaction_time",
within = "time_of_day",
data = data
)
summary(model)time_of_day.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?# Generalized eta-squared (ges) is already in the summary(model) table above.
library(emmeans)
emmeans(model, pairwise ~ time_of_day, adjust = "tukey")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.