更改二进制预测器的参考级别会导致glmer爆炸

时间:2015-12-23 20:40:13

标签: r lme4

在具有二进制DV得分(编码为1或0)和一些二元预测变量的模型上运行glmer(lme4_1.1-10):试验类型,在主体内(Aff和Neg),以及2个主题间变量:cdiNo(1或0)和cdiNot(1或0)。包括随机试验类型随机斜率的随机效应。请注意,这里我将随机斜率和截距建模为不相关。使用bobyqa和maxIter设置为10000.这是模型:

analysis<-glmer(score ~ TrialType*cdiNot + TrialType*cdiNo + (1|UniqueSubject) + (0+TrialType|UniqueSubject)

默认情况下,glmer输出是虚拟编码,以使Aff成为TrialType的参考级别。在这种情况下,输出是完全合理的(并且在理论上预测)。

  AIC      BIC   logLik deviance df.resid 
 1766.8   1819.5   -873.4   1746.8     1431 

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-2.3214 -0.8554  0.4693  0.6288  1.5026 

Random effects:
Groups          Name         Variance Std.Dev. Corr
UniqueSubject   (Intercept)  0.3007   0.5484       
UniqueSubject.1 TrialTypeAff 0.2587   0.5087       
             TrialTypeNeg 0.4398   0.6631   0.13
Number of obs: 1441, groups:  UniqueSubject, 183

Fixed effects:
                Estimate Std. Error z value Pr(>|z|)   
(Intercept)           1.3728     0.5285   2.598  0.00939 **
TrialTypeNeg         -1.1677     0.6652  -1.755  0.07919 . 
cdiNot                0.6915     0.2280   3.033  0.00242 **
cdiNo                -0.4600     0.5394  -0.853  0.39384   
TrialTypeNeg:cdiNot   0.2673     0.2915   0.917  0.35904   
TrialTypeNeg:cdiNo    0.1239     0.6811   0.182  0.85560  

但是,我想看一下cdiNot和cdiNo相对于TrialType的其他参考级别的简单效果。所以,我重温:

data$TrialType<-relevel(data$TrialType, ref="Neg")

再次运行完全相同的模型。现在我收到了收敛警告和疯狂的输出。

     AIC      BIC   logLik deviance df.resid 
 1766.8   1819.5   -873.4   1746.8     1431 

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-2.3351 -0.8586  0.4714  0.6301  1.4968 

Random effects:
Groups          Name         Variance Std.Dev. Corr
UniqueSubject   (Intercept)  0.3377   0.5811       
UniqueSubject.1 TrialTypeNeg 0.3917   0.6258       
             TrialTypeAff 0.2263   0.4757   0.02
Number of obs: 1441, groups:  UniqueSubject, 183

Fixed effects:
                 Estimate Std. Error z value Pr(>|z|)    
(Intercept)          0.207190   0.001148   180.5   <2e-16 ***
TrialTypeAff         1.149480   0.001148  1001.6   <2e-16 ***
cdiNot               0.949130   0.001147   827.1   <2e-16 ***
cdiNo               -0.330437   0.001148  -287.9   <2e-16 ***
TrialTypeAff:cdiNot -0.247906   0.001147  -216.1   <2e-16 ***
TrialTypeAff:cdiNo  -0.107224   0.001148   -93.4   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
           (Intr) TrlTyA cdiNot cdiNo TrlTypAff:cdNt
TrialTypAff    0.001                                    
cdiNot         0.000  0.000                             
cdiNo          0.000  0.001  0.000                      
TrlTypAff:cdNt 0.000  0.000  0.000  0.000               
TrilTypAff:cdN 0.001  0.001  0.000  0.001 0.000         
convergence code: 0
Model failed to converge with max|grad| = 0.0624071 (tol = 0.001, component 1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?

但神秘感加深了。如果我只是将随机斜率和截距的相关性添加到模型中,则收敛和其他警告消失,输出再次变得合理。因此,使用Neg作为参考级别并运行:

analysis<-glmer(score ~ TrialType*cdiNot + TrialType*cdiNo + (TrialType|UniqueSubject)

输出结果为:

 AIC      BIC   logLik deviance df.resid 
1764.8   1812.2   -873.4   1746.8     1432 

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-2.3215 -0.8554  0.4693  0.6288  1.5026 

Random effects:
Groups        Name         Variance Std.Dev. Corr 
UniqueSubject (Intercept)  0.7405   0.8605        
           TrialTypeAff 0.6125   0.7826   -0.59
Number of obs: 1441, groups:  UniqueSubject, 183

Fixed effects:
                Estimate Std. Error z value Pr(>|z|)    
(Intercept)           0.2051     0.5009   0.410   0.6821    
TrialTypeAff          1.1676     0.6654   1.755   0.0793 .  
cdiNot                0.9588     0.2222   4.314  1.6e-05 ***
cdiNo                -0.3360     0.5154  -0.652   0.5144    
TrialTypeAff:cdiNot  -0.2673     0.2915  -0.917   0.3591    
TrialTypeAff:cdiNo   -0.1239     0.6813  -0.182   0.8557    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
           (Intr) TrlTyA cdiNot cdiNo  TrlTypAff:cdNt
TrialTypAff    -0.621                                    
cdiNot         -0.036  0.021                             
cdiNo          -0.966  0.600 -0.121                      
TrlTypAff:cdNt  0.021 -0.021 -0.636  0.078               
TrilTypAff:cdN  0.603 -0.966  0.077 -0.625 -0.120 

我对可能发生的事情感到非常困惑。我想我可以想象,如果一个简单的效果很好并且一个是无法识别的,那么改变参考水平可能会导致收敛误差(尽管天文数字仍然不常见)。但如果我理解正确,随机斜率和截距之间的相关性只是模型估计的额外参数。怎么能包含这个参数使一个没有收敛的模型开始?

0 个答案:

没有答案