Hi,
I'm trying to create a linear mixed model with nested random effects. Kerby Sheddon
proposed an interesting structure to include one variable nested in another. But I can't figure out how to play with this structure to fit my needs. In particular, what should be specified in re_formula and what mean the zero and the
C() in
{'subject' : '0 + C(subject)'}. In the end, I would like to do in Python like I would do in R:
library(nlme)
mlm = lme(Weight ~ Dose,
random = ~ 1 + 1|Year/Site/Block,
data=data)
In Python?
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
mlm = smf.mixedlm("Weight ~ Dose",
groups="Year",
re_formula="1",
vc_formula={"Site": "0+C(Site)", "Block": "0+C(Block)"},
data=data).fit()
Thanks!