Mathwords logoMathwords

Analysis of Covariance — Definition, Formula & Example

Analysis of covariance (ANCOVA) is a method that compares the average outcome of several groups after removing the effect of a measured background variable, called the covariate. It answers the question: how would the groups compare if they had all started at the same covariate value?

For kk groups, ANCOVA fits the linear model Yij=μ+τi+β(xij−xˉ)+εijY_{ij} = \mu + \tau_i + \beta(x_{ij} - \bar{x}) + \varepsilon_{ij}. Here YijY_{ij} is the response of subject jj in group ii, τi\tau_i is the effect of group ii, xijx_{ij} is the covariate, β\beta is one common slope, and the errors εij\varepsilon_{ij} are independent N(0,σ2)N(0, \sigma^2). An FF-test then checks H0:τ1=τ2=⋯=τkH_0: \tau_1 = \tau_2 = \cdots = \tau_k, meaning there is no difference between groups once the covariate is accounted for. The test assumes a linear relationship between YY and xx, the same slope in every group (homogeneity of regression slopes), independent observations, normal errors, and equal error variance across groups.

Key Formula

yˉi,adj=yˉi−b (xˉi−xˉ)\bar{y}_{i,\text{adj}} = \bar{y}_i - b\,(\bar{x}_i - \bar{x})
Where:
  • yˉi,adj\bar{y}_{i,\text{adj}} = Adjusted mean of group i: the group's predicted mean response at the overall covariate mean
  • yˉi\bar{y}_i = Observed (raw) mean response of group i
  • bb = Pooled within-group regression slope, which estimates the common slope beta
  • xˉi\bar{x}_i = Mean covariate value in group i
  • xˉ\bar{x} = Overall (grand) mean of the covariate

Worked Example

Problem: Two algebra classes of 20 students each use different teaching methods. Class A averaged 70 on a pretest and 82 on the final exam. Class B averaged 60 on the pretest and 76 on the final. The pooled within-class slope of final score on pretest score is b=0.8b = 0.8. Find the adjusted mean of each class and compare them.
Step 1: Find the overall pretest mean. The classes are the same size, so it is the average of the two class means.
xˉ=20(70)+20(60)40=65\bar{x} = \frac{20(70) + 20(60)}{40} = 65
Step 2: Adjust Class A. It started 5 points above average, so its raw mean gets pulled down.
yˉA,adj=82−0.8(70−65)=82−4=78\bar{y}_{A,\text{adj}} = 82 - 0.8(70 - 65) = 82 - 4 = 78
Step 3: Adjust Class B. It started 5 points below average, so its raw mean gets pushed up.
yˉB,adj=76−0.8(60−65)=76+4=80\bar{y}_{B,\text{adj}} = 76 - 0.8(60 - 65) = 76 + 4 = 80
Answer: The adjusted means are 78 for Class A and 80 for Class B. The raw means put Class A ahead by 6 points. After adjusting for the pretest, Class B is ahead by 2 points. An ANCOVA F-test would decide whether that 2-point gap is statistically significant.

Why It Matters

Clinical trials and education studies use ANCOVA to adjust outcomes for baseline measurements such as starting blood pressure or a pretest score. Removing covariate-related variation also shrinks the error term, so the test can detect a real treatment effect with fewer subjects than a plain one-way ANOVA would need.

Common Mistakes

Mistake: Running ANCOVA without checking that the covariate's slope is the same in every group.
Correction: The adjustment uses one common slope. If the regression lines are clearly not parallel, the size of the group difference depends on the covariate value, and a single adjusted mean is misleading. First fit a model that includes a group-by-covariate interaction. Use standard ANCOVA only if that interaction is not significant.

Related Terms