Answer

How to analyze pre-post data: change scores, paired t test or ANCOVA?

A frequently asked statistics question ·

regressiont teststudy designanova

The short answer

If groups were randomized, the usual best choice is ANCOVA: regress the post score on group and the baseline score. It is unbiased, and more precise than comparing change scores or post scores alone. A paired t test on one group's pre-post difference cannot separate the treatment from time trends and regression to the mean, so it needs a control group to mean much.

Four ways to analyze a baseline and a follow-up

Pre-post data have the same people measured before and after something happens. The options differ in which question they answer and how precisely they answer it.

Why ANCOVA is preferred in randomized trials

Call the correlation between baseline and follow-up ρ, and assume the two have the same spread. Relative to comparing post scores alone, the variance of the treatment estimate is about 2(1 − ρ) for change scores and 1 − ρ² for ANCOVA. Change scores only beat a post-only comparison when ρ is above 0.5, while ANCOVA is never worse than either, apart from the one degree of freedom it spends estimating the slope. With ρ = 0.6, the three relative variances are 1, 0.8 and 0.64.

ANCOVA also corrects for chance baseline imbalance in the right amount. If the treated group happens to start low, a post-only comparison is biased against it in that particular trial and a change-score comparison overcorrects when ρ is below 1. ANCOVA subtracts the imbalance multiplied by the estimated slope of post on pre. That is why the baseline should go into the model as planned, whether or not a test of baseline differences is significant; such tests are pointless after randomization anyway.

See it in R and Python

The code simulates a trial with 100 people per arm, a baseline-to-follow-up correlation of 0.6, a general improvement of 3 points over time, and a true treatment effect of 5 points. It runs a paired t test in the treated arm, then the three between-group analyses, then repeats the trial 2,000 times. Finally it takes 5,000 untreated people, picks those with the top 20% of baseline scores, and looks at their change.

R

set.seed(1205)
# One randomized trial: baseline-post correlation 0.6, everyone improves by 3
# over time, and the treatment adds 5 points on top of that
sim_trial <- function(n = 100) {
  group <- rep(0:1, each = n)
  pre   <- rnorm(2 * n, 50, 10)
  post  <- 53 + 0.6 * (pre - 50) + 5 * group + rnorm(2 * n, 0, 8)
  data.frame(group, pre, post, change = post - pre)
}
d <- sim_trial()
round(tapply(d$pre, d$group, mean), 2)           # baseline means, control vs treated

# Paired t test inside the treated group: mixes the treatment with the time trend
tt <- t.test(d$post[d$group == 1], d$pre[d$group == 1], paired = TRUE)
round(c(mean_change = unname(tt$estimate), t = unname(tt$statistic)), 2)

# Three estimates of the treatment effect (true value 5)
est <- function(f, data) coef(summary(lm(f, data)))["group", 1:2]
round(rbind(post_only = est(post ~ group, d),
            change    = est(change ~ group, d),
            ancova    = est(post ~ group + pre, d)), 2)
anc <- lm(post ~ group + pre, d)                               # ANCOVA, df = 197
round(c(confint(anc)["group", ], t = coef(summary(anc))["group", "t value"]), 2)
signif(coef(summary(anc))["group", "Pr(>|t|)"], 2)             # p value

# Over 2,000 trials: all three are unbiased, ANCOVA is the most precise
sims <- replicate(2000, {
  s <- sim_trial()
  c(post_only = coef(lm(post ~ group, s))[2], change = coef(lm(change ~ group, s))[2],
    ancova = coef(lm(post ~ group + pre, s))[2])
})
rownames(sims) <- c("post_only", "change", "ancova")
round(rbind(mean = rowMeans(sims), sd = apply(sims, 1, sd)), 2)

# Regression to the mean: untreated people picked for high baseline scores
ctrl <- sim_trial(5000)
ctrl <- ctrl[ctrl$group == 0, ]
high <- ctrl$pre > quantile(ctrl$pre, 0.8)
round(c(all = mean(ctrl$change), top_20_percent = mean(ctrl$change[high])), 2)

Python

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

rng = np.random.default_rng(1205)
# One randomized trial: baseline-post correlation 0.6, everyone improves by 3
# over time, and the treatment adds 5 points on top of that
def sim_trial(n=100):
    group = np.repeat([0, 1], n)
    pre = rng.normal(50, 10, 2 * n)
    post = 53 + 0.6 * (pre - 50) + 5 * group + rng.normal(0, 8, 2 * n)
    return pd.DataFrame({"group": group, "pre": pre, "post": post, "change": post - pre})

def est(y, *cols):
    # OLS coefficient and standard error of the first predictor (group)
    X = np.column_stack([np.ones(len(y)), *cols])
    beta, *_ = np.linalg.lstsq(X, y, rcond=None)
    resid = y - X @ beta
    V = resid @ resid / (len(y) - X.shape[1]) * np.linalg.inv(X.T @ X)
    return beta[1], np.sqrt(V[1, 1])

d = sim_trial()
print(d.groupby("group")["pre"].mean().round(2))     # baseline means, control vs treated

# Paired t test inside the treated group: mixes the treatment with the time trend
t1 = d[d.group == 1]
tt = stats.ttest_rel(t1.post, t1.pre)
print("mean change", round((t1.post - t1.pre).mean(), 2), "t", round(tt.statistic, 2))

# Three estimates of the treatment effect (true value 5)
g, pre = d.group.to_numpy(), d.pre.to_numpy()
print(pd.DataFrame([est(d.post.to_numpy(), g), est(d.change.to_numpy(), g),
                    est(d.post.to_numpy(), g, pre)],
                   index=["post_only", "change", "ancova"], columns=["Estimate", "SE"]).round(2))
b, se = est(d.post.to_numpy(), g, pre)                         # ANCOVA test, df = 197
t = b / se
print("CI", np.round(b + np.array([-1, 1]) * stats.t.ppf(0.975, 197) * se, 2),
      "t", round(t, 2), "p", float(f"{2 * stats.t.sf(abs(t), 197):.2g}"))

# Over 2,000 trials: all three are unbiased, ANCOVA is the most precise
sims = []
for _ in range(2000):
    s = sim_trial()
    g, pre, post = s.group.to_numpy(), s.pre.to_numpy(), s.post.to_numpy()
    sims.append([est(post, g)[0], est(post - pre, g)[0], est(post, g, pre)[0]])
sims = pd.DataFrame(sims, columns=["post_only", "change", "ancova"])
print(pd.DataFrame({"mean": sims.mean(), "sd": sims.std(ddof=1)}).T.round(2))

# Regression to the mean: untreated people picked for high baseline scores
ctrl = sim_trial(5000)
ctrl = ctrl[ctrl.group == 0]
high = ctrl.pre > ctrl.pre.quantile(0.8)
print("all", round(ctrl.change.mean(), 2), "top 20 percent", round(ctrl.change[high].mean(), 2))

All figures below come from one seeded run of the R code. Python's random numbers differ from R's, so its figures differ slightly (for example, an ANCOVA estimate of 4.20 and a change of −2.89 in the high-baseline group), but they show the same pattern.

What the simulation shows

When the answer is less clear-cut

Our page on what controlling for a variable means explains why adjusting for baseline is not automatically correct outside randomized designs.

Unsure which design-based test applies? Our test chooser walks through the options.

How to report an ANCOVA on pre-post data in APA style (7th edition)

Give the adjusted group difference with its confidence interval and test, and say that baseline was the covariate. Using the single trial above (200 people, so 197 residual degrees of freedom):

"Adjusting for baseline scores, the treatment group scored 5.24 points higher at follow-up than the control group, 95% CI [2.97, 7.51], t(197) = 4.55, p < .001." If you present it as an ANCOVA F test, F(1, 197) equals the square of that t.

In the method section, state that the baseline score was prespecified as a covariate, and report unadjusted means and SDs at both time points in a table. For a single-group design, describe the change honestly: "Scores increased from baseline to follow-up, M = x.xx, 95% CI [LL, UL], t(df) = x.xx, p = .xxx; without a control group, this change cannot be attributed to the intervention."

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.