使用glmer解决警告消息的方法 [英] solution to the warning message using glmer
问题描述
和其他许多人一样,我在运行使用包lme4中的glmer函数的模型时遇到了麻烦.
As many other people, I'm having troubles running a model which uses glmer function from package lme4.
这是我的模特:
model = glmer(depvar ~ variety*cover+amplitude+time+ (1|pp) + (1|stim),
data = datafile, family=poisson)
这是我得到的警告:
Warning message:
In checkConv(attr(opt, "derivs"), opt$par,
ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.00606839
(tol = 0.001, component 1)
我在此链接中阅读,如果我添加>
control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=100000))
在模型结束时,我解决了这个问题.我尝试过,所以我的模型现在是:
at the end of my model, I solve the issue. I tried, so my model is now:
model = glmer(depvar ~ variety*cover+amplitude+time+
(1|pp) + (1|stim), data = datafile, family=poisson,
control=glmerControl(optimizer="bobyqa",
optCtrl=list(maxfun=100000)))
它可以正常工作,而不会发出任何警告消息.
and it works without giving any warning message.
我想问问是否有人可以解释我要添加到模型中的内容,因为我不确定是否理解.另外,这是解决警告问题的可接受的解决方案吗?还是有人用不同的方式解决了这个问题?
I would like to ask whether someone could explain what I am adding to the model, because I am not sure if I understand it. Also, is this an acceptable solution to solve the warning issue? Or anyone solved it in a different way?
非常感谢.
没有control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
的输出是:
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: depvar ~ variety * cover + amplitude + time + (1 | pp) + (1 | stim)
Data: datafile
AIC BIC logLik deviance df.resid
6916.6 6963.1 -3450.3 6900.6 2473
Scaled residuals:
Min 1Q Median 3Q Max
-0.8955 -0.4712 -0.2797 0.3163 3.0090
Random effects:
Groups Name Variance Std.Dev.
stim (Intercept) 0.031757 0.17821
pp (Intercept) 0.008918 0.09443
Number of obs: 2481, groups: stim, 200; pp, 28
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.77480 0.21459 3.611 0.000305 ***
variety2-1 0.04813 0.03096 1.555 0.119969
cover2-1 0.06725 0.03096 2.172 0.029862 *
amplitude -0.04704 0.02685 -1.752 0.079837 .
time -0.02545 0.03747 -0.679 0.496943
variety2-1:cover2-1 0.01435 0.06170 0.233 0.816128
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
convergence code: 0
Model failed to converge with max|grad| = 0.00606839 (tol = 0.001, component 1)
具有 control = glmerControl(optimizer ="bobyqa",optCtrl = list(maxfun = 100000)))的输出为:
The output with control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
is:
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: depvar ~ variety * cover + amplitude + time + (1 | pp) + (1 | stim)
Data: datafile
Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))
AIC BIC logLik deviance df.resid
6916.6 6963.1 -3450.3 6900.6 2473
Scaled residuals:
Min 1Q Median 3Q Max
-0.8956 -0.4712 -0.2797 0.3163 3.0090
Random effects:
Groups Name Variance Std.Dev.
stim (Intercept) 0.031759 0.17821
pp (Intercept) 0.008917 0.09443
Number of obs: 2481, groups: stim, 200; pp, 28
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.77480 0.21457 3.611 0.000305 ***
variety2-1 0.04813 0.03096 1.555 0.119997
cover2-1 0.06725 0.03096 2.172 0.029860 *
amplitude -0.04703 0.02685 -1.751 0.079861 .
time -0.02545 0.03746 -0.679 0.496889
variety2-1:cover2-1 0.01434 0.06170 0.232 0.816160
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
推荐答案
由于模型拟合之间的可能性相差小于< 0.1,并且参数中的最大相对差异约为10 ^(-4),我想说您已经成功证明警告是误报,您可以继续使用初始模型.
Since the likelihood differs by <0.1 between the model fits, and the largest relative differences in the parameters are of the order of about 10^(-4), I would say that you have successfully demonstrated that the warning is a false positive and you can proceed with your initial model.
将优化程序切换为"bobyqa"
并扩展最大迭代次数以抑制警告是无害的(浪费计算机时间除外),但这不是必需的.
Switching the optimizer to "bobyqa"
and extending the maximum number of iterations to suppress the warning is harmless (except in wasting computer time), but not necessary.
这篇关于使用glmer解决警告消息的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!