I am performing a logistic mixed effects regression on some data I have. There are 201 participants answering a question over 6 time points. The model includes 4 fixed effects: X1, X2, X3, and Time. It also includes a random intercept and a random slope for time, under grouping variable id.

I am interested in the marginal effect of time on the response y. Since I have a random slope, I am using package GLMMadaptive that allows specification of a mixed effects model (thus allowing specification of a random slope) and then allows estimation of the marginal effect as well.

I know in general the conditional and marginal effects can be quite different. However, when I run the code the differences are surprisingly(?) large. For example, whereas the conditional OR for a 1 unit change in time is over 13% increase, the corresponding marginal OR is less than 1% increase. Although I understand why the estimates usually differ, I find such large difference heavily unintuitive. It is very odd that for each specific person the estimated likelihood of yes will increase between the first and last (6th) time point by around ~85%, whereas the corresponding average population likelihood will increase by less than 5%.

Can someone point me to an explanation? What can be the source of such large discrepancy?

Here is my code. First the conditional estimates:

mm = mixed_model(fixed = Y ~ X1 + X2 + X3 + time, random = ~1+time|id, family = "binomial", data = dat )

mixed_model(fixed = Y ~ X1 + X2 + X3 + time, random = ~1 + time | 
    id, data = dat, family = "binomial")

Data Descriptives:
Number of Observations: 1206
Number of Groups: 201 

 family: binomial
 link: logit 

Fit statistics:
 log.Lik  AIC  BIC
   -1259 2533 2560

Random effects covariance matrix:
              StdDev    Corr
(Intercept)  13.3281        
time          1.2752 -0.4208

Fixed effects:
            Estimate Std.Err z-value p-value
(Intercept)  -11.497  0.7559 -15.211 <0.0001
X1             0.475  0.1377   3.452  0.0006
X2             0.334  0.0868   3.849  0.0001
X3             0.194  0.2026   0.958    0.34
time           0.123  0.0640   1.925    0.05

method: adaptive Gauss-Hermite quadrature rule
quadrature points: 11

method: hybrid EM and quasi-Newton
converged: TRUE

And the marginal effects:

marginal_coefs(mm, std_errors = TRUE)

    Estimate Std.Err z-value p-value
(Intercept)  -1.4855  0.1595  -9.313 <0.0001
X1            0.0629  0.0195   3.220   0.001
X2            0.0454  0.0118   3.844  0.0001
X3            0.0245  0.0271   0.904   0.366
time          0.0089  0.0147   0.602   0.547

1 Answer 1


The reason why you see this big difference is because the variance of your random effects is quite big. To see why is this happening, check slide 334 in my course notes for Repeated Measurements. That is, in the case you have only random intercepts, you have the relation $$\beta^M = \frac{\beta^{SS}}{\sqrt{1 + 0.346 \sigma_b^2}},$$ where $\beta^M$ are the coefficients with a marginal interpretation, $\beta^{SS}$ the coefficients with conditional on the random effects interpretation, and $\sigma_b^2$ the variance of the random intercepts. Hence, the bigger the variance, the larger the difference between the two sets of coefficients.

In your case, you have random intercepts and random slopes, and this formula does not directly apply, but the same logic and effect applies.

  • $\begingroup$ That makes sense, thanks! Can I also ask, if I have a model with two grouping variables and each has only a random intercept (no slope), does this or a similar formula applies? If so, which variance is used in it? $\endgroup$
    – Cuenco
    Jan 2, 2019 at 11:47
  • $\begingroup$ AFAIK there is no extension of the formula above in this case. $\endgroup$ Jan 2, 2019 at 11:55
  • $\begingroup$ Have you got a source for the above adjustment factor of $(1+0.346\sigma^2)^{-1/2}$? In Agresti's book on categorical analysis, an adjustment factor of $(1+0.6\sigma^2)^{-1/2}$ is given instead, see math.ntnu.no/emner/TMA4315/2019h/agresti.pdf, p. 499, eq. 12.8. $\endgroup$ Nov 9, 2022 at 15:06
  • $\begingroup$ As far as I remember it is in the book of Geert Molenberghs and Geert Verbeke for categorical longitudinal data. $\endgroup$ Nov 10, 2022 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.