为什么在lme4中强制随机斜率和截距之间没有相关性时,我会得到两个随机斜率项?

时间:2017-09-05 23:15:49

标签: r regression logistic-regression lme4 mixed-models

我正在使用R中的lme4运行混合效果逻辑回归。

我有一个预测器,它是一个二分类变量。它被编码为1/0并被定义为因子。

我发现随机项拦截与我的预测器的随机项斜率完全相关。因此,我使用以下代码运行一个新模型,在这个模型中它们是不相关的:

m1<-glmer(DV~1+PPTGender+(1|Subject)+(1+PPTGender||Item), data = data, family = "binomial")

然而,输出给出了两个随机斜率项:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: DV ~ 1 + PPTGender + (1 | Subject) + (1 + PPTGender ||      Item)
   Data: data

     AIC      BIC   logLik deviance df.resid 
   499.7    526.9   -242.9    485.7      353 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.7334 -1.0057  0.6312  0.8807  1.3858 

Random effects:
 Groups       Name              Variance  Std.Dev.  Corr 
 Subject      (Intercept)       6.323e-10 2.514e-05      
 Item         (Intercept)       2.785e-09 5.278e-05      
 Item.1       PPTGender0        5.229e-01 7.231e-01      
              PPTGender1        6.889e-03 8.300e-02 -1.00
Number of obs: 360, groups:  Subject, 60; Item, 36

Fixed effects:
               Estimate Std. Error z value Pr(>|z|)
(Intercept)     0.28229    0.17833   1.583    0.113
PPTGender -0.07718    0.29534  -0.261    0.794

Correlation of Fixed Effects:
            (Intr)
PPTGndr     -0.635

任何人都能解释为什么会这样吗?

如果我将PPTGender变量重新定义为数字字符变量,如下所示:

data$PPTGender<-as.numeric(as.character(data$PPTGender))

它消失了:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: DV ~ 1 + PPTGender + (1 | Subject) + (1 + PPTGender ||      Item)
   Data: data

 AIC      BIC   logLik deviance df.resid 
   500.8    520.2   -245.4    490.8      355 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.4075 -1.0489  0.7410  0.8472  1.1603 

Random effects:
 Groups       Name          Variance  Std.Dev. 
 Subject      (Intercept)   3.638e-10 1.907e-05
 PairNumber   (Intercept)   2.081e-01 4.562e-01
 PairNumber.1 PPTGender     1.091e-08 1.044e-04
Number of obs: 360, groups:  Subject, 60; Item, 36

Fixed effects:
              Estimate Std. Error z value Pr(>|z|)  
(Intercept)    0.26056    0.14625   1.782   0.0748 .
PPTGender     -0.03009    0.26720  -0.113   0.9103  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr)
PPTGendr    -0.397

这只是R中的怪癖吗?后一种方法有什么问题吗?

0 个答案:

没有答案