Understand the idea
When you measure the SAME people repeatedly (the same patients before, during, and after treatment; the same participants tested under three different conditions), an ordinary ANOVA would be the wrong tool, because it assumes every measurement is independent, and measurements from the same person obviously are not (a naturally fast responder tends to be fast in every condition). Repeated-measures ANOVA turns that non-independence into a genuine ADVANTAGE: it specifically pulls stable person-to-person differences OUT of the error term before testing, which means it needs fewer subjects than an equivalent between-groups design to detect the same real effect.
There is one assumption specific to this design worth understanding by name: sphericity, which requires the variance of the DIFFERENCE between every pair of conditions to be roughly equal. This is checked directly with Mauchly's test. When sphericity fails, the ordinary F-test becomes too liberal (it will flag 'significant' results too often), and the fix is to shrink the degrees of freedom by a correction factor (epsilon) before looking up the p-value; Greenhouse-Geisser is the safe, conservative default correction, with Huynh-Feldt preferred specifically when Greenhouse-Geisser's own epsilon comes out fairly close to 1 (where GG tends to over-correct).
With exactly TWO conditions, sphericity is automatically satisfied: there is only a single pairwise difference to worry about, so there is nothing to violate and no correction is ever needed in that specific case.
Repeated measures ANOVA is also called within-subjects ANOVA. When sphericity fails, the Greenhouse-Geisser correction shrinks the degrees of freedom so the p-value is not too small.
Practitioner explanation
KernelStats partitions SS_total = SS_subjects + SS_condition + SS_error, testing F = MS_condition/MS_error with df_condition=k-1, df_error=(k-1)(n-1), and reports partial eta-squared = SS_condition/(SS_condition+SS_error). Mauchly's W, chi-square, df, and p are all reported directly, along with BOTH the Greenhouse-Geisser and Huynh-Feldt epsilon corrections and their corrected p-values; the card computes and shows both automatically rather than requiring the analyst to pick one blind, and states the standard guidance explicitly: Greenhouse-Geisser is the safe default (conservative), while Huynh-Feldt is preferred specifically when epsilon_GG exceeds about 0.75 (where GG over-corrects).
The design REQUIRES a complete, balanced structure: every subject must appear EXACTLY ONCE at every condition level, checked explicitly before fitting (statsmodels' AnovaRM otherwise raises a raw ValueError on an incomplete design); a missing cell or a duplicate subject-condition combination is caught and reported as a clean, named error rather than an opaque library exception. This completeness requirement is stated as a hard boundary of the method itself: a linear mixed-effects model, not this closed-form ANOVA, is the correct tool once the repeated-measures design has missing cells or dropouts.
The product states directly what this design's whole structural point is: the SS_subjects term (stable individual differences) is deliberately PULLED OUT of the error term used to test the condition effect; using an ordinary one-way ANOVA on the same data instead would leave that individual-differences variation sitting inside the error term, understating the true effect and typically requiring more subjects to detect the same real difference that the repeated-measures design would catch more easily.
When to use it
Consider it when
Every subject is measured under every condition (a complete, balanced within-subjects design), and you want to test whether the mean response differs across those conditions while accounting for the correlation between repeated measurements on the same subject.
Use caution when
The design has missing cells or dropouts (subjects not measured at every condition; use a linear mixed-effects model instead), the response is severely non-normal or ordinal (use the Friedman test), or the groups being compared are actually independent (different subjects in each group) rather than the same subjects repeated across conditions.
Formulas and symbols
Repeated-measures F statistic
k conditions, n subjects. The subject-to-subject variation (SS_subjects) is removed from the error term before this ratio is computed.
Partial eta-squared
Answers: of the variance left after removing subject differences, how much does condition explain? Cohen's marks: 0.01 small, 0.06 medium, 0.14 large.
Sphericity-corrected degrees of freedom
epsilon (Greenhouse-Geisser or Huynh-Feldt) <= 1 shrinks the degrees of freedom when Mauchly's test rejects sphericity, making the F-test appropriately more conservative.
Assumptions and checks
- Sphericity. When sphericity is violated (the variances of the pairwise condition differences are not all equal), the uncorrected F-test's p-value is too liberal (too easily significant); a correction (Greenhouse-Geisser, or Huynh-Feldt when epsilon is large) restores approximately the right Type I error rate.
In KernelStats: Mauchly's test of sphericity, reported directly on the card, with the Greenhouse-Geisser and Huynh-Feldt corrected p-values also reported so the corrected result is always available alongside the uncorrected one; automatically reported as satisfied (no test needed) when there are only two conditions, since a single difference variance cannot violate sphericity.
- Normality (of residuals, not of the raw data). Non-normal residuals make the F-test (corrected or not) approximate rather than exact.
In KernelStats: Shapiro-Wilk on the model residuals (sampled for large n), reported directly on the card.
Alternatives
- Friedman Test. Normality is doubtful, the response is ordinal, or the sample is small: the rank-based nonparametric analogue of repeated-measures ANOVA.
- Linear Mixed-Effects Model. The repeated-measures design is unbalanced or has missing cells, which this closed-form ANOVA cannot handle.
- One-Way ANOVA. The groups being compared are genuinely independent (different subjects), not the same subjects measured repeatedly.
Worked example
Scenario
Reaction times measured on 24 participants under three drug doses (placebo, low, high), each participant tested at all three doses.
Result
F(2, 46) = 12.7, p < .001; Mauchly's W = 0.75, chi-square(2) = 6.33, p = .04 (sphericity violated); Greenhouse-Geisser epsilon = 0.84, corrected p < .001 (conclusion unchanged); partial eta-squared = 0.36 (large).
Interpretation
Reaction times differ significantly across the three doses, and although sphericity is technically violated, the Greenhouse-Geisser correction confirms the conclusion holds even after accounting for it; the large partial eta-squared indicates dose explains a substantial share of the variance remaining after individual differences between participants are removed.
Common misconceptions
Misconception
Sphericity violations don't matter much as long as you report the uncorrected p-value alongside a caveat.
Correction
When Mauchly's test shows sphericity is violated, the ORDINARY (uncorrected) F-test is too liberal: it inflates the true Type I error rate beyond the nominal alpha. The correct response is to report the Greenhouse-Geisser (or Huynh-Feldt) CORRECTED p-value as the actual result, not to report the uncorrected p-value with a footnote; the correction changes which conclusion is actually warranted.
Misconception
Repeated-measures ANOVA can be run on data with a few missing cells (some subjects missing a condition) the same way as a complete design, just with slightly reduced power.
Correction
This closed-form ANOVA REQUIRES a complete, balanced design: every subject present at every condition exactly once. Missing cells are not merely a power loss; the underlying computation (statsmodels' AnovaRM) cannot run at all on an incomplete design without raising an error. A linear mixed-effects model is the correct tool once the design has missing cells or dropouts, not this ANOVA with reduced power.
References
- Designing Experiments and Analyzing Data: A Model Comparison Perspective, Maxwell, S. E., Delaney, H. D. and Kelley, K. (2017).
- On the Test of Sphericity, Mauchly, J. W. (1940), Annals of Mathematical Statistics, 11(2), 204-209.
