Skip to content

TST more unit tests for GLM - discrete #2350

Open

Description

@josef-pkt

test_glm.py has CheckComparisonMixin but it is not used for all families, and doesn't check enough of the attributes.

example: GLM llnull has no test coverage, but glm and discrete should coincide, see #2349
(I just checked it for a Logit example)

for a possible problem for GLM llnull in gaussian family, see next comment

Activity

  1. josef-pkt commented on Apr 3, 2015

    @josef-pkt
    MemberAuthor

    example from statsmodels/examples/python/glm.py last case GLM: Gaussian distribution with a noncanonical link

    LL-Null: -2.6391e+08 looks strange, Incorrect ? check scale handling for llnull calculation

    >>> print(gauss_log_results.summary2())
                   Results: Generalized linear model
    ================================================================
    Model:              GLM              AIC:            -1319.8467 
    Link Function:      log              BIC:            -446.7015  
    Dependent Variable: y                Log-Likelihood: 662.92     
    Date:               2015-04-03 09:07 LL-Null:        -2.6391e+08
    No. Observations:   100              Deviance:       1.0215e-05 
    Df Model:           2                Pearson chi2:   1.02e-05   
    Df Residuals:       97               Scale:          1.0531e-07 
    Method:             IRLS                                        
    -----------------------------------------------------------------
               Coef.   Std.Err.      z       P>|z|    [0.025   0.975]
    -----------------------------------------------------------------
    x1        -0.0300    0.0000  -5361.3156  0.0000  -0.0300  -0.0300
    x2        -0.0001    0.0000   -951.0906  0.0000  -0.0001  -0.0001
    const      1.0003    0.0001  18569.2937  0.0000   1.0002   1.0004
    ================================================================
    
    >>> print(sm.GLM(lny, X[:,-1:], family=sm.families.Gaussian(sm.families.links.log)).fit().summary2())
                  Results: Generalized linear model
    ==============================================================
    Model:              GLM              AIC:            227.0694 
    Link Function:      log              BIC:            -400.3255
    Dependent Variable: y                Log-Likelihood: -112.53  
    Date:               2015-04-03 09:08 LL-Null:        -112.53  
    No. Observations:   100              Deviance:       55.586   
    Df Model:           0                Pearson chi2:   55.6     
    Df Residuals:       99               Scale:          0.56148  
    Method:             IRLS                                      
    ---------------------------------------------------------------
                Coef.   Std.Err.     z     P>|z|    [0.025   0.975]
    ---------------------------------------------------------------
    const      -0.2493    0.0961  -2.5929  0.0095  -0.4378  -0.0609
    ==============================================================
    
  2. josef-pkt commented on Apr 3, 2015

    @josef-pkt
    MemberAuthor

    The previous is correct, it uses the scale of the full model to evaluate the loglikelihood of the reduced, constant-only model.
    However, family.Gaussian.loglike with identity power=1 link uses the concentrated likelihood which uses the scale of the reduced model, not the scale that is given.
    new issue #2351

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