Two-Way ANOVA Practice: Attention and Age

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

Part 1: Setup and Visualization

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)
  1. Confirm the design is balanced. How many cells are there, and how many participants per cell?

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)
  1. Look at the interaction plot. Do the lines look roughly parallel, or do they diverge? What would each pattern mean?

Part 2: Running the Two-Way ANOVA

model <- aov(reaction_time ~ attention_condition * age_group, data = data)

# Check assumptions
shapiro.test(residuals(model))
plot(model, which = 2)

# ANOVA table
summary(model)
  1. Report all three F-tests (attention condition, age group, and the interaction) with df, F, and p. Which are significant at α = .05?
  2. Was the interaction significant? If so, per the chapter’s own rule, how should that change the way you interpret the two main effects?

Part 3: Effect Sizes and Follow-up

library(effectsize)
eta_squared(model, partial = TRUE)

aggregate(reaction_time ~ attention_condition + age_group, data = data, FUN = mean)
  1. Report partial η² for all three effects. Effect sizes are reported regardless of significance — classify each as small, medium, or large by the course’s conventions (.01 / .06 / .14).

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")
  1. Within the older group, is there any pair of attention conditions that does not significantly differ? Within the younger group, are all six pairwise comparisons significant? What does this difference tell you about the interaction?

Part 4: Reporting

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.

  1. A classmate writes: “Older adults were significantly slower than younger adults across the board.” Using your simple-effects results, is this statement fully accurate? If not, what qualification is missing?