使用glmer解决警告消息

ded*_*ede 8 warnings r lme4

和其他许多人一样,我在运行一个使用包lme4中的glmer功能的模型时遇到了麻烦.

这是我的模型:

model = glmer(depvar ~ variety*cover+amplitude+time+ (1|pp) + (1|stim), 
  data = datafile, family=poisson)
Run Code Online (Sandbox Code Playgroud)

这是我得到的警告:

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)
Run Code Online (Sandbox Code Playgroud)

我在这个链接上看到,如果我添加

control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=100000))
Run Code Online (Sandbox Code Playgroud)

在我的模型的最后,我解决了这个问题.我试过,所以我的模型现在是:

model = glmer(depvar ~ variety*cover+amplitude+time+ 
   (1|pp) + (1|stim), data = datafile, family=poisson,
    control=glmerControl(optimizer="bobyqa",
            optCtrl=list(maxfun=100000)))
Run Code Online (Sandbox Code Playgroud)

它没有给出任何警告信息.

我想问一下是否有人可以解释我在模型中添加的内容,因为我不确定我是否理解它.此外,这是解决警告问题的可接受的解决方案吗?或者任何人以不同的方式解决它?

非常感谢.

没有的输出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)
Run Code Online (Sandbox Code Playgroud)

输出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
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
Run Code Online (Sandbox Code Playgroud)

Ben*_*ker 7

由于模型拟合之间的可能性差异小于<0.1,并且参数中的最大相对差异约为10 ^(-4),因此我想说您已经成功证明警告为假阳性,您可以继续使用您的初始模型。

将优化器切换到"bobyqa"最大迭代次数并扩展其最大次数以抑制警告是无害的(浪费计算机时间除外),但这不是必需的。