I can't get lsmeans output in glmer

江枫思渺然 提交于 2019-12-13 07:15:41

问题


List.

I have a generalized mixed model using lmer.test package and calling glmer. I can get a good model, however I can't get the output of the LSMEANS and Diff means.

Here's what I have

library(plyr)
library(lubridate)
library(chron)
library(reshape)
library(lattice)
library(car)
library(lmerTest)


fm17<-glmer(I(Steps+1)~Treatment + treatdate +Weight + BF+ (1|Block) +(0+treatdate|exp.unit), family=poisson)
summary(fm17,ddf="Kenward-Roger")
qqnorm(resid(fm17),main="QQ Model 17")
plot(fm17,main="Residual Model 17")
anova(fm17, ddf="Kenward-Roger")
lsmeans(fm17)
difflsmeans(fm17)

Everything runs fine until LSMEANS statement

Here's the output summary(fm17,ddf="Kenward-Roger") qqnorm(resid(fm17),main="QQ Model 17") plot(fm17,main="Residual Model 17") anova(fm17, ddf="Kenward-Roger") All the above work fine

lsmeans(fm17) Error in lsmeans(fm17) : The model is not linear mixed effects model difflsmeans(fm17) Error in difflsmeans(fm17) : The model is not linear mixed effects model

Any help on how to get that output back would be much appreciated.


回答1:


The lsmeans package does support glmerMod objects, but it does not support Kenward-Rogers df for these models(nor does the pbkrtest package that these rely on). What factors do you want lsmeans of? You need to name them in the call. Do something like this

detach(lmerTest)
library(lsmeans)
lsmeans(fm17, "Treatment")
pairs(.Last.value)

The df show as NA in the results, indicating that asymptotic results ($z$ tests and CIs) are used.




回答2:


lmerTest supports only linear mixed effects models (lmer objects). The anova method that you use comes actually from the lme4 package, and that is why you do not get an error - the model fm17 is of class glmerMod. In the lmerTest only anova for the lmer objects is re-specified. The lsmeans and difflsmeans functions that you use come from the lmerTest package and thereby give you an error saying that your model is not an lmer object.



来源:https://stackoverflow.com/questions/28752417/i-cant-get-lsmeans-output-in-glmer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!