[R-sig-ME] testing simple main effects by contrasts

Erich Studerus erich.studerus at bli.uzh.ch
Sat Jun 13 16:57:54 CEST 2009


I have the following study design: Each of two groups of subjects (group A 
and group B) was tested repeatedly on two experimental days. At each 
experimental day, placebo or drug were administered in a randomized order 
and subjects were tested under the the influence of the drug in 3 
consecutive blocks. I have therefore one between subjects factor (Group A vs 
Group B) and two within subjects factors (Drug and Block). Here's a 
reproducible example:

x <- expand.grid(Block= paste('B', 1:3, sep=''),
  Drug = c('Placebo', 'Drug'), Subj=1:24)
df <- data.frame(x, Group = rep(c('A','B'), each=72),
  value=rnorm(144, sd=10))
m <- model.matrix(lm(value~Group*Drug+Block,df))
df$value <- df$value+m[,2]*7+ m[,3]*2 + m[,4]*5 + m[,5]*8 + m[,6]-2
#delete some observations to simulate an unbalanced design
df <- df[-as.numeric(sample(rownames(df),20)),]

mod <- lme(value ~ Group*Drug+Block, random = ~1|Subj, data = df)

Now, since the interaction between Drug and Group is significant, the main 
effects of Drug and Group can not be interpreted. I therefore define 
contrasts to test the simple main effects, that is, the effect of the Drug 
in each Group, averaged over all levels of the Block factor.

I use the contrast package to set up the contrasts:
con1 <- contrast(mod, list(Block=c('B1','B2','B3'), Group = 'A', Drug = 
      list(Block=c('B1','B2','B3'), Group = 'A', Drug = 'Drug'), 
con2 <- contrast(mod, list(Block=c('B1','B2','B3'), Group = 'B', Drug = 
      list(Block=c('B1','B2','B3'), Group = 'B', Drug = 'Drug'), 

Now, I use the multcomp-package to correct the p-values for multiple 

summary(glht(mod, linfct = rbind(con1$X,con2$X)))

This approach works fine with lme, but not with lmer. In the model above I 
modeled the block factor as a fixed effect. However, according to my 
understanding, it would be more parsimonious to model the block factor as a 
random effect. I'm not directly interested in its effect and it's just an 
additional source of variance due to habituation effects . Unfortunately, 
the Block and Subj factors are crossed and therefore can not easily be 
modeled by lme. After comparing different models, the best fitting model 
with lmer looks like this:

lmer(value ~ Group*Drug+(Drug|Subj)+(1|Block))

How can I set up contrasts to test simple main effects for this lmer model? 
I know, that lmer has a contrasts argument. However, as far as I can see, 
one can only test contrasts for the levels of one factor at a time. Any 
comments are highly appreciated.


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