Need for contrasts in ANCOVA?

37 Views Asked by At

I'm currently trying to compute an ANCOVA as follows:

library(car)
model <- aov(speed~car+engine, data = car_data)
Anova(model, type="III")
library("multcomp")
m4 <- glht(car_data, linfct = mcp(car= "Tukey"), alternative = "two.sided")
summary(m4)

In the text book I'm currently reading (A Fields), it states that it is necessary to specify contrasts beforehand . However, in my current analysis it does not make a difference (to the code below) on the p-value for either the ANCOVA results or subsequent post-hoc tests.

library(car)
contrasts(car_data$car)<- cbind(c(-1, 1, 1),c(0, -1, 1))
model <- aov(speed~car+engine, data = car_data)
Anova(model, type="III")
library("multcomp")
m4 <- glht(car_data, linfct = mcp(car= "Tukey"), alternative = "two.sided")
summary(m4)

Does anyone know if the above mentioned is correct?

I have tried different types of code.

0

There are 0 best solutions below