...

/

Analysis of Covariance (ANCOVA)

Analysis of Covariance (ANCOVA)

Learn about the analysis of covariance, how to interpret its results, and post hoc comparisons for it.

Introduction

Let’s learn about covariance and analyze how covariance affects our linear regression model.

What happens when we have a combination of continuous and categorical predictors? This sort of model is called an analysis of covariance, or ANCOVA for short. This name comes from the fact that it’s an ANOVA that contains a covariate or a continuous variable. For example, perhaps we’d like to know if the relationship we’ve been examining between age at DPO and SVL differs when tadpoles are raised in different predator environments. When we code the predictors in an ANCOVA, we must remember to code the covariate before any categorical variables. Note that it’s now even more important to use the Anova() function from the car package to calculate summary statistics because using anova() would give us misleading summary statistics.

R
#Now let’s make an ANCOVA that looks at the
#effects of categorical and continuous data together
lm5<-lm(log.SVL.final~log.Age.DPO*Pred, data=RxP.byTank)
summary(lm5)

For the sake of comparison, here’s the output from both the anova() and Anova() functions:

R
anova(lm5)

Now, let’s run the Anova() function on the lm5 model.

R
Anova(lm5)

Notice the significance of log.Age.DPO is much higher in the anova() output than in the Anova() version. This is because the anova() version calculates the significance of each predictor in a step-by-step manner, so the importance of the first predictor (in this case, log.Age.DPO) is considered the ...