I'm trying to run a binary logit regression on hierarchical data using python, and I cannot find a way to do that. Any help is appreciated.
The dataset has the following variables:
- Accuracy, the binary response variable
- Mask, the type of mask used, a categorical variable with 3 categories
- Position, where on the screen the stimulus is presented, categorical with 3 categories
- RT, reaction time, a metric variable
- subjectID, the grouping variable, because it is repeated measure
Currently, I am trying to use statsmodels:
import statsmodels.formula.api as smf
md = smf.logit("Accuracy ~ Mask * RT + Position", data, groups = "subjectID")
Unfortunately, smf.logit()
does not account for multilevel data and will just ignore the groups = "subjectID"
, giving a ValueWarning: unknown kwargs ['groups']
.
I have also tried using sklearn.linear_model.LogisticRegression
but as far as I'm aware, that doesn't accept categorical independent variables.
Does anyone know how to do this? Thank you so much.