Cambridge/Humboldt Dataset 4: Reshaping and Mixed ANOVA (Full Dataset)

Setup

Run the standard setup from the Student Overview before starting this assignment. This assignment uses the full cam dataset — all four match × sex groups — not the 1v1-women subset from Assignments 1–3.

Research Question

Does testosterone’s response to winning or losing depend on whether someone competed 1v1 or 2v2, and on their sex?

This is the actual research question the Cambridge/Humboldt study was designed to answer. It requires three between-subjects factors (win, match, sex) crossed with one within-subjects factor (time) — a mixed ANOVA, the same design introduced in @sec-anova-repeated-mixed and Chapter 31, now run on the complete dataset instead of one condition at a time.

Variables

Variable Meaning Type
t1, t2, t3 Testosterone before, immediately after, and ~20 min after the contest Quantitative (repeated)
win Loss / Win Categorical (between-subjects)
match 1v1 / 2v2 Categorical (between-subjects)
sex Female / Male Categorical (between-subjects)

Decision Point 1: Why Reshape?

  1. Right now, each subject has one row with t1, t2, t3 as separate columns. What is this format called?
  2. A mixed ANOVA needs one row per subject per time point, with a single hormone column and a time column indicating which time point that row is. What is this format called?
  3. Why can’t aov_ez() (or any repeated-measures function) work directly on the wide format?

Question 1: Reshape to Long Format

library(tidyverse)

cam_reshape <- cam %>%
  select(subject, win, match, sex, t1, t2, t3, e1, e2, e3, p1, p2, p3, c1, c2, c3)

long_df <- pivot_longer(
  cam_reshape,
  cols = -c(subject, win, match, sex),
  names_to = c(".value", "time"),
  names_pattern = "([a-z])([1-3])"
)
long_df$time <- as.numeric(long_df$time)

head(long_df)
str(long_df)

This is the same .value reshape trick from Chapter 31 — the lowercase hormone letter becomes a column name, and the digit becomes time. The difference here is that win, match, and sex all carry over as between-subjects columns, since we’re now using every condition instead of just one.

Question 2: Mixed ANOVA on Testosterone

library(afex)
library(emmeans)

long_df$subject <- as.factor(long_df$subject)
long_df$time    <- as.factor(long_df$time)

model_t <- aov_ez(
  id = "subject",
  dv = "t",
  between = c("win", "match", "sex"),
  within  = "time",
  data = long_df
)

summary(model_t)

This model tests every main effect (win, match, sex, time) and every interaction between them, including the three-way win:match:sex interaction and its interaction with time — the four-way win:match:sex:time interaction is the one this whole study was designed to detect.

Questions

  1. Is there a significant main effect of sex on testosterone? Given what you know about male versus female testosterone levels biologically, is this surprising?
  2. Is the four-way win:match:sex:time interaction significant? What would a significant four-way interaction mean in plain language — that the win/loss effect on testosterone over time depends on what, exactly?

Question 3: Visualize the Interaction

An ANOVA table with a significant four-way interaction is hard to interpret from numbers alone. Visualize it directly:

ggplot(long_df, aes(x = time, y = t, color = win, group = win)) +
  stat_summary(fun = mean, geom = "line", linewidth = 1) +
  stat_summary(fun = mean, geom = "point", size = 2) +
  facet_grid(match ~ sex) +
  labs(x = "Time Point", y = "Mean Testosterone (transformed)",
       title = "Testosterone Across Time by Win/Loss, Match Type, and Sex")

Questions

  1. Look at the four panels. In which panel(s) does the winner line stay relatively higher (or decline less) than the loser line across time?
  2. Does the pattern look similar across all four panels, or does it genuinely differ by match type and sex?
  3. The published paper based on this dataset (Oxford et al., 2017, PLOS ONE) reported that men competing 1v1 and women competing as 2v2 teams showed a similar testosterone pattern after winning. Does your plot show any hint of that specific pattern?

A note on matching the published result exactly: The original paper analyzed hormone change using repeated-measures ANCOVA with baseline hormone (T1) as a covariate, rather than a plain mixed ANOVA on the raw repeated values as you just ran. Controlling for baseline this way corrects for chance imbalances between groups at T1 (which can happen even with random assignment) — a technique beyond this course’s scope. Your mixed ANOVA should show the same qualitative interaction pattern, but don’t expect your exact F values or the visual pattern to line up perfectly with the published figures.

Your Turn: Repeat for Another Hormone

Repeat Question 2 and Question 3 using cortisol (c) instead of testosterone. The published paper found a different pattern for cortisol than for testosterone — cortisol was differentially associated with outcome specifically in the team matches.

Effect F df p ges
win
match
sex
win:match:sex:time

Scientific Report

A mixed ANOVA was conducted on testosterone with win/loss, match type, and sex as between-subjects factors and time as a within-subjects factor. [Describe the significant effects you found, using generalized eta-squared (ges) as the effect size, and describe the four-way interaction in plain language if significant.]

What Can and Can’t We Conclude?

  1. Win/loss was experimentally assigned. What does that let us conclude about causality for the win effect that we couldn’t conclude for, say, the pill variable in Assignment 2?
  2. sex and match (whether someone signed up for/was assigned to a 1v1 or 2v2 session) were not randomly assigned to participants in the same causal sense as win. How does that change what we can conclude about why the pattern differs across sex or match type?
  3. Why does a four-way interaction require more caution in interpretation than a simple two-group difference — both statistically (power to detect it) and conceptually (how many “if…then…but only when…” conditions is this claim really making)?