使用lsmeans的lmer函数导致错误无法处理类“ref.grid”的对象

时间:2016-07-18 10:10:11

标签: r lme4 lsmeans

我正在尝试使用lme4 R包中的lmer来获得线性混合模型的估计值,以获得解释变量。我的代码如下:

lmm31<-lmer(logvalue~concentration+variable+species+species:concentration+(1|idsp), data=prirstart2)  
lsmeans(lmm31, prirstart2$species)

我收到错误:

    Error in ref.grid(object = <S4 object of class "ref.grid">) : 
    Can't handle an object of class  “ref.grid”
    Use help("models", package = "lsmeans") for information on supported models.

每个解释变量都被编码为因子。当我查看lmer函数返回的对象的类

class(lmm31)

我得到了

    [1] "lmerMod"
    attr(,"package")
    [1] "lme4"

ref.grid返回

ref.grid(lmm31)

     'ref.grid' object with variables:
      concentration = con0, con100, con5, con50
      variable = p1, p2, p3
      species = arenosa, columbiana, halleri, ratkovo

如果我尝试使用multicomp包进行成对比较,它可以正常工作

summary(glht(lmm31, linfct=mcp(species="Tukey")))


      Simultaneous Tests for General Linear Hypotheses

    Multiple Comparisons of Means: Tukey Contrasts


    Fit: lmer(formula = logvalue ~ concentration + variable + species +  species:concentration + (1 | idsp), data = prirstart2)

    Linear Hypotheses:
                              Estimate Std. Error z value Pr(>|z|)    
    columbiana - arenosa == 0  0.47028    0.23152   2.031    0.176    
    halleri - arenosa == 0     0.38960    0.23470   1.660    0.345    
    ratkovo - arenosa == 0    -0.99420    0.23469  -4.236   <0.001 ***
    halleri - columbiana == 0 -0.08068    0.23470  -0.344    0.986    
    ratkovo - columbiana == 0 -1.46448    0.23469  -6.240   <0.001 ***
    ratkovo - halleri == 0    -1.38380    0.23783  -5.819   <0.001 ***

非常感谢任何帮助

0 个答案:

没有答案