drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
60 stars 14 forks source link

emmeans produces strange (wrong) estimates from beta regression after mixed_model #40

Closed yuryzablotski closed 2 years ago

yuryzablotski commented 2 years ago

Dear Author,

thanks for creating such an amazing package!!! I started to use it and love it, especially for the mixed-effects beta regression. However, recently I could not get realistic emmeans. When I calculate a simple percentage of use a mixed effects model with gaussian family (lmer), I do get more realistic estimates. I know that the estimates supposed to be different, but 32% probability instead of 57% is a big difference, so that I am not certain about the inference. Well, the model itself is most likely fine, because when I plot model predictions, I do get realistic probabilities on the y-axis, but the emmean package does not extract them from mided_model (family = beta.fam()), but produces something bizarre. So, if I may, my question is: how get I extract the contrasts from your model, which has two categorical predictors. Here is the code I use:

library(GLMMadaptive) gm <- mixed_model(y ~ x1 * x2, random = ~ 1 | id, data = d, family = beta.fam())

works perfectly!

plot_model(gm, type = "int")+ scale_y_continuous(labels=scales::percent)

does't work properly somehow

emmeans::emmeans(gm, pairwise ~ x1|x2, type = "response")

Thanks forward for your time! Kind regards, Yury

drizopoulos commented 2 years ago

Unfortunately, I cannot help much with this since it is for functionality in another package.