lmerTest :: anova不显示p值 [英] lmerTest::anova not showing p-values

查看:1034
本文介绍了lmerTest :: anova不显示p值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问一个新问题,因为重复(与lmerTest一起使用时,> anova()不会显示p值)并未真正提供答案: 我遇到了一个同样的问题,即lmerTest :: anova不会为特定模型输出自由度和p值(这比上述文章中的复杂度要低得多):

I am asking a new question because the dublicate (anova() does not display p-value when used with lmerTest) is not really providing an answer: I ran into the same problem that lmerTest::anova will not output degrees of freedom and p-values for a specific model (that is much less complicated than the one in the post mentioned above):

DirectionFit <- lmer(Similarity ~  picture_category * ComparisonType + (1 + picture_category + ComparisonType|Subject), data = DirectionData, REML=FALSE)

我注意到,模型报告包含收敛代码0,并且存在2个优化器警告.可能是因为如此,lmerTest :: anova没有报告p值吗? 模型本身的输出看起来很正常,只是具有很高的AIC,BIC等(-10625). 有人知道该怎么做吗?我已经读到也许应该选择另一个优化器,但这是否也可以解决收敛性问题? 感谢您的帮助!

I noticed, that the model report includes the convergence code 0 and that there have been 2 optimizer warnings. Could it be that it is because of this that lmerTest::anova is not reporting p-values? The output of the model itself looks normal, just with very high AIC, BIC etc (-10625). Does anyone know what to do about this? I have read that maybe another optimizer should be chosen, but would that also solve the convergence problem? Any help is appreciated!

修改: 我将数据上传到: http://www.sharecsv.com/s/1e303e9cef06d02af51ed5231385b759/TestData.csv 谢谢您的帮助!

I uploaded my data on: http://www.sharecsv.com/s/1e303e9cef06d02af51ed5231385b759/TestData.csv Thank you for your help!

推荐答案

基本问题是您拥有单数适合度;估计的随机效应方差-协方差矩阵位于其可行空间的边界上(等效地,lme4用于表征方差-协方差矩阵的内部参数之一(必须为非负数)正好为零).这不是本身的优化问题;这通常意味着您的模型对于数据而言太复杂了,应该简化(例如,参见 GLMM常见问题解答以获取更多信息).尤其是,尽管您的实验设计原则上 允许您适应picture_categoryComparisonType效果的对象间差异,但希望为39个随机效果估计一个4x4的方差-协方差矩阵学科很乐观. (您可能会遵循Barr等人的保持最大建议" ...)

The basic problem is that you have a singular fit; the estimated random-effects variance-covariance matrix is on the boundary of its feasible space (equivalently, one of the internal parameters that lme4 uses to characterize the variance-covariance matrix, which must be non-negative, is exactly zero). This is not an optimization problem per se; it generally means your model is too complex for your data, and should be simplified (e.g. see the relevant section in the GLMM FAQ for more information). In particular, although your experimental design in principle allows you to fit among-subject variation in effects of picture_category and ComparisonType, hoping to estimate a 4x4 variance-covariance matrix for the random effect from 39 subjects is very optimistic. (You may be following Barr et al's "keep it maximal advice" ...)

以下内容可能比您真正想要的更具技术性,但我将其提供为将来解决此类问题的参考.如果您想忽略您的模型是单数的事实(我不推荐这样做),并且您愿意修复当前版本的lmerTest中的一个错误[我正在向维护者发送电子邮件]) ,实际上您可以通过Kenward-Roger逼近来获得此问题的p值:summary(m2, ddf="Kenward-Roger")可以工作,尽管它相当慢(在我的笔记本电脑上为163秒).

What follows may be more technical than you really want, but I'm providing it as future reference for trouble-shooting these kinds of problems. If you want to ignore the fact that your model is singular (which I wouldn't recommend), and you are willing to fix a bug in the current version of lmerTest [I'm sending the maintainer an e-mail]), you can actually get p-values for this problem via Kenward-Roger approximation: summary(m2, ddf="Kenward-Roger") works, although it's quite slow (163 seconds on my laptop).

由于lmerTest会截获错误消息,因此很难看清发生了什么情况,因此我通常会尝试从lme4开始对lmerTest问题进行故障排除.

Because lmerTest intercepts error messages, making it hard to see what has happened, I generally try to trouble-shoot lmerTest problems by starting with lme4.

适合的型号:

DirectionData <- read.csv("TestData.csv")
library(lme4)
DirectionFit <- lmer(Similarity ~  picture_category * ComparisonType +
           (1 + picture_category + ComparisonType|Subject),
                     data = DirectionData, REML=FALSE)
## Warning messages:
## 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
##   unable to evaluate scaled gradient
## 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
##   Model failed to converge: degenerate  Hessian with 1 negative eigenvalues

好的,让我们看看发生了什么. summary(DirectionFit),尤其是VarCorr(DirectionFit),没有显示任何0方差或+/- 1相关性,但是拟合仍然是单数:

OK, Let's look at what happened. summary(DirectionFit), and particularly VarCorr(DirectionFit), doesn't show us any 0 variances or +/-1 correlations, but the fit is nonetheless singular:

th <- getME(DirectionFit,"theta")
which(th==0)
## Subject.picture_categoryland 
##                           8 

(在实践中测试which(th<1e-10)可能会更好)

(it might be better in practice to test for which(th<1e-10))

那么这对lmerTest输出有何影响?

So how does this affect the lmerTest output?

library(lmerTest)
m2 <- as(DirectionFit,"merModLmerTest")
trace("summary",sig="merModLmerTest",browser)  ## debug
summary(m2)

在深入研究时,我们发现问题出在calcApvar函数中,该函数具有以下代码:

As we dig down, we find that the trouble is in the calcApvar function, which has this code:

dd <- devfunTheta(rho$model)  ## set up deviance function
h <- myhess(dd, c(rho$thopt, sigma = rho$sigma)) ## compute Hessian
ch <- try(chol(h), silent = TRUE)

如果我们尝试最后一个命令而没有沉默/捕获错误消息,我们将得到

If we try the last command without silencing/catching the error message we get

chol.default(h)中的错误:10级前导未成年人不是肯定的

Error in chol.default(h) : the leading minor of order 10 is not positive definite

基本上,我们不能用Cholesky分解Hessian(二阶导数)矩阵,因为它不是正定的:您可以在维基百科,Cholesky分解适用于PD矩阵.

Basically, we can't Cholesky-decompose the Hessian (second-derivative) matrix because it's not positive definite: as you can read on Wikipedia, the Cholesky decomposition applies to PD matrices.

这篇关于lmerTest :: anova不显示p值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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