0

I'm going through a tutorial on mixed-effects models in Python.

I'm building a model where litter is the random effect. In the tutorial, the output contains the variance across the litter intercepts. However, in Bayesian hierarchical modeling, I'm also able to see the intercepts for every level of the random effect variable.

How would I see that here?

import pandas as pd
import statsmodels.api as sm
import scipy.stats as stats
import statsmodels.formula.api as smf

df = pd.read_csv("http://www-personal.umich.edu/~bwest/rat_pup.dat", sep = "\t")

model = smf.mixedlm("weight ~ litsize + C(treatment) + C(sex, Treatment('Male')) + C(treatment):C(sex, Treatment('Male'))",
                    df,
                    groups= "litter").fit()
model.summary()

I would also ideally like to see the estimate of the intercept across all litters. Then, how would I interpret that overall intercept compared to the intercept for each single litter?

If there's a better Python package for what I'm striving for, please suggest.

matsuo_basho
  • 2,833
  • 8
  • 26
  • 47

0 Answers0