[R-sig-ME] Deviance tests and contrasts

Adam D. I. Kramer adik at ilovebacon.org
Mon Jun 14 03:04:54 CEST 2010

Yes, this is true...but it is a failure of my choice of example, rather than
a real solution to the question.  =) I only really brought up the "main
effect in the presence of the interaction" example as an instance of the
broader problem, which is testing the significance of an effect that I can't
remove in order to use anova()...for example, single-df contrasts on a
multi-level variable:

d <- data.frame(favcol=factor(rep(c("red","blue","yellow","purple"),each=50)),
subj=factor(rep(1:20,each=10)), dv=rnorm(200))

lmer(dv ~ favcol + (1|subj), data=d)

...in this example, with default (dummy-coded) contrasts, the "favcolpurple"
effect tests whether purple differs from red, but I can't (easily) subtract
the "favcolpurple" effect and recompute.

The test I want to conduct is, functionally, this one:

d <- cbind(d,t(sapply(d$favcol, function(x) { contrasts(d$favcol)[x,] } )))
l <- lmer(dv ~ purple + red + yellow + (1|subj), data=d)
l0 <- update(l, . ~ . - purple)

...but what I want is a more elegant way to do this for lmer models, as it
seems to me that the "contrasts" system exists for exactly this reason.

Any thoughts on this?


On Mon, 14 Jun 2010, David Duffy wrote:

>> David's solution below will give me the main effect of sex, but
>> will not tell me whether the sex effect is significant when the interaction
>> is in the model.
> Perhaps this is teaching one's grandmother how to suck eggs (not that I've 
> actually ever sucked eggs ;)), but I was always told that it is pretty hard 
> to interpret _significance_ of a main effect in the presence of an 
> interaction.  I would think this doubly so in the presence of your random 
> effects.
> Cheers, David.
> -- 
> | David Duffy (MBBS PhD)                                         ,-_|\
> | email: davidD at qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  /     *
> | Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
> | 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

More information about the R-sig-mixed-models mailing list