BCompare groups · Guide test 018
Repeated measures ANOVA F tests
Test within subject effects; univariate versions require sphericity or appropriate degrees of freedom adjustments.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- Mixed (split-plot) ANOVA — one between, one within factor — Do groups differ, do conditions differ, and do the groups change differently across conditions?
- Repeated-measures ANOVA (one within factor) — Do the means differ across conditions measured on the same subjects?
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Repeated measures ANOVA F test
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how F varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .059).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- between-condition mean square
- condition × block interaction used as error
The verdict
F(3, 27) = 2.79, p = .059, η²_p = 0.24
p > α = .050: compatible with H₀
Effect size: partial eta squared η²_p = 0.237
Removing block differences shrinks the error term — that is the gain over a one-way ANOVA. Assumes sphericity; check Mauchly or use a correction.
- Statistic
- 2.795
- p-value
- 0.0593
Repeated measures ANOVA F test on Condition 1: n = 10; Condition 2: n = 10; Condition 3: n = 10; Condition 4: n = 10: F(3, 27) = 2.79, p = .059, η²_p = 0.24. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: the specified within subject mean contrasts equal zero; H1: at least one differs.
Assumptions
Subjects are independent. The within subject errors are appropriately modeled. Conventional univariate F inference assumes multivariate normality and sphericity of the tested within subject contrasts.
Formula
Parameters and notation
The displayed degrees of freedom are for a one factor complete repeated design with n subjects and k conditions. With a sphericity correction ε, use εν1 and εν2.
Structure of the method
Arrange repeated measurements by independent subject and condition, partition within-subject effect and subject-by-effect variability, and form their mean-square ratio. In a complete one-factor design, sphericity yields the conventional F reference; epsilon corrections reduce both degrees of freedom while leaving the observed F ratio unchanged.
Estimated and nuisance parameters
Estimate condition means, subject-related components, residual variation, and any chosen sphericity correction from within-subject covariance. Subjects, occasions, contrasts, and covariance assumptions define the design. The number of rows is not the independent sample size; repeated observations within each subject share a covariance structure.
Settings and design choices
Specify within- and between-subject factors, aggregation rules for replicate cells, correction convention, alpha, and planned contrasts. Greenhouse–Geisser and Huynh–Feldt corrections are inferential choices, not neural hyperparameters. For a mixed-model alternative, specify covariance structure and inference method separately instead of labeling it identical repeated-measures ANOVA.
Fitting and adaptation
Refit after changing the complete-subject set or condition coding and re-estimate covariance corrections. Missing or irregular observations often require a model that uses their structure explicitly. A subject-level bootstrap preserves entire response vectors; resampling individual repeated rows destroys the dependence that the analysis is intended to model.
Sensitivity and robustness
Sphericity is automatic for a single two-condition contrast but not general multi-occasion effects. Informative dropout, carryover, and time trends complicate interpretation. The supplied AnovaRM example is balanced and uncorrected: its documented API does not implement sphericity corrections or between-subject effects, so those features cannot be inferred from the generic discussion.
How to use and calibrate
Arrange data by subject and condition, fit the repeated design, and specify the covariance or correction. For two conditions the test is equivalent to the square of a paired t test.
Example application
Compare a continuous outcome measured at four planned occasions in the same independent subjects.
Interpretation and pitfalls
Watch out
Sphericity is automatic for two occasions but not for more. Missing or irregular observations often favor a mixed model. Do not treat repeated rows as independent subjects.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
- Rewritten in the review: interpretation and pitfalls.
Interpretation and pitfallsstatsmodels.org
The cited Python class has a material documented implementation limitation.
Corrected text
Sphericity is automatic for two occasions but not for more. Missing or irregular observations often favor a mixed model. Do not treat repeated rows as independent subjects. The supplied statsmodels AnovaRM code is an uncorrected balanced within-subject example: the API does not implement sphericity corrections or between-subject effects. Those require a separately identified procedure.
Python and R
Uncorrected univariate repeated-measures F test. Sphericity is required with more than two levels; these examples do not apply a Greenhouse–Geisser correction.
Validated — Executed successfully in the validation environment · needs numpy, pandas, scipy, statsmodels
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
b = rng.normal(size=(12,3)) + np.array([0,.3,.7])
import pandas as pd
from statsmodels.stats.anova import AnovaRM
d=pd.DataFrame({"id":np.repeat(np.arange(12),3),"time":np.tile(np.arange(3),12),"y":b.ravel()})
print(AnovaRM(d,"y","id",within=["time"]).fit())
Output
Anova
==================================
F Value Num DF Den DF Pr > F
----------------------------------
time 0.7891 2.0000 22.0000 0.4667
==================================Validated — Executed successfully in the validation environment · needs Base/standard library
set.seed(2026)
b <- matrix(rnorm(36)+rep(c(0,.3,.7),each=12),nrow=12,ncol=3)
d <- data.frame(y=c(b),id=factor(rep(1:12,3)),time=factor(rep(1:3,each=12)))
print(summary(aov(y~time+Error(id/time),d)))
Output
Error: id
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 11 4.704 0.4277
Error: id:time
Df Sum Sq Mean Sq F value Pr(>F)
time 2 21.37 10.685 9.929 0.000845 ***
Residuals 22 23.67 1.076
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Sources
- R stats — R stats · aovstat.ethz.ch
- R Mauchly sphericity teststat.ethz.ch
- aovstat.ethz.ch
- mauchly.teststat.ethz.ch
- Statistics guide v4 (historical):
- Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 018, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT018.