Answer

Mixed ANOVA vs repeated measures ANOVA: what is the difference?

A frequently asked statistics question ·

anovamultilevel models

The short answer

A repeated measures ANOVA compares the same people across conditions or time points, so all its factors are within-subject. A mixed ANOVA (also called a split-plot ANOVA) adds at least one between-subjects factor, such as treatment group, and its key result is usually the interaction: whether change over time differs between groups. Both assume sphericity for the within-subject effects; a linear mixed model is often the better choice when data are missing or time points are unevenly spaced.

Within-subject only, or within and between

In a repeated measures ANOVA, every factor varies within people: each participant is measured at every time point, or under every condition. Because each person serves as their own control, stable differences between people are removed from the error term, which makes the test of time (or condition) much more sensitive than a between-groups ANOVA.

A mixed ANOVA combines that with a factor that varies between people, such as treatment vs control, or men vs women. The name comes from mixing the two kinds of factor, not from mixed-effects models. It is also called a split-plot ANOVA, after the agricultural designs in which whole plots get one treatment and subplots within them get another.

What a mixed ANOVA tests, and with which error term

A mixed ANOVA gives three tests, and they use different error terms:

If you run a plain repeated measures ANOVA on data that really come from two groups, the group × time variation stays in the error term. The test of time loses power, and the question you probably care about, whether the groups changed differently, is never asked.

Sphericity and when to switch to a mixed model

Within-subject tests assume sphericity: the variances of the differences between every pair of time points are equal. With only two time points it holds automatically. With three or more, check it, and correct the degrees of freedom when it is doubtful. The Greenhouse-Geisser epsilon measures the departure: 1 means sphericity holds, and its lower limit is 1/(k − 1) for k time points. A mixed ANOVA also assumes that this covariance structure is the same in each group.

A linear mixed model (for example with R's lme4 or nlme packages) fits the same design with a random effect for each person. It keeps people with some missing time points instead of dropping them, handles unequal or person-specific timing, lets you treat time as continuous, and can model the covariance between time points directly instead of assuming sphericity. For balanced, complete data the two approaches agree closely; with dropout or irregular timing, the mixed model is usually the better choice. See fixed vs random effects in mixed models.

See it in R and Python

The code simulates 20 people in each of two groups measured at three time points; only the treated group improves (by 3 points per time step). It runs a repeated measures ANOVA that ignores the groups, then the mixed ANOVA with aov() and an Error() term, and finally the Greenhouse-Geisser correction. Python computes the same sums of squares by hand with NumPy and SciPy; fed R's data, it reproduces R's tables exactly.

R

set.seed(2718)
n <- 20                                       # people per group
d <- expand.grid(time = factor(1:3), id = factor(1:(2 * n)))
d$group <- factor(ifelse(as.integer(d$id) <= n, "control", "treated"))
person <- rnorm(2 * n, 0, 5)                  # stable differences between people
slope <- ifelse(d$group == "treated", 3, 0)   # only treated people improve
d$y <- 50 + person[d$id] + slope * (as.integer(d$time) - 1) + rnorm(nrow(d), 0, 3)

# Repeated measures ANOVA: one within-subject factor (time), groups ignored
summary(aov(y ~ time + Error(id/time), data = d))

# Mixed (split-plot) ANOVA: time within people, group between people
mixed <- summary(aov(y ~ group * time + Error(id/time), data = d))
mixed

# Sphericity: Greenhouse-Geisser epsilon from the pooled within-group covariance
w <- matrix(d$y, ncol = 3, byrow = TRUE)      # one row per person, one column per time
g <- d$group[d$time == 1]
S <- (cov(w[g == "control", ]) + cov(w[g == "treated", ])) / 2
C <- contr.poly(3)                            # orthonormal contrasts among the 3 times
M <- t(C) %*% S %*% C
eps <- sum(diag(M))^2 / (2 * sum(diag(M %*% M)))
round(eps, 3)

# Greenhouse-Geisser corrected p values for time and group x time
F_within <- mixed[["Error: id:time"]][[1]][1:2, "F value"]
signif(pf(F_within, 2 * eps, 4 * (n - 1) * eps, lower.tail = FALSE), 3)

Python

import numpy as np
import pandas as pd
from scipy import stats

rng = np.random.default_rng(2718)
n, a, b = 20, 2, 3                            # people per group, groups, time points
person = rng.normal(0, 5, (a, n, 1))          # stable differences between people
slope = np.array([0, 3]).reshape(a, 1, 1)     # only treated people improve
y = 50 + person + slope * np.arange(b) + rng.normal(0, 3, (a, n, b))   # group x person x time

def table(rows):
    # rows: (name, SS, df, error SS, error df) -> ANOVA table with F and p
    out = pd.DataFrame(rows, columns=["term", "SS", "df", "SS_err", "df_err"]).set_index("term")
    out["F"] = (out.SS / out.df) / (out.SS_err / out.df_err)
    out["p"] = stats.f.sf(out.F, out.df, out.df_err)
    return out.round(4)

gm = y.mean()
ss_total = ((y - gm) ** 2).sum()
ss_people = b * ((y.mean(axis=2) - gm) ** 2).sum()            # all between-person variation
ss_group = b * n * ((y.mean(axis=(1, 2)) - gm) ** 2).sum()
ss_time = a * n * ((y.mean(axis=(0, 1)) - gm) ** 2).sum()
cell = y.mean(axis=1)                                          # group x time means
ss_gxt = n * ((cell - gm) ** 2).sum() - ss_group - ss_time

# Repeated measures ANOVA: one within-subject factor (time), groups ignored
ss_err_rm = ss_total - ss_people - ss_time
print(table([("time", ss_time, b - 1, ss_err_rm, (a * n - 1) * (b - 1))]))

# Mixed (split-plot) ANOVA: time within people, group between people
ss_err_between = ss_people - ss_group
ss_err_within = ss_err_rm - ss_gxt
df_w = a * (n - 1) * (b - 1)
print(table([("group", ss_group, a - 1, ss_err_between, a * (n - 1)),
             ("time", ss_time, b - 1, ss_err_within, df_w),
             ("group:time", ss_gxt, (a - 1) * (b - 1), ss_err_within, df_w)]))

# Sphericity: Greenhouse-Geisser epsilon from the pooled within-group covariance
S = (np.cov(y[0], rowvar=False) + np.cov(y[1], rowvar=False)) / 2
C = np.linalg.qr(np.column_stack([np.ones(b), np.arange(b), np.arange(b) ** 2]))[0][:, 1:]
M = C.T @ S @ C                               # orthonormal contrasts among the 3 times
eps = np.trace(M) ** 2 / ((b - 1) * np.trace(M @ M))
print("GG epsilon", round(eps, 3))

# Greenhouse-Geisser corrected p values for time and group x time
F_within = np.array([ss_time / 2, ss_gxt / 2]) / (ss_err_within / df_w)
print(stats.f.sf(F_within, 2 * eps, df_w * eps).round(7))

The figures below come from one seeded run of the R code.

How to report a mixed ANOVA in APA style (7th edition)

Name the design with its factors and levels, say whether a sphericity correction was applied, and lead with the interaction when that is the question. Using the example above:

"A 2 (group: control, treated) × 3 (time) mixed ANOVA showed a significant group × time interaction, F(2, 76) = 5.30, p = .007, η²p = .xx. The Greenhouse-Geisser epsilon was .99, so uncorrected degrees of freedom are reported. Main effects of time, F(2, 76) = 6.43, p = .003, and group, F(1, 38) = 12.56, p = .001, were also significant."

Follow a significant interaction with simple effects or planned contrasts, and give the cell means and SDs in a table or figure. Partial eta squared is the effect's sum of squares divided by that sum plus its error sum of squares; Greek letters such as η are not italicized.

Related tools and guides

More answered questions

Working with your own data?

General answers only go so far. Send us your situation and we'll reply by email within two business days.

Ask your question

Need more than an answer?

Written by AskStats with AI assistance. This is general information, not advice for your specific data or study. When the results matter, check your approach with a qualified statistician.