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 groups, ANCOVA fits the linear model . Here is the response of subject in group , is the effect of group , is the covariate, is one common slope, and the errors are independent . An -test then checks , meaning there is no difference between groups once the covariate is accounted for. The test assumes a linear relationship between and , the same slope in every group (homogeneity of regression slopes), independent observations, normal errors, and equal error variance across groups.
Key Formula
Where:
- = Adjusted mean of group i: the group's predicted mean response at the overall covariate mean
- = Observed (raw) mean response of group i
- = Pooled within-group regression slope, which estimates the common slope beta
- = Mean covariate value in group i
- = 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 . 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.
Step 2: Adjust Class A. It started 5 points above average, so its raw mean gets pulled down.
Step 3: Adjust Class B. It started 5 points below average, so its raw mean gets pushed up.
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.
