Skip to content

ENH: add estimated variance of endog to GLMResults #7528

Open

Description

@josef-pkt

getting the variance for the estimated GLM model is a bit tedious, e.g. for inverse gaussian example

results_ig.model.family.variance(results_ig.predict([1])) * results_ig.scale

I think the best would be to add it as option to predict.

GLMResults currently does not define a predict method. It uses the inherited predict method of base.model.Results, that delegates to the model GLM.predict method.

base.model.Results.predict delegates args and kwargs to model predict method, so is flexible to handle additional keywords.

GLM.predict uses boolean linear=False. This would need to be generalized to which similar to the newer count models.
We will not get get_prediction for variance and similar because we don't have cov_params for scale.

The current GLM.predict does not use weights for linpred and predicted mean.
In variance prediction we could have an option to include var_weights, similarly resid_pearson (always) includes var_weights

(context: I'm verifying get_distribution with implied mean and variance.)

Activity

  1. josef-pkt commented on Jul 2, 2021

    @josef-pkt
    MemberAuthor

    followup idea

    predict(..., which="loglike")
    In GLM in contrast to discrete and other models, the loglike for GLM is not hardcoded in the model class. We can use the family.loglike_obs to compute loglike for out-of-sample observations.

    #2572 last sentence

    difference to other predict options would be that we need endog in addition to exog. So, it's not completely the same pattern.

  2. added this to the 0.14 milestone on Dec 13, 2021
  3. josef-pkt commented on Dec 13, 2021

    @josef-pkt
    MemberAuthor

    related: for out of sample loglike

    BetaModel has a private _llobs which is loglikeobs with additional endog, exog arguments. The loglikeobs method delegates to it.
    That's another way of getting loglike for endog or exog. other than the model attributes.
    Zero-inflated models still temporarily replaces the model attributes.

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