Skip to content

ENH: helper function is_nested, support for nested categorical #5722

Open

Description

@josef-pkt

a helper function in the old formula code
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/formula.py#L655

We don't have any explicit support for nested categoricals,
patsy does something but I never looked closely and it looked like just data handling without handling implications for identifiability

We have one or several issues with an example where nested dummies caused problems. (which issue?)

related
#5364 score test and similar with collinear columns
e.g. when we are binning to create bin or group dummies we need to check the rank or check for collinearity.

Activity

  1. josef-pkt commented on Nov 17, 2025

    @josef-pkt
    MemberAuthor

    update:
    the module with the isnested helper function has been deleted.
    However, it checks the formula and does not use linear algebra or similar, so it's not generally useful
    https://github.com/statsmodels/statsmodels/blob/v0.4.0/statsmodels/sandbox/formula.py#L652

    Aside:
    I tried out nested categorical in two-way anova recently and patsy looks a bit fragile. (topic ICC with raters nested in main categorical).
    I did not try out formulaic for it.
    (Two-way nested anova is a pain.
    Because of the nested pattern, the anova is not balanced, and therefore the split in different effects depends on the encoding. Changing which interaction terms are included, or which redundant columns are dropped, changes the results of the hypothesis tests. I did not see how we could test whether the main categorical (species) has an effect when the nested effect (workers) is present. I never read the literature on nested effects.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions