r - 如何修复线性混合模型中的奇异拟合?

标签 r lme4 mixed-models

我正在运行一个线性混合模型,以查看任务的 react 时间是否因受试者、实验条件或目标而异。然而,当我运行 lme 时,它​​会警告我有关奇异拟合的情况。

我知道奇异拟合可能表明模型过度拟合,但我不明白为什么我的模型与我拥有的数据量过度拟合。

欲了解更多信息,该实验要求受试者说出一系列图片,并记录 react 时间 (RT)。每个参与者都会看到所有图片(目标)并拥有全部 4 个条件。有 440 个目标,每种条件有 110 个目标。

我的第一个模型没有单一的合身问题:

model1 = lmer(log(RTs300ms)~Condition+(1|Targets)+(1|Subject),data=beh_acc2)


REML criterion at convergence: -6030.481
Random effects:
 Groups   Name        Std.Dev.
 Targets  (Intercept) 0.07918 
 Subject  (Intercept) 0.13678 
 Residual             0.17972 
Number of obs: 10985, groups:  Targets, 110; Subject, 27
Fixed Effects:
  (Intercept)    ConditionTh  ConditionUnTa  ConditionUnTh  
      6.67960       -0.03549       -0.01475       -0.01700  

但是从我的第二个模型开始,我开始遇到问题:

model2 = lmer(log(RTs300ms)~Condition+(1|Targets)+(1+Condition|Subject),data=beh_acc2)

REML criterion at convergence: -6037.6

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-7.3985 -0.6456 -0.1593  0.4551  5.3105 

Random effects:
Groups   Name          Variance  Std.Dev. Corr             
Targets  (Intercept)   6.270e-03 0.079184                  
 Subject  (Intercept)   1.947e-02 0.139546                  
          ConditionTh   2.482e-05 0.004982  0.58            
          ConditionUnTa 2.273e-04 0.015078 -0.50  0.41      
          ConditionUnTh 1.200e-04 0.010956 -0.64  0.26  0.99
 Residual               3.226e-02 0.179597                  
Number of obs: 10985, groups:  Targets, 110; Subject, 27

Fixed effects:
               Estimate Std. Error t value
(Intercept)    6.679624   0.028108 237.641
ConditionTh   -0.035441   0.004949  -7.162
ConditionUnTa -0.014807   0.005648  -2.621
ConditionUnTh -0.017071   0.005293  -3.225

Correlation of Fixed Effects:
            (Intr) CndtnT CondtnUnT
ConditionTh  0.022                 
ConditinUnT -0.321  0.463          
ConditnUnTh -0.321  0.471  0.597   
convergence code: 0
boundary (singular) fit: see ?isSingular

理想情况下,我希望我的最终模型能够工作,但它是三个模型中最复杂的:

model3 = lmer(log(RTs300ms)~Condition+(1+Condition|Targets)+(1+Condition|Subject),data=beh_acc2)

REML criterion at convergence: -6068.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-7.3684 -0.6393 -0.1575  0.4541  5.2834 

Random effects:
 Groups   Name          Variance  Std.Dev. Corr             
 Targets  (Intercept)   6.931e-03 0.083252                  
          ConditionTh   1.008e-03 0.031748 -0.19            
          ConditionUnTa 1.419e-03 0.037676 -0.35  0.58      
          ConditionUnTh 1.727e-03 0.041553 -0.29  0.72  0.98
 Subject  (Intercept)   1.951e-02 0.139662                  
          ConditionTh   2.575e-05 0.005074  0.57            
          ConditionUnTa 2.371e-04 0.015399 -0.50  0.43      
          ConditionUnTh 1.237e-04 0.011124 -0.63  0.28  0.99
 Residual               3.187e-02 0.178527                  
Number of obs: 10985, groups:  Targets, 110; Subject, 27

Fixed effects:
               Estimate Std. Error t value
(Intercept)    6.679466   0.028234 236.574
ConditionTh   -0.035074   0.005785  -6.063
ConditionUnTa -0.014748   0.006706  -2.199
ConditionUnTh -0.016823   0.006607  -2.546

Correlation of Fixed Effects:
            (Intr) CndtnT CondtnUnT
ConditionTh -0.008                 
ConditinUnT -0.325  0.497          
ConditnUnTh -0.306  0.548  0.722   
convergence code: 0
boundary (singular) fit: see ?isSingular

我不确定如何解决 model2 和 model3 上出现的奇异拟合问题。我读过一些尝试贝叶斯模型的建议,但我对此并不熟悉。

关于此问题的任何建议或进一步建议将不胜感激!

最佳答案

在您的第一个模型中,不包含任何随机效应。但是,在返回错误的模型中,您现在已经包含了条件的随机效应。我的猜测是,条件的影响实际上不存在随机性。

您可以使用以下代码检查 lme4 中的 rePCA 函数:summary(rePCA(model2))。结果将提供一个表格,其中提供随机效应结构中解释的方差比例。如果您有任何列解释了接近 0 比例的方差,则这可能是问题所在,并导致奇异拟合误差。确认这一点的另一种方法是绘制参与者每个条件的平均 RT,以创建所谓的“意大利面条图”。添加线路并按参与者对它们进行分组,以便您可以看到参与者针对每个条件的 RT 变化。如果这些线都是平行的(或接近平行的),那么这表明条件的影响可能不存在随机性。

关于r - 如何修复线性混合模型中的奇异拟合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57700917/

相关文章:

r - 锁定或保护 R 中的 data.table

斯坦福解析器的 R 接口(interface)

r - lme4 错误 : boundary (singular) fit: see ? isSingular

r - 在 lme4 中查看标准误差和参数估计

r - lsmeans 和 difflsmeans 不返回 lmer 对象的输出

r - 了解 r lme4 中混合模型的警告消息

r - 在 R 中使用 Open Street Map 和 get_osm {osmar}

日期属性为 : error instantiating 的 R S4 类

r - 德雷克计划拟合 lmer 模型失败

r - 编写循环/函数来生成各种混合模型结果