[R] Please Post Planned Contrasts Example in lme {nlme}

Dieter Menne dieter.menne at menne-biomed.de
Fri Mar 19 08:40:32 CET 2010



Tobias Verbeke-2 wrote:
> 
> I would have a look at the multcomp package which allows for
> defining contrasts in a very convenient way and can deal a.o.
> with lme (from nlme) and mer (from lme4) objects.
> 
> 

It's correct, but there is no example in the docs of glht for lmer, but
there is one in the vignette. Also have a look at Nicholas Levin-Koh's
elegant misuse of contrast/lm (reproduced below, typo corrected)

#-------------------------------------
#http://markmail.org/message/62knhcfupzyt2p6r
library(contrast) 
library(multcomp) 
library(mlmRev)  # for data
library(lme4) 
data(egsingle)

fm1 <- lmer(math~year*size+female+(1|childid)+(1|schoolid), egsingle)
## Main effects to get contrast matrix, there is no method for lme4 objects
fm2 <- lm(math~year*size+female, data=egsingle)

cc<-contrast(fm2,
         a=list(year=c(.5,1.5,2.5),size=380, female="Male"), 
         b=list(year=c(.5,1.5,2.5),size=800, female="Male"))
 ## Plug in the contrast matrix from contrast, multcomp will use the
variance covariance matrix
summary(glht(fm1, linfct = cc$X))



-- 
View this message in context: http://n4.nabble.com/Please-Post-Planned-Contrasts-Example-in-lme-nlme-tp1598717p1599031.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list