RMS Titanic Binary Logistic Case Study
Thanks. I found this thread which is helpful.
I quote Joshua Wiley.
Averaging over fitted values incorporating random effects does not appropriately integrate over the random effects. Specifically, you do not get an estimate of the average marginal effect (AME) in the population that was sample from. You get an estimate in the people sampled.
If the goal is an estimator of the AME in the population, the random effects need to be integrated out. Averaging over
fitted()estimates, whether or not random effects were used in these predictions, is not the same.
joshuawiley.com
Marginal Effects for Mixed Effects Models
This implementation seems to use MC integration. I asked ChatGPT which proposed Gauss-Hermit quadrature to approximate this. After some initial testing the results, at least for a logit link with a random intercept only, are nearly identical to MC integration.
The marginaleffects package also seems to use MC integration, and would thus be suitable for any brms model (?), but very slow.
Side note: If I use a hierarchical model for the analysis of a clinical trial, I would probably not care about this, because RCT (imo) are primarily about inference about the sample, not some hypothetical population.
Discussion in the ATmosphere