Hi, 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: ## a simple randomized block design, ## type is fixed effect ## batch is random effect ## model with interaction dat.lme<-lme(info.index~type, random=~1|batch/type, 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? Thanks ____________________________________________________________________________________ Be a better friend, newshound, and
Dieter Menne
2008-Jan-10 09:31 UTC
[R] general linear hypothesis glht() to work with lme()
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)