Firstly, I want to say thanks to the developers and maintainers of R and
its packages- it is a great resource and I appreciate their work.

 

My question relates to setting the reference level in interaction terms
using glm in the "base" package. I would normally set contrasts for the
treatment factors so that the base is zero (control), and the treatment
(one) is compared to it. However, when I specify an interaction between
2 such factors in a glm model, the reference in the glm summary is both
the level 2 factors combined. My example code is below:

 

dat$treat <- factor(dat$treat, labels=c("no", "yes"))

contrasts(dat$treat) <- contr.treatment(2, base=1, contrasts = TRUE)

 

dat$sample <- factor(dat$sample, labels=c("no", "yes"))

contrasts(dat$sample) <- contr.treatment(2, base=1, contrasts = TRUE)

 

I tried reordering the base for the contrasts, but it didn't change the
output.

Is there some way around this without reversing the coding of my
variables?

 

Chris Compton (Veterinarian)

Animal Health Centre

P.O Box 21 Morrinsville

New Zealand

 


	[[alternative HTML version deleted]]


