I am trying to replicate the following R code for GLMER
lm1 <- glmer(correct~type+(1+type|subject_id) + (1|category), df %>% filter(type!="target"), family = binomial())
lmnull <- glmer(correct~1+(1+type|subject_id) + (1|category), df %>% filter(type!="target"), family = binomial())
to Python using
import statsmodels.formula.api as smf
df = df[df['type'] != 'target']
model = smf.mixedlm("correct~ C(type) + .......", df, groups="subject_id*").fit()
model = smf.mixedlm("correct~ 1 + .......", df, groups="subject_id*").fit()
I am stucked with trying to find a way to replicate the R formula. Anyone has any idea on how to do it? I am using the same dataframe for both codes.