Skip to content

REF/Design: separate GLM Binomial Count from Proportion #5282

Open

Description

@josef-pkt

Binomial with n_trials != 1 is a pain because it doesn't follow the standard pattern of the models and results. We have to special case it all over the place.
e.g. #4599 and now in #5255
and we ran into it several times in weights and scale PRs

two old "design" issues #203 and #2192

We cannot really fundamentally change Binomial because of backwards compatibility, and I don't see a way how we could for example specify model.endog in a backwards and forwards compatible way during a deprecation period.

One possibility would be to replace the current Binomial by two classes one for counts and one for proportion. The problem is mainly in the interface, internally they are all the same and we have already several ways of specifying the model after the addition of var_weights.

BinomialCount

__init__(endog, exog, n_trials, ...)
where endog is success count.
This is similar to most stats.proportions functions

BinomialProportion
__init__(endog, exog, n_trials, ...)
where endog is success proportion.
this is similar to how Binomial currently behaves after the internal transformation

both would be models that follow standard patterns and convention, where in the first everything is specified in counts and in the second everything is specified in proportions.

The two models are equivalent to (Binomial is shortcut for GLM(... family=Binomial,...))
Binomial(proportion, exog, var_weights=1/n_trials...)

additionally n_trials would be equivalent to a generalized exposure variable (which is currently restricted to log link)

The simpler alternative would be to keep endog as counts () and use wendog for proportion instead of changing endog. () or proportions if user uses var_weights instead of n_trials.
For recreating the model, i.e. #4599, it would still be better to have n_trials as a keyword instead of the 2-D endog in the GLM.__init__

It might be possible to make this alternative work with deprecation, i.e. condition on whether endog is 2-D and whether n_trials keyword is not None. Then we could deprecate 2-D endog.

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