statcompute

Hypothesis tests

ANCOVA Calculator

Compare group means while holding a second, continuous variable constant — so you measure the treatment, not the head start.

Also called analysis of covariance calculator, t test with covariates, ANCOVA test calculator, adjusted means calculator.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
Group name, then the covariate, then the outcome — “Control 52 61”. Separate with spaces, commas or tabs.
Conventionally 0.05. Decide before you look.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

ANCOVA answers the question a plain ANOVA cannot: are these groups different for a reason other than where they started? It compares group means after statistically removing the part of the outcome that a continuous covariate explains.

01

How to read this result

Read the adjusted means, not the raw ones. The raw mean is what each group actually scored. The adjusted mean is what it would have scored had every group started at the same covariate value — the grand mean. The F test is about the adjusted means, so those are the numbers that match the p-value.

The pooled slope is doing the adjusting. ANCOVA estimates one slope from inside the groups and uses it to slide every group along that line to a common covariate value. A group that started above average gets adjusted down, one that started behind gets adjusted up.

Check the homogeneity-of-slopes line before believing any of it. ANCOVA assumes the covariate works the same way in every group — parallel lines. If that test rejects, a single adjusted difference is a fiction: the group difference depends on where you are along the covariate, and what you should report is that interaction, not one adjusted number.

The covariate must not be affected by the treatment. It should be measured beforehand — prior ability, baseline weight, age. Adjusting for something the treatment itself moved subtracts part of the effect you are trying to measure, and the result will understate it, sometimes to nothing. This is the most common way ANCOVA goes wrong, and no test on the output will warn you about it.

02

The formula

bw=gi(xgix¯g)(ygiy¯g)gi(xgix¯g)2
xgi
the covariate for observation i in group g
x¯g
the covariate mean of group g

The pooled within-group slope: the covariate's effect estimated inside the groups, so that differences between groups do not inflate it.

y¯gadj=y¯gbw(x¯gx¯)

Each group's mean slid along the pooled slope to the grand mean of the covariate. This is the number the F test compares.

F=(SSExSSEx+g)/(k1)SSEx+g/(Nk1)
SSEx
residual SS with the covariate alone
SSEx+g
residual SS with the covariate and the groups
k
the number of groups

How much the group labels explain once the covariate has already had its turn: the drop in residual sum of squares when groups are added.

03

Worked example

Three teaching methods, adjusted for prior ability

Eighteen students are split between a control and two teaching methods. Everyone sits a pre-test before the course and an exam after it. The exam means look close — and the pre-test means are not equal either, so part of any difference is just who started where.

Control: pre 52, 58, 61, 45, 67, 55 · exam 61, 65, 69.5, 52.5, 76, 62 Method A: pre 49, 63, 57, 70, 54, 60 · exam 62, 78, 70.5, 84.5, 67, 75 Method B: pre 66, 51, 59, 62, 48, 57 · exam 75.5, 59.5, 69, 70, 57.5, 65.5

  1. Run a plain ANOVA on the exam scores, ignoring the pre-test.
    F = 2.060, p = 0.162 — nothing
  2. Estimate the slope of exam on pre-test from inside the groups.
    b = 987.14 / 938.44 = 1.0519
  3. Slide each group's mean to the grand pre-test mean of 57.44.
    Control 64.33 → 65.50 · A 72.83 → 71.37 · B 66.17 → 66.46
  4. Residual SS with the pre-test alone, then with groups added.
    126.14 → 9.900
  5. The groups' share is the difference, on 2 df.
    F = (116.24/2) / 0.7071 = 82.19
  6. Check the slopes really are parallel before trusting it.
    interaction F = 0.838, p = 0.456 — they are
F (group | covariate) 82.19p < 0.0001pooled slope 1.0519adjusted means 65.50 / 71.37 / 66.46

This is the case ANCOVA exists for. The plain ANOVA sees nothing (p = 0.162) because the groups' pre-test means differ enough to mask the effect. Holding the pre-test constant, the same data give p < 0.0001. Neither answer is a trick — they answer different questions, and the adjusted one is the question about teaching.

Checked against R's aov(exam ~ pre + group) and anova(lm(exam ~ pre * group)).

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

  • The covariate is measured before the treatment, or is otherwise unaffected by it.
  • Parallel slopes. The covariate relates to the outcome the same way in every group. The calculator tests this and says so.
  • Linearity. The covariate–outcome relationship is a straight line within each group.
  • The usual ANOVA assumptions on the residuals: independence, roughly equal spread, and approximate normality.
  • The covariate is measured with little error. A noisy covariate under-adjusts, leaving part of the head start in the "treatment" effect.
  • There is no covariate to adjust forOne-way ANOVAComparing group means on their own is exactly what ANOVA does.
  • Only two groups and one covariateLinear regressionWith two groups this is a regression with a group dummy, and the dummy's coefficient is the adjusted difference.
  • F is significant and you need to know which pairs differTukey's HSDANCOVA says the adjusted means are not all equal; a post-hoc test says which.
  • The slopes are not parallelLinear regressionFit the interaction directly and report how the group difference changes along the covariate.
05

Questions people ask

What is the difference between ANOVA and ANCOVA?

ANOVA compares group means as they are. ANCOVA compares them after removing the part of the outcome explained by a continuous covariate. If the groups differ on that covariate to begin with — different prior ability, different baseline weight — ANOVA attributes the head start to the treatment and ANCOVA does not.

Is ANCOVA the same as a t-test with covariates?

For two groups, yes in effect. A t-test with a covariate is a regression of the outcome on the covariate plus a group indicator, and the indicator's coefficient is the adjusted difference. ANCOVA generalises it to any number of groups.

What is an adjusted mean?

What a group would have averaged if it had started at the same covariate value as everyone else — the grand mean. Each group's raw mean is slid along the pooled slope to that common point. Groups that started ahead move down, groups that started behind move up.

What if the homogeneity-of-slopes test is significant?

Then ANCOVA's central assumption fails and a single adjusted difference is misleading: the gap between groups depends on where you look along the covariate. Fit the interaction instead and describe how the difference changes, rather than quoting one number.

Can I use a covariate measured after the treatment?

Almost never. If the treatment changed the covariate, adjusting for it subtracts part of the treatment's own effect, and the result understates it — sometimes to zero. This is the most common misuse of ANCOVA, and nothing in the output will flag it.