Skip to content

ENH: add var_weights to GLM #3371

Open
Open

Description

@josef-pkt

PR #2879 was intended to add weights but ended up adding mainly test cases and no new weights.

To make this more digestible it will be better to start with more limited target

  • add var_weights in GLM.__init__
  • rename internally the current freq_weights to iweights and
    • define iweights as product var_weights * freq_weights
  • use None for weights that are not used (and add many if xxx_weights are None:

minimal result: replicate var_weights for case when endog is an average and match R and Stata for params_table. Family Gaussian with var_weights should also replicate WLS (except for use_t default).

extra results (those are the messy parts)

  • loglike and similar: var_weights behaves differently from the other weight types. All others just multiply loglike_obs.
  • resid_pearson and similar: My guess: Those should include var_weights, but not freq and other weights (the latter is unchanged from now). Alternatively we need wresid_xxx in analogy to WLS.
    maybe: resid (unweighted), wresid (var_weighted), resid_pearson and resid_anscombe (var_weighted).
    open: resid_deviance (it's likely that var_weighted is more useful).
    open: resid_xxx are cached attributes. Do we need a new resid method that can take arguments like use_weights, but without caching?

resids and other attributes are mainly intermediate results where the definition is mostly for convenience. The actual use and test cases need to go on some final results. E.g. outliers in anscombe, scale computation with resid_pearson and resid_deviance, LR and deviance tests for comparing models, resids for diagnostics and regression plots and so on.

score_factor, score_obs and hessian_factor: those might all be multiplicative with iweights.

question: Are there differences with respect to weight types between canonical and noncanonical link functions?

aside: stats.stackexchange has several questions on weights and glm for R. Several of those about the limitation for outlier robust weights and IPW.

Activity

  1. lorentzenchr commented on Feb 23, 2017

    @lorentzenchr
    Contributor

    Hi Josef. As you pointed out, having only iweights in family.py, it is not possible to distinguish the cases, i.e. only var_weights should go into resid_dev and resid_anscombe. What do you suggest?

    Aside: Once var_weights are merged, I could add some explanation in the documentation of GLMs.

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