我的 lmer 摘要的"Corr"列在哪里"Random effects?"



我正在使用lmer包来构建一个模型,并希望检查随机效应之间的相关性。

首先我构建了一个tibble:

id <- rep(1:6, each=4) 
group <- rep(c("A","B"), each=12)
type <- rep(c("pencil", "pencil", "pen", "pen"), times=6)
color <- rep (c ("blue", "red"), times = 12)
dv <- c(-24.3854453, 17.0358639, -15.5174479, 8.6462489, -7.0561166, 3.3524410, 21.6199364, -6.1020999, 13.2464223, 20.3740206, 22.8571793, -6.6159629, 18.7898553, -8.2504319, 17.9571641, 2.9555213, -19.5516738, -0.5845135, 9.6041710, -4.1301420, 4.1740094, -24.2496521, 7.4432948, -0.8290391)
sample_data <- as_tibble(cbind(id, group, type, color, dv)

这是我的样本数据:

id   group   type   color  dv
1    A       pencil blue   0.05925979
1    A       pencil red    4.60326151
1    A       pen    blue   -20.72000620
1    A       pen    red    -15.27612843    
2    A       pencil blue   -0.68719576
2    A       pencil red    16.34200026
2    A       pen    blue   18.23954687
2    A       pen    red    21.02837383
3    A       pencil blue   -22.28695974
3    A       pencil red    -18.36587259
3    A       pen    blue   -15.13952913
3    A       pen    red    19.95919637
4    B       pencil blue   -19.52410412
4    B       pencil red    -3.25912890
4    B       pen    blue   -12.11669400
4    B       pen    red    15.93333896
5    B       pencil blue   -17.93575204
5    B       pencil red    -8.58879605
5    B       pen    blue    8.89757943
5    B       pen    red    -13.42995221
6    B       pencil blue   12.03769124
6    B       pencil red    -10.28876053
6    B       pen    blue    7.69523239
6    B       pen    red    -2.94621122

现在我运行我的模型并对其进行总结:

test.model <- lmer(dv ~ 1 + group * type * color + (1 * type * color | id), data = sample_data,  REML = FALSE)
summary(test.model)

这是我的输出:

Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: dv ~ 1 + group * type * color + (1 * type * color | id)
Data: test
AIC      BIC   logLik deviance df.resid 
204.7    216.5    -92.4    184.7       14 
Scaled residuals: 
Min       1Q   Median       3Q      Max 
-2.16529 -0.45429  0.09296  0.62406  1.62720 
Random effects:
Groups   Name        Variance Std.Dev.
id       (Intercept)   4.975   2.23   
Residual             124.228  11.15   
Number of obs: 24, groups:  id, 6
Fixed effects:
Estimate Std. Error       df t value Pr(>|t|)  
(Intercept)                  -0.6679     6.5626  23.8937  -0.102   0.9198  
groupA                       -0.6894     9.2809  23.8937  -0.074   0.9414  
typepencil                  -10.3603     9.1005  18.0000  -1.138   0.2699  
colorblue                    12.3361     9.1005  18.0000   1.356   0.1920  
groupA:typepencil            25.3050    12.8700  18.0000   1.966   0.0649 .
groupA:colorblue             -1.3256    12.8700  18.0000  -0.103   0.9191  
typepencil:colorblue         -0.1705    12.8700  18.0000  -0.013   0.9896  
groupA:typepencil:colorblue -30.4925    18.2010  18.0000  -1.675   0.1112  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) groupA typpnc colrbl grpA:t grpA:c typpn:
groupA      -0.707                                          
typepencil  -0.693  0.490                                   
colorblue   -0.693  0.490  0.500                            
grpA:typpnc  0.490 -0.693 -0.707 -0.354                     
gropA:clrbl  0.490 -0.693 -0.354 -0.707  0.500              
typpncl:clr  0.490 -0.347 -0.707 -0.707  0.500  0.500       
grpA:typpn: -0.347  0.490  0.500  0.500 -0.707 -0.707 -0.707

我想检查随机效应的相关性,但我看不到通常的"相关性";Corr";列(通常出现在"随机效果"下的输出中的"St.Dev."旁边(。它在哪里?

我认为问题源于模型的随机效应部分。您当前拥有:

(1 * type * color | id)

然而,标准公式是:

(1 + type * color | id)

当我运行这个程序时,我得到了一个error,关于观察的数量小于随机效应的数量(这种交互作用使随机效应结构对于样本数据集来说过于复杂(。使用一个不太复杂的随机效应结构(1 + type + color | id),我可以得到你想要的Corr列:

Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: dv ~ 1 + group * type * color + (1 + type + color | id)
Data: sample_data
AIC      BIC   logLik deviance df.resid 
203.8    221.5    -86.9    173.8        9 
Scaled residuals: 
Min      1Q  Median      3Q     Max 
-1.5320 -0.7217  0.1363  0.7089  1.3920 
Random effects:
Groups   Name        Variance Std.Dev. Corr       
id       (Intercept) 130.22   11.411              
typepencil   15.49    3.936    0.42      
colorred    219.98   14.832   -1.00 -0.37
Residual              41.79    6.464              
Number of obs: 24, groups:  id, 6
Fixed effects:
Estimate Std. Error      df t value Pr(>|t|)   
(Intercept)                   9.653      7.572   6.888   1.275  0.24368   
groupB                        2.015     10.708   6.888   0.188  0.85617   
typepencil                  -15.718      5.747  14.358  -2.735  0.01582 * 
colorred                    -11.010     10.059   7.985  -1.095  0.30562   
groupB:typepencil             5.187      8.127  14.358   0.638  0.53333   
groupB:colorred              -1.326     14.226   7.985  -0.093  0.92805   
typepencil:colorred          30.663      7.465  11.996   4.108  0.00145 **
groupB:typepencil:colorred  -30.492     10.556  11.996  -2.889  0.01362 * 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) groupB typpnc colrrd grpB:t grpB:c typpn:
groupB      -0.707                                          
typepencil  -0.174  0.123                                   
colorred    -0.922  0.652  0.117                            
grpB:typpnc  0.123 -0.174 -0.707 -0.083                     
gropB:clrrd  0.652 -0.922 -0.083 -0.707  0.117              
typpncl:clr  0.246 -0.174 -0.649 -0.371  0.459  0.262       
grpB:typpn: -0.174  0.246  0.459  0.262 -0.649 -0.371 -0.707
convergence code: 0
Model failed to converge with max|grad| = 0.00237651 (tol = 0.002, component 1)

我仍然得到一个关于模型未能收敛的warning。这可能再次是由于随机效应结构对于您的样本数据集来说过于复杂:lmer(dv ~ 1 + group * type * color + (1 | id), data = sample_data, REML = FALSE)没有给出这样的警告。

希望有帮助吗?

相关内容

  • 没有找到相关文章

最新更新