StatsModels: get levels and model matrix for each level of categorical term

I have dataframe (df) with categoricals factors and i make schema fs = apply_schema(someterm, StatsModels.schema(df)) (where someterm is InteractionTerm). Then I want to get a vector of levels and then get a submatrix of the model matrix for each level.
From one side I can get mx = modelcols(fs, df) and then get view(mx, :, levelrange), but how to get column range for each level? Or how to get a map of the model matrix column to levels? Or there is no such functionality in StatsModels?

1 Like