Skip to content

ENH: fit_collinear, unit tests and make public, advertise #8580

Open

Description

@josef-pkt

see also #4705 and #6935

_fit_collinear is a private method

We need something public that drops collinear columns.
Main work will be to add unit tests for extra keywords in model.__init__ for _fit_zeros which is also private and not in docs.
possible solution: add public fit_collinear only to models that we have checked, unit tested, but not generically in base.

current fit_collinear uses a single QR decomposition.
In a multicollinearity PR, I also have sequential dropping, new QR after dropping a column (AFAIR)

I was trying out scipy pivoting QR q, r, p = linalg.qr(a, mode='economic', pivoting=True)
but again it looks kind of arbitrary which columns need to be dropped

Activity

  1. added this to the 0.15 milestone on Dec 16, 2022
  2. josef-pkt commented on Mar 6, 2023

    @josef-pkt
    MemberAuthor

    for linear models like OLS

    I guess if users have to explicitly request method - "qr-piv" or "qr-seq", then it is explicit enough that there are multi- or perfect collinearities.

    related discussion, PR in scipy scipy/scipy#18097

  3. josef-pkt commented on Jun 7, 2024

    @josef-pkt
    MemberAuthor

    bump
    we had a new question/proposal for dropping on mailing list "Elimination of singular variables from linear regressions"

    we have unit test for _fit_collinear in base test_generic_methods, but it only verifies params table (params, bse, tvalues, pvalues) and predict.

    related:
    fit_constrained is missing in linear regression models, AFAIR
    OLS has partially implemented offset, used for regularized coordinate descend for elastic net, only internal kwd
    (AFAICS, mainly in loglike and not in fit)

  4. josef-pkt commented on Nov 5, 2025

    @josef-pkt
    MemberAuthor

    bump

    needs more unit test
    and degrees of freedom in F/Wald test needs to be fixed.
    Based on an example, I don't get the correct df for the constraints in wald_test_terms and anova_lm in OLS.
    I did not check again the examples with GLM and discrete (which were my main working cases in the previous times)

    otherwise it looks like it works fine for OLS

    same with _fit_zeros

    aside: linear models, OLS don't have fit_constrained, but I don't find an issue for it.
    I thought we had and issue.
    Main point I got stuck with before was no offset in linear models to directly correct for affine constraints.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions