Analysis of Covariance (ANCOVA) is a blend of ANOVA that analyzes the difference of means of a continuous response variable across levels of a categorical predictor, controlling for the effect of covariates that are of less interest.
ANCOVA can explain the within-group error variance and hence reduce it. It tries to explain the unexplained variance () in ANOVA in terms of covariates. Additionally, ANCOVA helps to eliminate the influence on results by confounders. The power of the ANCOVA test would increase when entering a strong covariate and be reduced by having a weak covariate.
For the ANCOVA test, the predictor is categorical, while the response variable and covariates are continuous.
There are five assumptions of ANCOVA:
- Linearity: the covariates and the response variable are linearly related.
- Homogeneity of variance: the error is a random variable with zero mean and equal variance across all subpopulations.
- Homogeneity of regression slopes: the slopes of regression lines are equal across all subpopulations.
- Independence: observations are independent, which means errors are uncorrelated.
- Normality: The errors follow a normal distribution.
Suppose a researcher is studying the relationship between the decrease in a personís blood pressure (DBP) and personal and environmental variables, to which they are exposed. Knowledge from observational studies and laboratory findings suggest that the decrease in a personís blood pressure is related to their age and a drug believed to reduce blood pressure.
Then the model can be written as
The main effects of drug treatment on the decrease of blood pressure are tested, controlling for the effect of age.
Example Code in SAS
/* Analysis of Covariance --------------------------------------*/
input Drug $ PreTreatment PostTreatment @@;
A 11 6 A 8 0 A 5 2 A 14 8 A 19 11
A 6 4 A 10 13 A 6 1 A 11 8 A 3 0
D 6 0 D 6 2 D 7 3 D 8 1 D 18 18
D 8 4 D 19 14 D 8 9 D 5 1 D 15 9
F 16 13 F 13 10 F 11 18 F 9 5 F 21 23
F 16 12 F 12 5 F 12 16 F 7 1 F 12 20
proc glm data=DrugTest;
model PostTreatment = Drug PreTreatment / solution;
lsmeans Drug / stderr pdiff cov out=adjmeans;
proc print data=adjmeans;
/* Visualize the Fitted Analysis of Covariance Model -----------*/
ods graphics on;
proc glm data=DrugTest plot=meanplot(cl);
model PostTreatment = Drug PreTreatment;
lsmeans Drug / pdiff;
ods graphics off;
Example Code in R
1. Stephanie Glen. "ANCOVA: Analysis of Covariance" From StatisticsHowTo.com: Elementary Statistics for the rest of us! https://www.statisticshowto.com/ancova/
2. Keppel, G. (1991). Design and analysis: A researcher's handbook (3rd ed.). Englewood Cliffs: Prentice-Hall, Inc.
3. Tabachnick, B. G.; Fidell, L. S. (2007). Using Multivariate Statistics (5th ed.). Boston: Pearson Education.
4. Example 48.4 Analysis of Covariance. (n.d.). SASģ Help Center. Retrieved November 3, 2021, from https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_glm_examples04.htm