2
$\begingroup$

I am trying to fit a mixed effects model in python ( using MixedLM model from "statsmodels.regression.mixed_linear_model" ) for inferential purposes.

I have an intercept 'a', a slope variable 'b', and a group variable 'g'. Since the intercept and slope may vary across the group levels in variable 'g', I am using the mixed effects model to allow each group level to have its own random intercept and slope.

I want to get the estimated coefficients for the slope and intercept for each group level separately. However the model mentioned above only seems to return the fixed effects coefficients, and the variance of random effects for slope and intercept.

How can I use this returned output to get an estimated value for the slope and intercept within each group level separately?

$\endgroup$
2
$\begingroup$

You can use MixedLMResults.random_effects to extract the conditional means of random effects, given the data.

$\endgroup$
1
  • $\begingroup$ thank you so much Robert! I can just add these returned random effects to the fixed effect to get a cluster-level parameter correct? $\endgroup$
    – Fiori
    Jun 28 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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