Skip to content

GLM aic bic inconsistency #1733

Closed
Closed

Description

@josef-pkt

writing unit tests for GLM aic and bic compared to Stata

our aic agrees with estat ic but not with the one in ereturn list
our bic agrees with ereturn list but not with estat ic

???

GLMResults aic uses the usual llf based definition
GLMResults bic uses the deviance based definition.

Proposal
make both llf based, for comparability and consistency across MLE models (e.g. discrete)
add aic_dev and bic_dev for users that want the deviance based ic

AFAIK: they should only differ by a constant within same model (llf of saturated model), and it won't affect comparison within the same model for different df_model.

Activity

  1. josef-pkt commented on Jun 4, 2014

    @josef-pkt
    MemberAuthor

    to make it more complicated
    Stata with irls only reports bic, and estat ic fails with likelihood information not found in last estimation results

    list of attributes in ereturn list differs whether the estimator is irls or mle (mle is default)

    Is there even a aic_dev?

  2. ledmonster commented on Mar 27, 2015

    @ledmonster

    +1

  3. josef-pkt commented on Jan 6, 2018

    @josef-pkt
    MemberAuthor

    bump for 0.10: the inconsistency in definition of bic is just ugly (comparing GLM gaussian to ols/wls)

    changing this will not be backwards compatible, but usage for within model specification search will not be affected (ranking stays the same). Across model comparison is currently not possible because bic definition doesn't match the llf version in other models.
    So, change without deprecation.

  4. added this to the 0.10 milestone on Jan 6, 2018
  5. josef-pkt commented on Aug 27, 2018

    @josef-pkt
    MemberAuthor

    """
    We are comparing statistical analysis with R · Python. When logistic regression was executed with glm of Python 's statsmodels, when we output the result of bic, it was different from R.

    Since aic matched, is it a bug? All the results of the summary of the logistic regression also match.
    """
    quote translated by Google from a Japanese web site

  6. JoonsukPark commented on Mar 7, 2020

    @JoonsukPark
    Contributor

    So it seems that this issue hasn't been resolved. I looked at the definition of llf and deviance in the GLM api and it seems that either works fine. The problem is actually about the usage of df_resid instead of (df_model+1) that should have been used in that place -- that is the source of discrepancies between the R version of BIC and the statsmodels' one. For consistency, however, it would be better to just use llf in the definition of BIC.

  7. josef-pkt commented on Mar 7, 2020

    @josef-pkt
    MemberAuthor

    The problem is that we have unit tests against Stata that fail in PR #6568

    I never looked at the formula specifically for the deviance case, but the use of df_resid looks now strange/wrong to me.

    We need to check whether there was a problem in Stata or if the unit tests hide some problems, some decimal in the asserts are very low.

  8. josef-pkt commented on Mar 7, 2020

    @josef-pkt
    MemberAuthor

    Stata docs matches our computation with df_resid = N - k
    BIC = D**2 - (N - k) ln(N)

    But this still looks wrong.
    e.g AFAIK, deviance is supposed to be the analogue of RSS in the linear model, but there we use k and not df_resid,
    e.g. https://en.wikipedia.org/wiki/Bayesian_information_criterion
    and tools.eval_measures.bic_sigma

    I don't find a reference for the deviance based bic.

    correction BIC uses log(RSS), so deviance D^2 cannot be directly the analogue of RSS.

  9. josef-pkt commented on Mar 7, 2020

    @josef-pkt
    MemberAuthor

    BIC in Stata and statsmodels is not wrong in terms of ranking models.

    Because of the linearity in k, using df_resid just adds a constant that is not model (selection of exogs) dependent for a given sample (of given size nobs=N).

    BIC = D**2 - (N - k) ln(N) = D**2 + k ln(N) - N ln(N)

    (I might have seen this version before in some references with the N log N term)

    The problem is "only" the inconsistency in the definition with other information criteria and that we cannot compare bic across models (i.e. across model classes).

  10. JoonsukPark commented on Mar 7, 2020

    @JoonsukPark
    Contributor

    Yes, that is true; ranking of the models would not change under the Stata-style BIC. (This is what I meant when I said "Although the current implementation of BIC in genmod serves the purpose" in #6568). I only raised this issue because the R-style definition is a more common one (at least what I have seen from the literature) and I thought it would be better to adopt such a thing. Personally, I think the Stata-style definition is a bit weird because it does not make it clear that BIC penalizes models based on the complexity (i.e., number of model parameters), although the penalty is hidden in the definition. Either way, however, BIC will do its job.

  11. josef-pkt commented on Mar 7, 2020

    @josef-pkt
    MemberAuthor

    One possible difference between likelihood based and divergence based aic is likely in dispersion for models like Poisson and Binomial.
    The likelihood version does not include excess dispersion, scale is assumed to be 1.
    I guess that the divergence based aic does not use the scale=1 assumption.

    see also #1802 #1802 (comment)
    #6516 for TIC (similar to robust cov_type)

    The main way forward is to add a method where we can add several options for different definitions of the information criteria. Then we don't have to rely so much at the attributes that cannot have options, and we could deprecate the cases that we don't like.

  12. JoonsukPark commented on Mar 10, 2020

    @JoonsukPark
    Contributor

    OK, I will try to commit something like that sooner or later.

  13. modified the milestones: 0.10, 0.12 on Aug 5, 2020
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions