lme4 and languageR compatibility error: \"input model is not a mer object”

强颜欢笑 提交于 2019-12-03 03:38:41

I confirm that the pvals.fnc function doesn't work in the new languageR -- this is essentially because mcmcsamp wasn't implemented in the new version of lme4, which in turn because it was found to be unreliable in many cases.

We (the lme4 authors) are sorry to have left languageR users in the lurch this way, but it was somewhat unavoidable.

https://github.com/lme4/lme4/blob/master/man/pvalues.Rd offers some alternative suggestions for what to do about computing p-values.

https://github.com/lme4/lme4/blob/master/man/drop1.merMod.Rd gives a particular recipe (for the development version of lme4) about how to use pbkrtest::KRmodcomp to get p-values for all of the predictors in a model:

 fm1 <- lmer(Reaction~Days+(Days|Subject),sleepstudy)
 ## Likelihood ratio test
 drop1(fm1,test="Chisq")
 if (require(pbkrtest)) {
    KRSumFun <- function(object, objectDrop, ...) {
       krnames <- c("ndf","ddf","Fstat","p.value","F.scaling")
       r <- if (missing(objectDrop)) {
           setNames(rep(NA,5),krnames)
       } else {
          krtest <- KRmodcomp(object,objectDrop)
          unlist(krtest$stats[krnames])
       }
       attr(r,"method") <- c("Kenward-Roger via pbkrtest package")
       r
    }
    drop1(fm1,test="user",sumFun=KRSumFun)
}

This example produces:

Single term deletions

Model:
Reaction ~ Days + (Days | Subject)
Method: 
Kenward-Roger via pbkrtest package


       ndf ddf  Fstat    p.value F.scaling
<none>                                    
Days     1  17 45.853 3.2638e-06         1

You can use Package ‘lmerTest’ to get the p_values. See the example below:

#import lme4 package and lmerTest package
library(lmerTest)
# an object of class merModLmerTest
m <- lmer(Informed.liking ~ Gender+Information+Product +(1|Consumer), data=ham)
# gives summary of lmer object. The same as of class merMod but with
# additional p-values calculated based on Satterthwate's approximations
summary(m)

More about Package ‘lmerTest’, please see the link below: http://cran.r-project.org/web/packages/lmerTest/lmerTest.pdf

You might look into the mixed function in the afex package found here. It uses Kenward-Rogers for df.

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