How to run an ANCOVA
- Copy the group column, covariate column and measurement column together with the header.
- Select different columns for the response, group and covariate. Check the interaction option to also test whether the slopes differ by group.
- Press Analyze and check the group p-value in the ANCOVA table and the adjusted means.
Worked example with sample data
The sample data are the raw material moisture (%) and strength (MPa) of 10 products made by each of 3 processes (A, B, C). The Process column is the group, Raw moisture the covariate and Strength the response.
The raw means are 50.6 (A), 52.24 (B) and 55.86 MPa (C), but the moisture differs by process; adjusted to the overall mean moisture, the adjusted means are 50.22, 52.96 and 55.52 MPa. In the ANCOVA table the group has F = 38.32, p = 1.77e-08, so the processes still differ after controlling for moisture.
The covariate (raw moisture) is also significant (F = 93.1, p = 4.44e-10) with coefficient -2.106: strength drops about 2.1 MPa for each 1-point increase in moisture. In the scatter plot with regression lines by group, all three lines slope down to the right.
With the group × covariate interaction included, p = 0.2804, so the slopes do not differ significantly and the parallel-lines assumption of ANCOVA holds. Ignoring moisture and running only a one-way ANOVA makes the process difference look weaker (p=0.001029) than it is.
How it is calculated
The linear model y ~ group + covariate is fitted and the group and covariate effects are tested with Type II sums of squares. With the interaction, a group × covariate term tests whether the regression slopes differ by group.
The adjusted mean is the group mean predicted by the model with the covariate fixed at its overall mean, and its confidence interval uses the standard error of the predicted mean and the t distribution.
What the result shows
A table of raw and adjusted means, the ANCOVA table (with the covariate coefficient), a scatter plot with regression lines by group, adjusted means with confidence intervals, and residuals vs fitted values.
How to read the ANCOVA result
- If the group p-value is below the significance level, the group means still differ after controlling for the covariate. Compare the adjusted means, not the raw means.
- The sign of the covariate coefficient shows whether the response rises (positive) or falls (negative) as the covariate increases.
- If the interaction is significant, the regression lines are not parallel and the comparison of adjusted means depends on the covariate value, so interpret with care.
Frequently asked questions
Why do the raw and adjusted means differ?
Because the groups have different covariate means. The adjusted mean sets the covariate of every group to the same value (the overall mean).
How many covariates are supported?
One covariate.
What if the group affects the covariate?
If the process itself changes the moisture, it should not be controlled as a covariate. A covariate must be fixed independently of the group assignment.