lme4和languageR兼容性错误:“输入模型不是mer对象" [英] lme4 and languageR compatibility error: "input model is not a mer object”

查看:166
本文介绍了lme4和languageR兼容性错误:“输入模型不是mer对象"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集dat2,我想在该数据集上拟合线性混合效应模型.我过去使用lmer()(软件包lme4)来补充pvals.fnc来计算关联的p值.

I have a dataset dat2 on which I want to fit a linear mixed-effects model. I used lmer() (package lme4) in the past in complement of pvals.fnc to compute the associated p-values.

但是,由于我使用新的lme4(1.0.4)和languageR(1.4)软件包重新安装了R 3.0.2版本,因此我得到了有关lmer函数输出的错误.它说输出不是mer对象.实际上,它的类是lmeRmod.

However, since I reinstalled R 3.0.2 version with the new lme4 (1.0.4) and languageR (1.4) packages I obtain an error about the output of lmer function. It says that the output is not a mer object. Indeed its class is lmeRmod.

这是我使用的代码:

names(dat2)<-c("auc","subj","decod","soa","vis")
attach(dat2)
mod1 <- lmer(auc ~ decod + (1 | subj))
mod2 <- lmer(auc ~ vis+ (1 | subj))
mod3 <- lmer(auc ~ decod + vis + (1 | subj))
mod4 <- lmer(auc ~ decod + vis + decod*vis + (1 | subj))
pvals.fnc(mod1)

我收到此错误:

> pvals.fnc(mod1)
the input model is not a mer object
NULL

实际上,当我查看mod1时,发现它是一个lmeRmod对象,而不是mer对象.

Indeed, when I look at mod1, I find it is a lmeRmod object and not a mer object.

> mod1
Linear mixed model fit by REML ['lmerMod']
Formula: auc ~ decod + (1 | subj) 
REML criterion at convergence: -213.3884 
Random effects:
 Groups   Name        Std.Dev.
 subj     (Intercept) 0.04187 
 Residual             0.11087 
Number of obs: 155, groups: subj, 6
Fixed Effects:
(Intercept)       decod2       decod3       decod4  
     0.9798      -0.1141      -0.3599      -0.3090 

此问题与此处. 1/可能是什么问题(为什么不输出mer对象)和2/如何解决(我尝试重新安装旧版本,但程序包之间存在兼容性问题)的任何想法?

This problem is very similar to the one discribed here. Any ideas of 1/ what the problem might be (why do I do not output a mer object) and 2/ how to work around it (I tried reinstalling older versions but I have compatibility problems between packages) ?

任何帮助都会很棒! 谢谢!

Any help would be great ! thanks !

推荐答案

我确认pvals.fnc函数在新的languageR中不起作用-实质上是因为mcmcsamp未在新的languageR中实现lme4的新版本,这反过来是因为在许多情况下发现它不可靠.

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.

对于我们(lme4作者)感到遗憾的是,这样让languageR用户陷入困境,但这是不可避免的.

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 为计算p值提供了一些替代建议.

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 给出了一个特殊的配方(用于lme4的开发版本),关于如何使用pbkrtest::KRmodcomp获取模型中所有预测变量的p值:

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)
}

此示例产生:

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

这篇关于lme4和languageR兼容性错误:“输入模型不是mer对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆