Skip to content

ENH/Design GLM pattern, families, links, for non-LEF distributions #3915

Open

Description

@josef-pkt

related similar issue #2107

The idea is to bring discrete and other future models closer to the GLM pattern of delegating to family and link classes, instead of hardcoding inside the models. This would be similar to what GAMLSS in R is doing.

There would be some additional function call overhead and generic code will in several cases be computationally less efficient than the special case models.
Right now I'm thinking more of the usage for post-estimation results where computational efficiency is not as important.

The current case are prediction, margins in the new count models and the required evaluation of distribution methods and computation of derivatives.
For example loglike is built into the model class and cannot use different exog or distribution parameters than those provided and hardcoded into the model. (Evgeny used an artificial model to manipulate the attached endog). In contrast families specify the distribution in terms of mu (mean) directly.

We also have the scipy distributions available and some similar classes in statsmodels.distributions, but they don't have the required methods like derivatives, and not the regression based parameterization in several cases, e.g. NegativeBinomial.
In the gemod.families we have distributions that have the used parameterization and the derivatives and other methods that we needed so far. However, the families are currently only for one-parameter LEF.

Parametric duration models are another group of models on the wishlist that could follow a similar pattern. Accelerated failure time models AFT look very similar to discrete models with log-link.

Modified models, like zero-inflation, hurdle, truncated, censored, mixture models, need additional methods of the distribution that are not available in the "plain" discrete models. Delegation would make this more modular and reusable than adding special case methods like pmf or cdf to every model.

Activity

  1. josef-pkt commented on Sep 14, 2017

    @josef-pkt
    MemberAuthor

    trying to be lazy:

    one example for discrete (using generic computation) mu is mean of model or submodel
    pmf = exp(loglikeobs)
    score wrt mu = d loglikeobs / d mu = 1 / pmf * d pmf / d mu
    or
    score = d loglikeobs / d params = 1 / pmf * d pmf / d params

    The derivative d pmf / d mu is what we need for predict and margins, and eg. for zero-inflation score test.

    Note, score_factor is different because it is not with repect to mu, it includes the derivative of the link function, i.e. is derivative w.r.t. linpred which works for many cases but hardcodes the link function.

  2. josef-pkt commented on Sep 16, 2017

    @josef-pkt
    MemberAuthor

    cross-link to alternative idea allowing exog in the methods like score_obs #1784

    That sounds more messy now in count models with two exog, offset and exposure, and then also several types of weights which makes it into a lot of extra arguments that need to have default handling.

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