我正在估计一个多级逻辑回归,以预测在给定试验中出错的可能性。该模型具有参与者、场景和参与者的随机效应,以及基于两个变量及其相互作用的固定效应。结果如下:
a1 <- glmer(errorDummy ~ race*object + #fixed effects
(1|participant) + (1|scenario) + (1|actor), #random effects
data = df,
control = glmerControl(optimizer="bobyqa"),
family = binomial(link = "logit")) #binomial
print(summary(a1), correlation = F) #decision to shoot
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial ( logit )
Formula: errorDummy ~ race * object + (1 | participant) + (1 | scenario) + (1 | actor)
Data: df
Control: glmerControl(optimizer = "bobyqa")
AIC BIC logLik deviance df.resid
6704.4 6759.2 -3345.2 6690.4 18397
Scaled residuals:
Min 1Q Median 3Q Max
-2.557 -0.230 -0.108 -0.045 40.303
Random effects:
Groups Name Variance Std.Dev.
participant (Intercept) 0.6115 0.7820
actor (Intercept) 0.8919 0.9444
scenario (Intercept) 1.3102 1.1446
Number of obs: 18404, groups: participant, 630; actor, 20; scenario, 8
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.1705 0.4666 -8.938 <2e-16 ***
raceblack 0.1942 0.4410 0.440 0.66
objectgun -2.9482 0.1059 -27.846 <2e-16 ***
raceblack:objectgun -0.3143 0.2074 -1.516 0.13
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
该模型表明,此任务中的错误并不常见。但是,它们确实因场景而异:
coef(a1)$scenario
(Intercept) raceblack objectgun raceblack:objectgun
alley -2.331117 0.1942088 -2.948222 -0.3142849
domesticphone -3.539802 0.1942088 -2.948222 -0.3142849
grocery -5.314944 0.1942088 -2.948222 -0.3142849
parkinglot -4.098250 0.1942088 -2.948222 -0.3142849
pulloverday -3.084138 0.1942088 -2.948222 -0.3142849
pullovernight -3.971451 0.1942088 -2.948222 -0.3142849
sidewalk -5.619601 0.1942088 -2.948222 -0.3142849
warehouse -4.539444 0.1942088 -2.948222 -0.3142849
我想要的是对比例尺度上八个场景中的每一个的条件模式(最佳线性无偏预测?)的估计。也就是说,我想要估计在给定场景的试验中出错的可能性。
我知道在非多级逻辑回归中为截距执行此操作的公式为 p = exp(logit) / (1 + exp(logit)。这将转化为 p = exp(-4.1705) / (1 + exp(-4.1705)). 但我确信这在具有随机因素的多级上下文中是有问题的。
在给定的场景中,估计在试验中出错的可能性的适当方法是什么?R 中是否有可能内置此功能的软件包?