Skip to content

ENH/REF get_distribution 2dim column_vector is annoying, results methods missing #8723

Closed

Description

@josef-pkt

example: predict logpmf/loglike out of sample, similar to the in-sample loglikeobs

It's now relatively easy with get_distribution, but get_distribution has distribution parameters as 1-dim array with one column.

This is annoying if we have applications where we only need 1-dim.
Problem is that whether 1-dim distribution args is more convenient depends on the usage. But we don't know the intended usage when user calls get_distribution.

res.get_distribution(res.model.exog[:3, :]).logpmf(df.y.to_numpy()[:3, None])

quantiles, prediction intervals

np.random.seed(123)
stats.norm(loc=np.arange(3)[:,None]).ppf([0.025, 0.5, 0.975])
array([[-1.95996398,  0.        ,  1.95996398],
       [-0.95996398,  1.        ,  2.95996398],
       [ 0.04003602,  2.        ,  3.95996398]])
  • need option, maybe return_column boolean
  • which default? We will not be able to change it in a backwards compatible way.

aside: I looked at this now because of
https://stackoverflow.com/questions/75645250/different-values-of-the-log-loss-in-statsmodels-and-sklearn/75646515

Activity

  1. added this to the 0.14 milestone on Mar 8, 2023
  2. changed the title [-]ENH/REF get_distribution 2dim column_vector is annoying for 1-dim usage[/-] [+]ENH/REF get_distribution 2dim column_vector is annoying, results methods missing[/+] on Apr 7, 2023
  3. josef-pkt commented on Apr 7, 2023

    @josef-pkt
    MemberAuthor

    checking across models

    • GLM and OLS do not have results method
    • only recent addition of get_distribution (discrete except poisson) return column distr, others return 1-d distr (GLM, Beta, Poisson, OLS, ...)

    discrete/tests/test_predict.py test_distr uses squeeze to handle inconsistency in shape of get_distribution.

  4. josef-pkt commented on Apr 7, 2023

    @josef-pkt
    MemberAuthor

    Another "cleanup"

    GLM families Poisson, ... that don't have scale, ignore scale and var_weights arguments in the family get_distribution method.
    It would be better to raise an exception or at least a warning if those are not 1 or None.
    We need the arguments for generic calling consistency, but they should not be different from no-op default.

  5. josef-pkt commented on Apr 14, 2023

    @josef-pkt
    MemberAuthor

    changed in #8780

    get_distribution now returns 1-d

    issue #106 is still open, so closing this

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