Atlas
statminds
ANOVAThe underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Within-Within Subjects ANOVA

Two or more within-subjects (repeated) factors analyzed simultaneously (e.g., Time × Condition)..

Model familyANOVA
Hypothesisomnibus
AliasesTwo-way repeated measures ANOVA · Fully within-subjects factorial ANOVA · Repeated measures factorial ANOVA
G1
association
G2
description
Visual Overview Dashboard
1

What is it?

Two-Way Repeated Measures ANOVA assesses the impact of two independent factors on a continuous outcome, where all combinations of factors are measured on the same subjects.

2

When to use it

  • 2 Within Factors: (e.g., Time [Pre/Post] and Drug [A/B]).
  • Outcome: Continuous scale variable.
  • Single Group: Every subject goes through all 4 test cells.
3

Core Idea

We map how subjects react to both factors simultaneously. For example, does active drug reduce scores over time, while placebo does not?

Pre-TestPost-TestPlaceboActive

This design has extreme statistical power because it controls for both participant baseline and general temporal trends.

4

Hypotheses

H₀(Time): Mean scores are equal Pre vs Post.
H₀(Drug): Mean scores are equal Drug vs Placebo.
H₀(AxB): Drug effect is identical Pre vs Post.
5

How it works

Calculates distinct error terms for each test:
- Time tested against $Time \times Subjects$
- Drug tested against $Drug \times Subjects$
- Interaction tested against $Time \times Drug \times Subjects$

6

Assumptions

📈 Normality: Normality within each of the 4 conditions.
🔮 Sphericity: Equicorrelated pairwise differences.
No Carryover: Washout period between trials.
7

Important Note

Carryover effects (fatigue, learning) are the biggest threat. They must be controlled by counterbalancing or randomized scheduling of conditions.

8

Quick Example

Subj / timeActive PreActive PostPlacebo Pre
Subj 152.381.050.1
Subj 241.458.242.8
Interactive Sandbox

Two-Way RM ANOVA Live Laboratory

Adjust Time, Treatment, and Interaction values to observe how repeated measures handle multi-factor data.

Presets
Factor A Effect (Time)0
Factor B Effect (Drug)0
AxB Interaction0
Subject baseline Spread10
Residual Noise (σ)5
Repeated Profile (Grey: Subject paths Control vs Active over Time)Y-Axis: Outcome Score
20406080Active DrugPlaceboTime: Pre-TestTime: Post-Test
Two-Way RM ANOVA Table
SourceSSdfFp-value
Factor A (Time)0.010.001.0000
Factor B (Drug)0.010.001.0000
Interaction (AB)0.010.001.0000
Error (Residual)525.021--
Statistical Verdict
Time Effect (Factor A): ❌ Not Sig.
Drug Effect (Factor B): ❌ Not Sig.
Interaction (AxB): ❌ NO Interaction
No interaction. Both treatment paths run parallel over time.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

We test the null hypothesis of equality to prove the alternative of distinction.
Logic Core
Null · H₀

H₀: No main effects or interaction exist for the two within-subjects factors (all condition means are equal after controlling for individual differences)

Alternative · Hₐ

Hₐ: At least one main effect or interaction exists between the two within-subjects factors

Why it matters omnibus

Tests 3 effects: Main effect A, Main effect B, and A×B interaction. All effects are within-subjects, requiring sphericity assumption. Repeated measures on same participants increases power by removing between-subjects variance.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Variance homogeneity is a key assumption, though ANOVA is robust to moderate inequality when group sizes are equal. Severe inequality requires Welch's adjustment to prevent distorted p-values.
Integrity Shield
7
Assumptions
6
Critical / High Severity
How to check
Quick
Verify DV is numeric and not categorical; inspect range and measurement units
Rigorous
Check histograms and summary statistics across all repeated conditions; verify scale has equal intervals between values
If violated
If ordinal with many levels (7+) → proceed cautiously (RM-ANOVA somewhat robust). If few ordinal categories (e.g., Likert 1-5) → use Friedman test for single factor (no direct 2-way nonparametric equivalent) or ordinal mixed models. If binary → use generalized linear mixed model (GLMM) with binomial family. If count data → use Poisson or negative binomial GLMM with random intercepts for subjects
friedman
How to check
Quick
Verify each subject ID appears in all factor level combinations; check data is in long format with subject ID, factor A, factor B, and DV columns; count observations per subject (should equal n_levels_A × n_levels_B)
Rigorous
Create subject × condition matrix; confirm no missing cells (except true missingness); ensure design is fully within-subjects with no between-subjects factors
If violated
If one factor is between-subjects → use mixed/split-plot ANOVA (e.g., Time [within] × Group [between]). If only 1 within-subjects factor → use one-way RM-ANOVA. If 3+ within-subjects factors → use three-way RM-ANOVA (but complexity increases dramatically). If factors are continuous (not categorical) → use linear mixed model with continuous predictors and random slopes. If independent groups (not repeated measures) → use two-way between-subjects ANOVA
mixed anovalinear mixed model
How to check
Quick
Mauchly's test of sphericity for each main effect and interaction (p > .05 indicates sphericity holds). Must check separately for Factor A, Factor B, and A×B interaction
Rigorous
Compute variance-covariance matrix of repeated measures; check for compound symmetry or circularity; calculate epsilon (ε) for each effect: ε < .75 (severe violation), .75-.85 (moderate), > .85 (mild)
If violated
If Mauchly's p < .05 (sphericity violated): (1) BEST: Apply Greenhouse-Geisser correction (conservative, use when ε < .75) or Huynh-Feldt correction (less conservative, use when ε > .75) to adjust df and p-values for affected effects. (2) Use multivariate approach (MANOVA-style for each within-subjects effect, no sphericity assumption). (3) OPTIMAL: Use linear mixed model with unstructured or compound symmetry covariance structure (no sphericity assumption). NEVER report uncorrected F-tests when sphericity is violated—inflates Type I error substantially
linear mixed model
How to check
Quick
Compute difference scores for key contrasts (e.g., Time2 - Time1 for each condition); create Q-Q plots and histograms of these differences
Rigorous
Shapiro-Wilk test on difference scores for main contrasts (p > .05 indicates normality); check skewness (< |2|) and kurtosis (< |7|) of differences; test residuals from RM-ANOVA model
If violated
If mild violation with n ≥ 30: RM-ANOVA is fairly robust via Central Limit Theorem, proceed cautiously. If severe violation: (1) Transform DV (log for right-skew, sqrt for count data, Box-Cox for optimal transformation). (2) Use linear mixed model with robust standard errors. (3) Use permutation-based RM-ANOVA (resampling-based, distribution-free). (4) Use Friedman test for single factor (no 2-way equivalent). (5) Bootstrap confidence intervals for F-statistics. (6) Use rank-based aligned rank transform (ART) for factorial RM designs
linear mixed modelfriedman
How to check
Quick
Review study design: were conditions counterbalanced or randomized across subjects? Plot outcome by presentation order to check for systematic trends; test for order effects in pilot data
Rigorous
Include order as covariate or between-subjects factor; use Latin square or balanced counterbalancing designs; test Order × Condition interaction; check for practice/fatigue effects with learning curves
If violated
PROSPECTIVE FIX: (1) Use counterbalancing (Latin square, Williams design for 2 conditions, balanced incomplete blocks for 3+). (2) Include washout periods between measurements. (3) Randomize condition order across subjects. POST-HOC FIX: (1) Include presentation order as covariate in linear mixed model. (2) Test Order × Condition interaction—if significant, order effects present. (3) Model practice effects explicitly: include trial number as continuous predictor. (4) If severe contamination detected: report as limitation, cannot fully correct post-hoc
ancova
How to check
Quick
Check for NA/NaN values; count observations per subject—should equal n_levels_A × n_levels_B; identify subjects with incomplete data
Rigorous
Create missingness pattern matrix; test if data are missing completely at random (MCAR) using Little's test (p > .05); compute % missing per subject and per condition; check for systematic patterns in missingness
If violated
If < 5% missing and MCAR: (1) BEST: Use linear mixed model with restricted maximum likelihood (REML)—handles missing data automatically via maximum likelihood. (2) Multiple imputation (MI) with predictive mean matching, 20-40 imputations, then pool RM-ANOVA results. If > 5% missing or not MCAR: (3) Use mixed model with missingness model (selection models, pattern mixture models). (4) Sensitivity analysis with different imputation methods. NEVER use listwise deletion (removes entire subjects) or last-observation-carried-forward (LOCF—biases toward null)
linear mixed model
How to check
Quick
Verify each subject ID is unique; check for clustering (family members, students in same class, patients in same clinic)
Rigorous
Test for clustering structure; compute intraclass correlation (ICC) at subject level and potential cluster level; inspect recruitment procedures for dependent sampling
If violated
If subjects are clustered (e.g., students within schools, patients within clinics): (1) Use three-level mixed model with random intercepts for clusters (Level 1: repeated measures, Level 2: subjects, Level 3: clusters). (2) Use generalized estimating equations (GEE) with nested correlation structure. (3) Include cluster as fixed effect if few clusters (< 10). (4) Use cluster-robust standard errors. Ignoring clustering underestimates SEs and inflates Type I error
gee
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. Outliers can reveal critical data quality issues or genuine subgroup effects that averages obscure.
System Health
Essential checks
  1. Mauchly's test of sphericity for both main effects and interaction
  2. Greenhouse-Geisser or Huynh-Feldt epsilon (ε) if sphericity violated
  3. Descriptive statistics (M, SD) for all conditions
  4. Interaction plot (profile plot) to visualize Factor A × Factor B
Recommended checks
  1. Q-Q plots of residuals or key difference scores
  2. Shapiro-Wilk test on difference scores for main contrasts
  3. Check for missing data patterns (% missing per condition)
  4. Residual plots to detect outliers
  5. Counterbalancing check (order × condition interaction)
  6. Simple effects analysis for significant interaction
  7. Effect sizes (partial η² or generalized η²) for all effects
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

Caffeine Effects on Cognitive Performance Across Time and Task Type

Research question: Does caffeine improve cognitive performance differently across task types and time since ingestion? Design: 30 participants complete 2 tasks (Memory, Attention) at 3 time points (30min, 60min, 90min post-caffeine) in fully within-subjects 2×3 design. Each participant completes all 6 conditions in counterbalanced order. Outcome: Performance accuracy (% correct, 0-100).

Design2×3 fully within-subjects
Total n180
Outcome ScaleAccuracy (% correct, continuous 0-100)
# Two-way RM-ANOVA: Task × Time on Cognitive Performance
# Fully within-subjects design (2×3 = 6 conditions per participant)

# Load packages
library(tidyverse)   # Data manipulation and ggplot2
library(ez)          # For ezANOVA
library(rstatix)     # For anova_test
library(emmeans)     # For post-hoc contrasts

# Set seed
set.seed(2025)

# Simulate realistic data
n_subjects <- 30

data <- expand.grid(
  subject = factor(1:n_subjects),
  task = factor(c("Memory", "Attention")),
  time = factor(c("30min", "60min", "90min"), levels = c("30min", "60min", "90min"))
)

# Generate accuracy with realistic effects
data <- data %>%
  mutate(
    # Base accuracy by task
    base_acc = ifelse(task == "Memory", 72, 75),
    
    # Time effect (caffeine peaks at 60min)
    time_effect = case_when(
      time == "30min" ~ 0,
      time == "60min" ~ 5,
      time == "90min" ~ 3
    ),
    
    # Task × Time interaction (caffeine more beneficial for Attention)
    interaction_effect = case_when(
      task == "Attention" & time == "60min" ~ 4,
      task == "Attention" & time == "90min" ~ 2,
      TRUE ~ 0
    ),
    
    # Subject random effect
    subject_effect = as.numeric(subject) * 0.4 - 6,
    
    # Generate accuracy
    accuracy = base_acc + time_effect + interaction_effect + subject_effect + rnorm(n(), 0, 3.5)
  ) %>%
  mutate(accuracy = pmin(pmax(accuracy, 0), 100)) %>%
  select(subject, task, time, accuracy)

cat("=== Data Structure ===", "\n")
cat("Total observations:", nrow(data), "\n")
cat("Observations per subject:", nrow(data) / n_subjects, "\n")
cat("Design: 2 tasks × 3 time points = 6 conditions per participant\n\n")

# === STEP 1: Check Assumptions ===

# 1. Missing data
cat("Missing observations:", sum(is.na(data$accuracy)), "\n\n")

# 2. Descriptive statistics
cat("=== Descriptive Statistics ===", "\n")
desc_stats <- data %>%
  group_by(task, time) %>%
  summarise(n = n(), M = mean(accuracy), SD = sd(accuracy), .groups = "drop")
print(desc_stats)

# === STEP 2: Run Two-way RM-ANOVA ===

cat("\n=== Two-way RM-ANOVA(ezANOVA) ===", "\n")
anova_result <- ezANOVA(
  data = data,
  dv = accuracy,
  wid = subject,
  within = .(task, time),
  detailed = TRUE,
  type = 3
)

print(anova_result)

# Check sphericity
if(!is.null(anova_result$`Mauchly's Test for Sphericity`)) {
  cat("\n=== Mauchly's Test for Sphericity ===", "\n")
  print(anova_result$`Mauchly's Test for Sphericity`)
  cat("\nInterpretation: p < .05 indicates sphericity violated\n")
}

# Sphericity corrections
if(!is.null(anova_result$`Sphericity Corrections`)) {
  cat("\n=== Sphericity Corrections ===", "\n")
  print(anova_result$`Sphericity Corrections`)
  cat("\nGG = Greenhouse-Geisser, HF = Huynh-Feldt\n")
  cat("Use GG if epsilon < .75, HF if epsilon > .75\n\n")
}

# === STEP 3: Check Normality ===

cat("=== Normality Check ===", "\n")
# Compute within-subject residuals
data <- data %>%
  group_by(subject) %>%
  mutate(residual = accuracy - mean(accuracy)) %>%
  ungroup()

# Q-Q plot and histogram
par(mfrow=c(1,2))
qqnorm(data$residual, main="Q-Q Plot of Residuals")
qqline(data$residual, col="red")
hist(data$residual, breaks=25, main="Histogram of Residuals", xlab="Residual")

# Shapiro-Wilk test
shapiro_test <- shapiro.test(data$residual)
cat("\nShapiro-Wilk test: W =", round(shapiro_test$statistic, 3), 
    ", p =", round(shapiro_test$p.value, 4), "\n")
cat(ifelse(shapiro_test$p.value > .05, "✓ Normality OK", "⚠ Normality violated"), "\n\n")

# === STEP 4: Visualize Interaction ===

cat("=== Interaction Plot ===", "\n")
task_time_means <- data %>%
  group_by(task, time) %>%
  summarise(M = mean(accuracy), SE = sd(accuracy)/sqrt(n()), .groups="drop")

p1 <- ggplot(task_time_means, aes(x=time, y=M, color=task, group=task)) +
  geom_line(linewidth=1.2) +
  geom_point(size=3) +
  geom_errorbar(aes(ymin=M-SE, ymax=M+SE), width=0.1) +
  labs(title="Task × Time Interaction: Caffeine Effects on Performance",
       subtitle="Caffeine more beneficial for Attention at peak(60min)",
       x="Time Since Caffeine Ingestion", 
       y="Accuracy(% correct) ± SE",
       color="Task Type") +
  theme_classic() +
  theme(legend.position="right")
print(p1)

# === STEP 5: Simple Effects Analysis (if interaction significant) ===

if(anova_result$ANOVA$`Pr(>F)`[3] < .05) {  # If interaction p < .05
  cat("\n=== Simple Effects: Effect of Time for each Task ===", "\n")
  
  # Memory task
  cat("\n--- Memory Task ---\n")
  memory_data <- data %>% filter(task == "Memory")
  memory_anova <- anova_test(data = memory_data, dv = accuracy, wid = subject, within = time)
  print(get_anova_table(memory_anova))
  
  # Attention task
  cat("\n--- Attention Task ---\n")
  attention_data <- data %>% filter(task == "Attention")
  attention_anova <- anova_test(data = attention_data, dv = accuracy, wid = subject, within = time)
  print(get_anova_table(attention_anova))
}

# === STEP 6: Post-hoc Pairwise Comparisons ===

cat("\n=== Pairwise Comparisons: Time(Main Effect) ===", "\n")
pairwise_time <- data %>%
  pairwise_t_test(accuracy ~ time, paired = TRUE, p.adjust.method = "bonferroni")
print(pairwise_time)

# === STEP 7: Effect Sizes ===

cat("\n=== Effect Sizes ===", "\n")
cat("From ANOVA table(ges = generalized eta squared):\n")
cat("Interpretation: .01 = small, .06 = medium, .14 = large(Cohen, 1988)\n\n")

# === APA-Style Reporting ===

cat("=== APA-Style Report ===", "\n")
cat("
A two-way repeated measures ANOVA was conducted to examine the effects of
caffeine on cognitive performance across task type(Memory, Attention) and
time since ingestion(30min, 60min, 90min). Mauchly's test indicated sphericity
was violated for the Time main effect(p = .032, ε = .85), so Huynh-Feldt
corrected values are reported.

Results revealed a significant main effect of Time, F(1.70, 49.30) = 42.15,
p < .001, η²_G = .28 (large effect), with peak performance at 60 minutes
post-ingestion. The Task main effect was also significant, F(1, 29) = 8.34,
p = .007, η²_G = .05 (small effect), with Attention tasks(M = 77.8%, SD = 3.8)
outperforming Memory tasks(M = 74.2%, SD = 4.1).

Crucially, a significant Task × Time interaction emerged, F(2, 58) = 6.78,
p = .002, η²_G = .04 (small-to-medium effect). Simple effects analysis revealed
that caffeine improved Attention performance significantly at 60min (M = 84.2%)
compared to baseline 30min (M = 75.3%), Δ = 8.9%, p < .001, but the effect was
smaller for Memory tasks(60min: M = 77.5% vs 30min: M = 72.1%, Δ = 5.4%, p = .003).
By 90 minutes, Attention performance remained elevated(M = 81.4%) while Memory
returned near baseline.

These findings support caffeine's time-dependent and task-specific cognitive
enhancement, with maximal benefits for attention tasks occurring 60 minutes
post-ingestion, consistent with pharmacokinetic profiles(McLellan et al., 2016).
")

cat("\n=== Key Statistics to Report ===", "\n")
cat("• Main effect Task: F(df1, df2) = X.XX, p = .XXX, η²_G = .XX\n")
cat("• Main effect Time: F(df1, df2) = X.XX, p < .001, η²_G = .XX(report corrected df if violated)\n")
cat("• Interaction Task × Time: F(df1, df2) = X.XX, p = .XXX, η²_G = .XX\n")
cat("• Sphericity tests and corrections(report ε and which correction used)\n")
cat("• Descriptive statistics(M, SD) for all conditions\n")
cat("• Simple effects analysis for significant interaction\n")
cat("• Post-hoc pairwise comparisons with Bonferroni correction\n")
Interpretation Blueprint

Significant Task × Time interaction (F[2,58] = 6.78, p = .002, η²_p = .19): Caffeine improved Attention performance more than Memory, with peak benefits at 60 minutes post-ingestion. Attention accuracy increased 8.9% from baseline (30min) to peak (60min), compared to only 5.4% for Memory. By 90 minutes, Attention remained elevated (+6.1% from baseline) while Memory declined. Main effects: Time (F[2,58] = 42.15, p < .001, η²_p = .59), Task (F[1,29] = 8.34, p = .007, η²_p = .22). Findings align with pharmacokinetics (peak plasma caffeine ~60min) and support task-specific cognitive enhancement.

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Ratio / Interval
Ratio
Maintain Within-Within ANOVA. The gold standard for pure internal crossover designs.
Peak Signal
Interval
Ideal for Primary Metrics. Ensure each subject provides a stable response across all crossover cells.
Standard Precision
Ordinal
Pivot to Non-Parametric Crossover Models if outcomes are ranked or non-normally skewed.
Variance Compression
Nominal
Abandon ANOVA. Use McNemar-Bowker to model categorical status flips within the crossover grid.
Identity Only
Temporal Trajectory Audit Pure Within-Subject Crossover
Balanced Crossover
Full grid per subject.
Stay with Within-Within ANOVA. Isolate the internal signal from between-person noise.
Carryover Effects
Persistent treatment.
Pivot to Linear Mixed Models (LMM) with 'Period' and 'Sequence' factors to neutralize carryover bias.
Adaptive Technical Safeguards · adaptive safeguards
sphericity violation
  • Greenhouse-Geisser Correction — The mandatory shield for within-subject variance heterogeneity.
  • MANOVA Path — bypass sphericity by treating the crossover cells as a multivariate profile.
independence violated
  • Linear Mixed Models — Use if participants are further clustered within clinical sites or periods.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons

Post-hoc pairwise tests defined for this model.

Interpretation Guidelines

No specific guidelines provided.

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Eta-squared tells you the 'ownership' of variance. How much of the outcome does your treatment actually control?
Impact Magnitude

Proportion of variance explained after removing other effects. Small: .01, Medium: .06, Large: .14 (Cohen, 1988). Most commonly reported for RM-ANOVA

More appropriate for designs with both between- and within-subjects factors. Same thresholds as partial η²

Less biased estimate of population effect size. Preferred for within-subjects designs when available

Recommended Metric: partial_eta_squared for pure within-subjects designs, generalized_eta_squared if comparing across studies with different designs
Small
0.2
Medium
0.5
Large
0.8
0.50
partial_eta_squared for pure within-subjects designs, generalized_eta_squared if comparing across studies with different designs
Recommended Measure
3
Available Metrics
ReportUse partial_eta_squared for pure within-subjects designs, generalized_eta_squared if comparing across studies with different designs to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

At least 15-20 subjects for adequate power, depends on effect size and correlation among repeated measures

Effect SizeParametersRequired n
Small Effectα=.05, power=.80n ≈ 54 subjects
Medium Effectα=.05, power=.80n ≈ 12 subjects
Large Effectα=.05, power=.80n ≈ 6 subjects
G*Power StrategyUse G*Power: F-test → ANOVA: Repeated measures, within factors. Input: effect size f, α, power, number of groups per factor, number of measurements, correlation among repeated measures
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

Report the F-statistic as the signal-to-noise ratio, showing how much of the variance is driven by treatment differences versus background noise.
Narrative Arc
Worked APA paragraph example
A two-way repeated measures ANOVA was conducted to examine caffeine effects on cognitive performance across task type (Memory, Attention) and time since ingestion (30min, 60min, 90min). Mauchly's test indicated sphericity was violated for Time (p = .032, ε = .85); Huynh-Feldt corrected values are reported for this effect. Results revealed significant main effects for Time, F(1.70, 49.30) = 42.15, p < .001, η²_p = .59, and Task, F(1, 29) = 8.34, p = .007, η²_p = .22. A significant Task × Time interaction emerged, F(2, 58) = 6.78, p = .002, η²_p = .19. Simple effects analysis revealed caffeine improved Attention significantly at 60min (M = 84.2%) compared to 30min (M = 75.3%, Δ = 8.9%, p < .001), with smaller effects for Memory (Δ = 5.4%, p = .003). By 90min, Attention remained elevated while Memory returned near baseline. Findings support caffeine's time-dependent and task-specific cognitive enhancement, with maximal attention benefits at 60 minutes post-ingestion.
Reusable template

A two-way repeated measures ANOVA was conducted to examine the effects of Factor A and Factor B on DV. Mauchly's test of sphericity was assessed for both main effects and the interaction; state if violated and which correction used: Greenhouse-Geisser (ε = .XX) or Huynh-Feldt (ε = .XX) for specific effects. Results revealed describe main effects with F(df1, df2) = X.XX, p = .XXX, η²_p = .XX. If interaction significant: A significant Factor A × Factor B interaction emerged, F(df1, df2) = X.XX, p = .XXX, η²_p = .XX. Simple effects analysis revealed describe pattern with means and p-values. Post-hoc pairwise comparisons using correction method indicated specific differences.

Essential statistics to report
  • F-statistic for both main effects and interaction
  • degrees of freedom (corrected if sphericity violated)
  • p-values
  • effect sizes (partial η² or generalized η²)
  • sphericity test results and corrections applied
  • descriptive statistics (M, SD) for all conditions
  • simple effects analysis for significant interaction
  • post-hoc pairwise comparisons with corrections
10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: Doubly Repeated Measures ANOVA (Time × Condition)
SourcedfMSFpηp²
Time (Within)285.412.5< .001.27
Condition (Within)142.16.2.018.15
Time × Condition218.53.1.055.08
Error (T×C)686.0
Note. Both factors measured within the same subjects. N = 35.
Time × Condition (p=.055)Borderline interaction. In a 'Doubly Repeated' design, power is high, so a marginal p-value suggests a weak or non-existent synergy.
Time (ηp² = .27)The dominant factor. Subjects changed more due to the passage of time than due to the specific condition applied.
Header glossary

Indicates that every subject experienced every combination of Time and Condition.

The 'crossover' effect. Did the pattern over time differ depending on the condition?

Interaction Error. The specific variance associated with the subject-by-time-by-condition interaction.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code is the modern laboratory. Clean execution ensures reproducible discovery.
Execution Engine
# 1. Execute Doubly Repeated ANOVA
model <- aov_ez(id = 'subject', dv = 'score', data = df, 
                within = c('time', 'condition'))

# 2. Plot the Within-Subject factorial
afx_plot(model, x = 'time', trace = 'condition', error = 'within')
Library stack
R
afexggplot2
Python
pingouin
Elite Forensic Strike

In doubly repeated designs, missing data is fatal (casewise deletion). Audit for completeness first.

# Missing Data Audit
naniar::vis_miss(df)

# Sphericity Check for both Main Effects and Interaction
performance::check_sphericity(model)
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
Sphericity violation inflates Type I error rate substantially in RM-ANOVA. Uncorrected F-tests assume equal variances of all pairwise differences, which is rarely true. This leads to liberal p-values (too many false positives). For interactions, sphericity violation can be severe.
The correction
ALWAYS check Mauchly's test for each within-subjects effect (Factor A, Factor B, A×B interaction). If p < .05: apply Greenhouse-Geisser correction if ε < .75, or Huynh-Feldt if ε > .75. Report corrected df: 'F(1.64, 47.56) = 12.34, p < .001' (not F[2,58]). Alternatively, use linear mixed model which doesn't assume sphericity.
Why it's wrong
A significant A×B interaction indicates the effect of one factor depends on the other, but doesn't specify the pattern. Without simple effects analysis, you can't identify where differences lie or explain the interaction to readers.
The correction
For significant interaction: (1) Test simple main effects (effect of Factor A at each level of Factor B, and vice versa). (2) Conduct pairwise comparisons within each level with Bonferroni correction. (3) Create interaction plot showing pattern. (4) Report specific cells that differ with means and p-values. Example: 'Simple effects revealed caffeine improved attention at 60min (p < .001) but not memory (p = .12).'
Why it's wrong
RM-ANOVA requires complete data, so software drops entire subjects with 1+ missing values. This loses power dramatically and biases results if data aren't missing completely at random (MCAR). With even 10% missingness, you might lose 30-40% of subjects.
The correction
BEST: Use linear mixed model with REML—handles missing data via maximum likelihood without deletion. Alternative: Multiple imputation with 20-40 imputations, pool RM-ANOVA results. Always report % missing per condition and test MCAR (Little's test). Never use LOCF (last-observation-carried-forward)—severely biases toward null.
Why it's wrong
If all subjects experience conditions in same order, practice effects, fatigue, and carryover confound true effects. You cannot determine if differences are due to the factor itself or order effects. This is critical in crossover designs.
The correction
PROSPECTIVE: Use counterbalancing (Latin square for complex designs, ABBA for 2 conditions, Williams square for crossover). Randomize order across subjects. POST-HOC: (1) Include order as covariate in LMM. (2) Test Order × Condition interaction. (3) If significant, carryover present—report as limitation. (4) Model practice explicitly with trial number as predictor.
Why it's wrong
Between-subjects ANOVA ignores dependency of repeated measures, inflating error variance and losing power (may miss real effects). Also violates independence assumption, leading to incorrect p-values and confidence intervals.
The correction
If same subjects measured multiple times: MUST use RM-ANOVA or linear mixed model. Specify within-subjects factors correctly. In R: use within=.(factor1, factor2) in ezANOVA, or Error(subject/(factor1*factor2)) in aov(). In Python: use pg.rm_anova() with subject parameter. Never ignore repeated measures structure.
Why it's wrong
p-values indicate significance but not practical importance. With repeated measures (higher power), tiny trivial effects can be 'significant'. Without effect sizes, readers can't judge magnitude or compare to other studies.
The correction
ALWAYS report partial η² (or generalized η²): 'F(2, 58) = 12.34, p < .001, η²_p = .30'. Interpret: .01 = small, .06 = medium, .14 = large (Cohen, 1988). Report means and SDs for each condition. Consider confidence intervals for effect sizes when possible.
Why it's wrong
RM-ANOVA assumes complete factorial design (all subjects measured in all conditions). Empty cells or severe imbalance destabilizes F-tests, reduces power, and can bias results. Software may fail or produce incorrect estimates.
The correction
If cells missing or severely unbalanced: (1) Use linear mixed model—handles unbalanced designs robustly. (2) Use Type III SS (not Type I) for unbalanced designs. (3) Report cell sizes clearly. (4) Consider why cells are missing—systematic missingness biases results. (5) If >20% missing in any cell, reconsider analysis or collect more data.
Why it's wrong
RM-ANOVA tests whether means differ across conditions, but repeated observation ≠ experimental manipulation. Without random assignment to conditions (e.g., comparing naturally-occurring sleep patterns over time), confounds prevent causal inference.
The correction
For causal claims: (1) Use experimental manipulation with random assignment to condition order (crossover RCT). (2) If observational: use causal inference methods (instrumental variables, difference-in-differences). (3) Report 'associated with' not 'caused'. (4) Discuss confounds (time trends, practice effects, regression to mean) as limitations. Be explicit about study design (experimental vs observational).
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
McLellan, T. M., Caldwell, J. A., & Lieberman, H. R. (2016). A review of caffeine's effects on cognitive, physical and occupational performance. Neuroscience & Biobehavioral Reviews, 71, 294-312.
Comprehensive review of caffeine's cognitive effects with time-course data. Basis for Example 1.
doi: 10.1016/j.neubiorev.2016.09.001
[2]
Dinges, D. F., Pack, F., Williams, K., Gillen, K. A., Powell, J. W., Ott, G. E., ... & Pack, A. I. (1997). Cumulative sleepiness, mood disturbance, and psychomotor vigilance performance decrements during a week of sleep restricted to 4-5 hours per night. Sleep, 20(4), 267-277.
Sleep deprivation effects on mood and performance with time-of-day interactions. Basis for Example 2.
doi: 10.1093/sleep/20.4.267
[3]
Greenhouse, S. W., & Geisser, S. (1959). On methods in the analysis of profile data. Psychometrika, 24(2), 95-112.
Original paper on Greenhouse-Geisser correction for sphericity violations.
doi: 10.1007/BF02289823
[4]
Huynh, H., & Feldt, L. S. (1976). Estimation of the Box correction for degrees of freedom from sample data in randomized block and split-plot designs. Journal of Educational Statistics, 1(1), 69-82.
Huynh-Feldt correction, less conservative than Greenhouse-Geisser when ε > .75.
doi: 10.3102/10769986001001069
[5]
Maxwell, S. E., Delaney, H. D., & Kelley, K. (2017). Designing Experiments and Analyzing Data: A Model Comparison Perspective (3rd ed.). Routledge.
Comprehensive textbook on repeated measures ANOVA, assumptions, sphericity, and mixed models. Chapters 11-14.
[6]
Bakeman, R. (2005). Recommended effect size statistics for repeated measures designs. Behavior Research Methods, 37(3), 379-384.
Guide to appropriate effect sizes for repeated measures: partial η² vs generalized η².
doi: 10.3758/BF03192707
statminds · Within-WithinMind reference · v2.2 · updated 2026-01-1715 of 15 sections