Skip to content

diagnostic for nonlinear: multicollinearity #2157

Open

Description

@josef-pkt

http://stackoverflow.com/questions/27651702/checking-for-multicollinearity-in-python

I don't think we have any ready made standalone functions either for an exog directly, of for the results (score_obs ?) of an estimation result of discrete or GLM.

see also #1534 for some problems

update

We should add multi-collinearity and collinearity/singular measures to get_diagnostic.
Those can be directly based on X, score_obs, hessian and/or cov_params.
We can have multicollinearity or near-singularity problems in the estimation results in non-linear models even when hessian inversion does not fail (which raises a warning).

However, adding them only to get_diagnostic will not make them available for results.summary().
Summary should add a extra_text warning for small eigenvalues and large condition number also for non-linear models.

Activity

  1. jseabold commented on Jan 9, 2015

    @jseabold
    Member

    Dupe of #2062?

  2. josef-pkt commented on Jan 9, 2015

    @josef-pkt
    MemberAuthor

    No, not really a duplicate, just closely related topic.
    #2062 is to handle numerical perfect collinearity, and by extension maybe regularized versions of near perfect collinearity.

    The issue here is to provide users which tools to identify or diagnose multicollinearity problems, whether they are strong enough for purely numerical problems or not.
    Like VIF for exog, instead of a post-estimation diagnostic for OLS.

  3. josef-pkt commented on Nov 7, 2017

    @josef-pkt
    MemberAuthor

    two more stackoverflow questions about how to identify collinear variables in the last few days.

    update:

    related: partial correlation linalg computation requires invertible correlation matrix inv(corr). So cannot be directly used for perfectly collinear variables.

  4. josef-pkt commented on Nov 7, 2017

    @josef-pkt
    MemberAuthor

    reminder #2380 has some of the function but fails now in singular case in one travis, i.e. don't use inv of singular matrix

    I think the problem is that we need to distinguish essential singularity (subject to numerical noise) from high collinearity. The inv versions are designed for the latter.
    But regularization using pinv or Ridge changes the behavior and results.

  5. josef-pkt commented on Nov 7, 2017

    @josef-pkt
    MemberAuthor

    Need a FAQ and SUMM: (there are many open issues, e.g. #3367 #2628 #1717 #1534 )

    in the spirit of "avoid numerical ambiguities" i.e. avoid results driven by numerical noise or "arbitrary" thresholds.

    either

    • use regularized to handle high and perfect multi-collinearity, or
    • stay far enough away from near singular cases, and look at only high multi-collinearity but not near singular. That is consider multicollinearity as a statistical or econometrics problem without numerical problems.
  6. josef-pkt commented on Jan 4, 2020

    @josef-pkt
    MemberAuthor

    just an implementation thought: vif and other multicollinearity measures based on weighted x'x

    In GLM and discrete we (should) have a hessian_factor, i.e. hessian is related to x' @ diag(w) @ x where w is the hessian factor.
    This means we could use the same measures as for WLS, just use weighted x, e.g. sqrt(w) * x
    similarly we could use score_obs for OPG variance, i.e score_factor * x

    see also #1534 for perfect collinearity, singular matrix problems in GLM and discrete.

  7. josef-pkt commented on Jun 24, 2020

    @josef-pkt
    MemberAuthor

    multicollinearity with weights (I downloaded it in 2017, but don't remember reading it)

    Huang, Chien-Chia L., Yow-Jen Jou, and Hsun-Jung Cho. 2016. “A New Multicollinearity Diagnostic for Generalized Linear Models.” Journal of Applied Statistics 43 (11): 2029–43. https://doi.org/10.1080/02664763.2015.1126239.

    also, (I think I never looked more closely into the GLM multicollinearity literature like)

    Lesaffre, Emmanuel, and Brian D. Marx. 1993. “Collinearity in Generalized Linear Regression.” Communications in Statistics - Theory and Methods 22 (7): 1933–52. https://doi.org/10.1080/03610929308831126.

    Mackinnon, Murray J., and Martin L. Puterman. 1989. “Collinearity in Generalized Linear Models.” Communications in Statistics - Theory and Methods 18 (9): 3463–72. https://doi.org/10.1080/03610928908830102.
    (includes Ridge and bounds on WLS condition number )

  8. josef-pkt commented on Jul 3, 2020

    @josef-pkt
    MemberAuthor

    R package car uses a vif computation based on cov_params
    https://stats.stackexchange.com/questions/474964/calculating-variance-inflation-factor-for-logistic-regression-using-statsmodels/475233#475233

    The actual computation in the car package is different and uses det of partitioned correlation matrix as in the generalized vif article Fox, J. and Monette, G. (1992)

    So far I haven't found a reference that explains or justifies this for the GLM case.

    older article by Weissfeld defines condition indices based on scaled cov_params (EIM) for GLM, no vif
    car package uses the same scaled cov for vif

    Lisa A. Weissfeld & Susan M. Sereika (1991) A multicollinearity diagnostic for
    generalized linear models, Communications in Statistics - Theory and Methods, 20:4, 1183-1198,
    https://doi.org/10.1080/03610929108830558

  9. josef-pkt commented on Jul 3, 2020

    @josef-pkt
    MemberAuthor

    trying this out with Logit and GLM-Binomial

    3 versions with similar values, based on

    • wls/irls wexog (only directly available for GLM irls)
    • hessian, cov_params
    • score_obs, OPG
    wex = p02a_glm.results_wls.model.wexog
    np.diag(np.linalg.inv(np.corrcoef(wex.T)))
    array([ 1.01182126,  1.10130972, 35.25156351, 35.60461122])
    
    vif_cov  # from cov_params, car package
    array([ 1.01630581,  1.10722033, 35.22711273, 35.5827284 ])
    
    scg = p02a_glm.model.score_obs(p02a_glm.params)
    np.diag(np.linalg.inv(np.corrcoef(scg.T)))
    array([ 1.11004267,  1.12474352, 26.97380377, 27.65079399])
    

    for Logit, observed and expected hessian are the same, so no distinction there.

    I don't know when OPG and Hessian are identical as in OLS.
    I thought it is the case with canonical link like Logit, but it's not.

    update
    There are still problems with the constant. The above was computed for demeaned slope exog, i.e. exog is orthogonal between constant and slope variables.
    When constant is included without demeaning other variables, then numbers are all over the place.

    maybe we need to absorb constant, i.e. condition on constant column to remove it's effect.
    i.e. need partial inverse or conditioning as in sweep algorithm PR #6268

  10. josef-pkt commented on Jul 6, 2020

    @josef-pkt
    MemberAuthor

    references for specific methods

    • scaled cov_params Weissfeld and Sereika 1991 used for condition index, EIM - Fisher scoring, irls, or OIM - Newton-Raphson
      recommend not to demean original exog for condition index, as by Belsley, Kuh, Welsch
    • WLS wexog
      • MacKinnon and Puterman 1989. using irls (EIM) weights, assumes original exog are scaled as desired, no rescaling of wexog
        only condition number
      • Smith and Marx, Environmetrics 1990: wexog from irls, centered and scaled (correlation matrix), vif = diag(inv(corr)) and condition number of corr.
  11. josef-pkt commented on Jul 6, 2020

    @josef-pkt
    MemberAuthor

    one thing I'm not sure about yet, i.e. how much does it matter

    cov_params is the inv of hessian/OIM/EIM/OPG, in one case we standardize cov of some data in the other we standardize inverse of it.

    condition indices are just reordered, but I don't know how it affects a vif definition.

  12. josef-pkt commented on Sep 11, 2021

    @josef-pkt
    MemberAuthor

    a reference for nonlinear:
    condition indices based on hessian, irls wexog for logit and cox proportional hazard

    Wax, Yohanan. "Collinearity diagnosis for a relative risk regression analysis: An application to assessment of diet‐cancer relationship in epidemiological studies." Statistics in medicine 11, no. 10 (1992): 1273-1287.

    scaled to unit length as in Belsley kuh welsch

  13. added this to the 0.15 milestone on Mar 25, 2023
  14. josef-pkt commented on Aug 12, 2024

    @josef-pkt
    MemberAuthor

    found by chance

    graphpad prism has warnings for unstable parameters and "ambiguous" models (i.e. parameters not well identified)

    https://www.graphpad.com/guides/prism/latest/curve-fitting/reg_how-prism-identifies-unstable-.htm
    https://www.graphpad.com/guides/prism/latest/curve-fitting/reg_unstable.htm

    threshold is condition number of hessian greater than 10/sqrt(epsilon), where epsilon is the 64 bit machine epsilon 2.22e-16 (= 2**(-52) ),

    that is, we can add warning directly based on hessian which will work for any model.
    see #7695

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