[R] general linear hypothesis glht() to work with lme()

array chip arrayprofile at yahoo.com
Thu Jan 10 21:23:26 CET 2008


Hi I updated my R version to 2.6.1, now glht() worked
with lme() from nlmn package. thanks for responding.

Now I have a questions: can I use the contrast() from
contrast package to do the comparison that I am
interested in?

The comparison that I am intersted is to test the
linear relationship among the 3 levels ('b','m','t')
of the fixed effect "type"? how to specify that
comparison? Using glht(), it is easy to specify by:

batch<-as.factor(rep(1:4,3,each=20))
type<-as.factor(rep(c('b','m','t'),each=80))
y<-2*(type=='m')+4*(type=='t')+rnorm(240,100,20)
dat<-cbind(as.data.frame(y),type=type,batch=batch)
rm(batch,type,y)

library(nlme)
dat.lme<-lme(y~type, random=~1|batch/type, data=dat)

library(multcomp)
summary(glht(dat.lme, linfct = mcp(type
=c("b+t-2*m=0"))),test=Chisqtest())

However, after looking at the examples from the help
page of contrast(), I still couldn't figure out how to
specify that comparison.

Thanks for any suggestions.




--- Dieter Menne <dieter.menne at menne-biomed.de> wrote:

> array chip <arrayprofile <at> yahoo.com> writes:
> 
> (Real names are prefered here)
> 
> > I am trying to test some contrasts, using glht()
> in
> > multcomp package on fixed effects in a linear
> mixed
> > model fitted with lme() in nlme package. The
> command I
> > used is:
> > data=dat)
> > glht(dat.lme, linfct = mcp(type =c("b+t-2*m=0")))
> > 
> > The lme model fit is ok, but I got an error
> message
> > with glht():
> > Error in eval(expr, envir, enclos) : object
> > "info.index" not found
> > Error in factor_contrasts(model) : no
> 'model.matrix'
> > method for 'model' found!
> > 
> > according to help page of glht(), it should work
> with
> > linear mixed model, what is the problem here?
> 
> 
> Here an example from Torsten Hothorn (author of
> multcomp), both for lme 
> and lmer :
> To get a better answer, please  provide the
> (simulated?) data for your example
> as required by the posting guide,
> 
> # multcomplme.r
> nlmeOK <- require("nlme")
> lme4OK <- require("lme4")
> library("multcomp")
> K <- rbind(c(0,1,-1,0),c(0,1,0,-1),c(0,0,1,-1))
> data("ergoStool", package = "nlme")
> stool.lmer <- lmer(effort ~ Type + (1 | Subject),
> data = ergoStool)
> glme4 <- glht(stool.lmer,K)
> summary(glme4)
> 
> 
> #Linear Hypotheses:
> #        Estimate Std. Error z value p value
> #1 == 0   1.6667     0.5187   3.213 0.00376 **
> #2 == 0   3.2222     0.5187   6.212 < 0.001 ***
> #3 == 0   1.5556     0.5187   2.999 0.00761 **
> stool.lme <- lme(effort ~ Type, data = ergoStool,
>                      random = ~ 1 | Subject)
> gnlme <- glht(stool.lme,K)
> summary(gnlme)
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



      ____________________________________________________________________________________
Looking for last minute shopping deals?




More information about the R-help mailing list