逻辑回归模型不使用glmer()函数收敛

时间:2018-06-01 13:13:04

标签: r logistic-regression lme4 convergence

我尝试使用glmer()函数创建混合效应逻辑回归模型,但模型不会收敛。首先,我将分类变量改为从向量到因子。

schwa_completed_2$Outcome <- as.factor(schwa_completed_2$Outcome)
schwa_completed_2$frequency_grouped <- as.factor(schwa_completed_2$frequency_grouped)
schwa_completed_2$sonority_grouped <- as.factor(schwa_completed_2$sonority_grouped)
schwa_completed_2$participant_gender <- as.factor(schwa_completed_2$participant_gender) 
schwa_completed_2$participant_age_group <- as.factor(schwa_completed_2$participant_age_group)
schwa_completed_2$Speaker <- as.factor(schwa_completed_2$Speaker)

还有一个连续变量。然后我创建了一个模型

model <- glmer(Outcome ~ frequency_grouped + sonority_grouped + syl_sec_EN +
                         participant_gender + participant_age_group + 1|Speaker,
           data = schwa_completed_2, family = binomial, optimizer = "bobyqa")

不幸的是,该模型并未收敛。如果我摆脱了#34;扬声器&#34;效果模型的效果很好,但结果可能会有所偏差。

  

警告讯息:
      1:在commonArgs(par,fn,control,environment())中:
      maxfun&lt;不推荐10 *长度(标准杆)^ 2       2:在optwrap中(优化器,devfun,start,rho $ lower,control = control,:
      来自bobyqa的收敛码1:bobyqa - 最大功能数
      评估超过了       3:In(函数(fn,par,lower = rep.int(-Inf,n),upper = rep.int(Inf,:
)       没有收敛到10000次评估中       4:在checkConv(attr(opt,&#34; derivs&#34;)中,选择$ par,ctrl = control $ checkConv,:       模型无法与max | grad |收敛= 0.0785481(tol = 0.001,组分1)

Generalized linear mixed model fit by maximum likelihood (Laplace 
Approximation) ['glmerMod']
Family: binomial  ( logit )
Formula: Outcome ~ frequency_grouped + sonority_grouped + syl_sec_EN +  
participant_gender + participant_age_group + 1 | Speaker
Data: schwa_completed_2

 AIC      BIC   logLik deviance df.resid 
1820.8   2066.1   -864.4   1728.8     1486 

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-2.5957 -0.6255 -0.3987  0.7714  3.4432 

Random effects:
Groups  Name                                 Variance Std.Dev. Corr                         
Speaker (Intercept)                          2.08476  1.4439                                
        frequency_groupedmoderately_frequent 0.78914  0.8883   -0.15                        
        frequency_groupedvery_frequent       3.07514  1.7536   -0.90  0.35                  
        sonority_groupedsonorants            1.33795  1.1567    0.82 -0.44 -0.91            
        sonority_groupedstops                1.76849  1.3298    0.02 -0.42 -0.36  0.51      
        sonority_groupedvowels               2.97690  1.7254    0.23  0.02 -0.32  0.55  0.77
        syl_sec_EN                           0.03217  0.1794   -0.62 -0.42  0.32 -0.44  0.11 -0.52  
        participant_genderM                  0.41458  0.6439   -0.86 -0.18  0.77 -0.77 -0.24 -0.62  0.82 
        participant_age_groupY               0.52428  0.7241    0.46  0.80 -0.20  0.06 -0.44  0.08 -0.73 -0.63

Number of obs: 1532, groups:  Speaker, 40

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -0.7650     0.1862  -4.108 3.99e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
convergence code: 0
Model failed to converge with max|grad| = 0.0785481 (tol = 0.001, component 1)
failure to converge in 10000 evaluations

是因为太复杂的模型还是我的笔记本电脑不够强大?我不知道此时应该怎么做。我能做些什么来解决这个问题?

1 个答案:

答案 0 :(得分:0)

好的,帮助我的是将发言者与group by分组,然后scale syl_sec_EN变量