I currently am fitting a mixed model on a data set of n=20,000 and my model takes the following form
mask_model=glmer(y~x_1+x_2+(1+x_3||x_4)+(1|x_5),data=fake_data,family="binomial)
So we have a random intercept and slope for each x_4
group, and a random intercept for each x_5
group.
x_3
takes one of 18 values, x_4
takes one of three values, and x_5
takes one of 20,000 values.
I am able to fit mask_model
in a few minutes. However when I attempt to extract the random effects from this model via ranef(mask_model)
my computer just hangs. This strikes me as strange as I would think when I make the original glmer()
it would calculate these random effects. If I exclude the random intercept involving x_5
, or if I make x_5
only take one of 5000 values then ranef()
seems to work.
Would greatly appreciate any insight into why this might be happening and a potential workaround.
I receive the following output from summary(mask_model)
When I run getME(mask_model, "b") I get a 8625x1 vector, (I have 8619 id's and 3 provinces). It appears to be that this is the conditional mode of the random effects, but ideally I could somehow extract what the id random effect is for each participant, and the random slope/intercept for each province (if that is possible; unfortunately ranef(mask_model) just hangs in R).
summary(test_model)
? Also what happens if you usegetME(test_model, "b")
? $\endgroup$getME()
returns above; is the correct way to interpret this vector byusing getME(mask_model,'Zt')
to find out which entry of the large vector corresponds to which random effect? $\endgroup$Zt
is the transpose of the model matrix for the random effects soZ
determines how the random effects are mapped to the response. But the question in the OP was how to extract the (conditional modes of the) random effects themselves and that's whatgetME(test_model, "b")
should do. $\endgroup$"b"
gives the conditional modes and thenrownames(Z_t)
give which conditional mode corresponds to which grouping (arranged id first, province slope second, province intercept third). Thank you very much for your help! $\endgroup$