I tried using BinomialBayesMixedGLM model in python to fit a logistic model with mixed effects, and for comparison, also fit a binomial model with Lmer from pymer4 library. The fitting was done as follows:
- Using BinomialBayesMixedGLM:
random = {"Intercept RE": '0 + C(G)', "X2 RE": '0 + C(G) * X2'}
model = BinomialBayesMixedGLM.from_formula('Y ~ X1 + X2', random, data)
- using Lmer:
model = Lmer('Y ~ X1 + X2 + (1 + X2 | G)', data=data, family = 'binomial')
However, the posterior mean of the coefficients returned by BinomialBayesMixedGLM is quite different from the fixed effect coefficients returned by Lmer. For X2 variable they even have opposite signs. Why would this be the case ?
BinomialBayesMixedGLM
default to making the two random effects independent? Some packages do, butlmer
doesn't. $\endgroup$