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 of 120 participants tests how attention condition and age group affect reaction time on a cognitive task. This is teaching data (simulated for this course), not a published study — treat the findings as practice, not as evidence about real attentional aging effects.
| Variable | Description | Type |
|---|---|---|
attention_condition |
Focused, divided, selective, or sustained attention task | Factor (4 levels) |
age_group |
Younger or older adult | Factor (2 levels) |
reaction_time |
Reaction time in ms | Numeric (continuous) |
data <- read.csv("https://jkoxford-a11y.github.io/awesomesaucestats/data/attention_study.csv")15 participants per cell, 120 total — a fully balanced 4 × 2 design.
str(data)
data$attention_condition <- as.factor(data$attention_condition)
data$age_group <- as.factor(data$age_group)
table(data$attention_condition, data$age_group)Predict before you plot. Which attention condition do you expect to produce the slowest reaction times? Do you expect older or younger adults to be slower overall? Do you expect the age gap to be roughly the same across all four conditions, or different for some conditions than others?
library(ggplot2)
ggplot(data, aes(x = attention_condition, y = reaction_time, color = age_group, group = age_group)) +
stat_summary(fun = mean, geom = "line", linewidth = 1) +
stat_summary(fun = mean, geom = "point", size = 3)model <- aov(reaction_time ~ attention_condition * age_group, data = data)
# Check assumptions
shapiro.test(residuals(model))
plot(model, which = 2)
# ANOVA table
summary(model)library(effectsize)
eta_squared(model, partial = TRUE)
aggregate(reaction_time ~ attention_condition + age_group, data = data, FUN = mean)Because the interaction is significant here, a straight
TukeyHSD() on the main effects would blur together a
pattern that actually differs by age group. Use simple effects
instead:
library(emmeans)
emmeans(model, pairwise ~ attention_condition | age_group, adjust = "tukey")Write a complete APA-style paragraph reporting this two-way ANOVA, using the Ch 18 reporting checklist: both main effects with df/F/p/partial η², the interaction with the same, cell means, and — since the interaction is significant — a description of the simple-effects follow-up rather than a flat statement about the main effects alone.