简体   繁体   English

lmer中的奇点问题(混合模型)

[英]Singularity issue in lmer (mixed model)

I was trying to test state-level variation in a mixed model to predict attitudes using lmer() function.我试图在混合模型中测试状态级别的变化,以使用lmer()函数预测态度。

My original code was我的原始代码是

summary(out3 <- lmer(attitude ~age+ gender+race+education.z+
                       PID.z+c.ex+l.ex+
                       a.z+b.z+
                       cases.z+state.bi+
                       (1|state), long))

all variables are individual-level variables, except cases.z and state.bi .除了cases.zstate.bi之外,所有变量都是个体级别的变量。 However, this model causes singularity issue-- state-level variance is zero and warning message.但是,该模型会导致奇点问题——状态级方差为零和警告消息。

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.7255 -0.6600 -0.0543  0.6332  4.8199 

Random effects:
 Groups   Name        Variance Std.Dev.
 state    (Intercept) 0.0000   0.0000  
 Residual             0.5719   0.7563  
Number of obs: 8280, groups:  state, 51

Fixed effects:
                  Estimate   Std. Error           df t value             Pr(>|t|)    
(Intercept)      2.7188699    0.0418414 8268.9999998  64.980 < 0.0000000000000002 ***
age              0.0005328    0.0005156 8268.9999998   1.033              0.30149    
race            -0.0426514    0.0199646 8268.9999998  -2.136              0.03268 *  
education.z     -0.0257635    0.0086102 8268.9999998  -2.992              0.00278 ** 
PID.z            0.4058194    0.0138666 8268.9999998  29.266 < 0.0000000000000002 ***
c.ex             0.0520329    0.0067580 8268.9999998   7.699   0.0000000000000152 ***
l.ex            -0.0413710    0.0040821 8268.9999999 -10.135 < 0.0000000000000002 ***
a.z             -0.3638447    0.0127821 8268.9999998 -28.465 < 0.0000000000000002 ***
b.z              0.5385977    0.0134168 8268.9999998  40.143 < 0.0000000000000002 ***
cases.z          0.0147368    0.0089858 8268.9999997   1.640              0.10104    
state.bi        -0.0052052    0.0179407 8268.9999998  -0.290              0.77172    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

fit warnings:
fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see ?isSingular

> isSingular(out3)
[1] TRUE

So I tried a number of different sets of models, by removing variables.所以我通过删除变量尝试了许多不同的模型集。

Then I found when I remove az and bz in the model, the singularity issue seems to be gone.然后我发现当我删除模型中的azbz时,奇点问题似乎消失了。


Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.3838 -0.6590 -0.0610  0.6936  4.1528 

Random effects:
 Groups   Name        Variance Std.Dev.
 state    (Intercept) 0.001854 0.04305 
 Residual             0.804934 0.89718 
Number of obs: 8280, groups:  state, 51

Fixed effects:
                  Estimate   Std. Error           df t value             Pr(>|t|)    
(Intercept)      2.7217213    0.0504252  927.3686109  53.975 < 0.0000000000000002 ***
age             -0.0015578    0.0005987 8269.3682573  -2.602              0.00929 ** 
race             0.0358835    0.0238024 7210.4125421   1.508              0.13171    
education.z     -0.0810985    0.0101691 8220.5507442  -7.975  0.00000000000000173 ***
PID.z            0.9792668    0.0115351 8246.0744340  84.894 < 0.0000000000000002 ***
c.ex             0.1366403    0.0078149 8255.4395441  17.485 < 0.0000000000000002 ***
l.ex            -0.0867261    0.0047532 8094.0071038 -18.246 < 0.0000000000000002 ***
cases.z          0.0295554    0.0129040   33.9892491   2.290              0.02833 *  
state.bi        -0.0112124    0.0264556   27.1321735  -0.424              0.67504    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I wonder I should remove az and bz in the model.我想知道我应该删除模型中的azbz But I don't want to do it, since these variables are fundamental for my hypothesis.但我不想这样做,因为这些变量是我假设的基础。 Do you have any solutions?你有什么解决方案?

Also, my second question is -- why do they drop gender ?另外,我的第二个问题是——他们为什么要放弃gender

To awnser your last question first: lme4::lmer reports "fixed-effect model matrix is rank deficient", do I need a fix and how to?首先要解决您的最后一个问题: lme4::lmer 报告“固定效应模型矩阵等级不足”,我是否需要修复以及如何修复?

And the second question : When you obtain a singular fit, this is often indicating that the model is overfitted – that is, the random effects structure is too complex to be supported by the data, which naturally leads to the advice to remove the most complex part of the random effects structure (usually random slopes).而第二个问题:当你得到奇异拟合时,这往往表明模型过拟合——即随机效应结构太复杂,数据无法支持,这自然会导致建议去除最复杂的随机效应结构的一部分(通常是随机斜率)。 The benefit of this approach is that it leads to a more parsimonious model that is not over-fitted.这种方法的好处是它会导致一个更简约的模型,不会过度拟合。

See: https://stats.stackexchange.com/questions/378939/dealing-with-singular-fit-in-mixed-models请参阅: https : //stats.stackexchange.com/questions/378939/dealing-with-singular-fit-in-mixed-models

Let me know if these links helped :)如果这些链接有帮助,请告诉我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM