Skip to content

ENH: Reduced exog column space, svd, qr #2062

Open

Description

@josef-pkt

tools, infrastructure and pattern for supporting perfectly collinear exog

we need a helper function to get the reduced full rank exog either using svd or pivoting QR (now available in minimum scipy IIRC)
pivoting QR might will not drop sequentially (reading the docstring), we might need explicit check instead for colinear columns instead.
#1061 colinear exog in auxiliary regression: we only need the rank but using pinv on full, possibly singular exog might be wasteful

drop collinear columns in regression, and nan results
we have infrastructure for nandot and nans in the t_test, but it might not be generically accessible (only for fit_regularized in discrete?)
this is user facing.

use reduced exog for non-linear MLE optimization, internal reparameterization.
can be user facing with nans and reduced rank QR, or purely internal with SVD.

Activity

  1. josef-pkt commented on Oct 26, 2014

    @josef-pkt
    MemberAuthor

    another issue: the actual estimation is with a different exog than the one that is attached.
    The current pattern that I was planing for this case is to use fit_transformed that similarly to fit_constrained creates an auxiliary model.
    The difference is that the constrained case and the pinv/svd/pca case don't have nans in the bse, but instead report a singular covariance matrix.

  2. josef-pkt commented on Apr 5, 2015

    @josef-pkt
    MemberAuthor

    fit_constrained can also be reused for setting singular/redundant columns to zero
    spector example from discrete test suite

    GLM example

    >>> mod_glm_singular = sm.GLM(data.endog, np.column_stack((data.exog, data.exog[:,0])), family=sm.families.Binomial(link=sm.families.links.probit))
    >>> res_glm_singular = mod_glm_singular.fit()
    >>> print(res_glm_singular.summary())
                     Generalized Linear Model Regression Results                  
    ==============================================================================
    Dep. Variable:                      y   No. Observations:                   32
    Model:                            GLM   Df Residuals:                       28
    Model Family:                Binomial   Df Model:                            3
    Link Function:                 probit   Scale:                             1.0
    Method:                          IRLS   Log-Likelihood:                -12.819
    Date:                Sun, 05 Apr 2015   Deviance:                       25.638
    Time:                        09:52:01   Pearson chi2:                     26.3
    No. Iterations:                     8                                         
    ==============================================================================
                     coef    std err          z      P>|z|      [95.0% Conf. Int.]
    ------------------------------------------------------------------------------
    x1             0.8129      0.345      2.357      0.018         0.137     1.489
    x2             0.0517      0.081      0.637      0.524        -0.107     0.211
    x3             1.4263      0.587      2.430      0.015         0.276     2.577
    const         -7.4523      2.572     -2.898      0.004       -12.492    -2.412
    x4             0.8129      0.345      2.357      0.018         0.137     1.489
    ==============================================================================
    
    
    >>> res_glm_singular_c = mod_glm_singular.fit_constrained('x4=0')
    >>> print(res_glm_singular_c.summary())
                     Generalized Linear Model Regression Results                  
    ==============================================================================
    Dep. Variable:                      y   No. Observations:                   32
    Model:                            GLM   Df Residuals:                       29
    Model Family:                Binomial   Df Model:                            2
    Link Function:                 probit   Scale:                             1.0
    Method:                          IRLS   Log-Likelihood:                -12.819
    Date:                Sun, 05 Apr 2015   Deviance:                       25.638
    Time:                        09:52:45   Pearson chi2:                     26.3
    No. Iterations:                     1                                         
    ==============================================================================
                     coef    std err          z      P>|z|      [95.0% Conf. Int.]
    ------------------------------------------------------------------------------
    x1             1.6258      0.690      2.357      0.018         0.274     2.978
    x2             0.0517      0.081      0.637      0.524        -0.107     0.211
    x3             1.4263      0.587      2.430      0.015         0.276     2.577
    const         -7.4523      2.572     -2.898      0.004       -12.492    -2.412
    x4                  0          0        nan        nan             0         0
    ==============================================================================
    
    Model has been estimated subject to linear equality constraints.
    

    compare with model without duplicate column

    >>> mod_glm = sm.GLM(data.endog, data.exog, family=sm.families.Binomial(link=sm.families.links.probit))
    >>> res_glm = mod_glm.fit()
    >>> print(res_glm.summary())
                     Generalized Linear Model Regression Results                  
    ==============================================================================
    Dep. Variable:                      y   No. Observations:                   32
    Model:                            GLM   Df Residuals:                       28
    Model Family:                Binomial   Df Model:                            3
    Link Function:                 probit   Scale:                             1.0
    Method:                          IRLS   Log-Likelihood:                -12.819
    Date:                Sun, 05 Apr 2015   Deviance:                       25.638
    Time:                        09:48:37   Pearson chi2:                     26.3
    No. Iterations:                     8                                         
    ==============================================================================
                     coef    std err          z      P>|z|      [95.0% Conf. Int.]
    ------------------------------------------------------------------------------
    x1             1.6258      0.690      2.357      0.018         0.274     2.978
    x2             0.0517      0.081      0.637      0.524        -0.107     0.211
    x3             1.4263      0.587      2.430      0.015         0.276     2.577
    const         -7.4523      2.572     -2.898      0.004       -12.492    -2.412
    ==============================================================================
    
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions