I am estimating a multilevel logistic regression predicting the likelihood of making an error on a given trial. The model has random effects of participant, scenario, and actor, as well as fixed effects based on two variables and their interaction. The results are below:
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
The model shows that errors are uncommon in this task. However, they do vary across scenario:
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
What I want is an estimate of the conditional modes (Best Linear Unbiased Prediction?) for each of the eight scenarios on the proportion scale. That is, I want an estimate of the likelihood of making an error on a trial for a given scenario.
I know that the formula to do this for, say, the intercept, in a non-multilevel logistic regression would be p = exp(logit) / (1 + exp(logit). Which would translate into p = exp(-4.1705) / (1 + exp(-4.1705)). But I am sure this is problematic in a multilevel context with random factors.
What is the appropriate way to estimate the likelihood of making an error on a trial in a given scenario? And are there packages available in R that might have this functionality built in?