Skip to content

ENH: GLM.estimate_scale add option to choose scaletype #4693

Open

Description

@josef-pkt

The GLM.estimate_scale method currently uses only the scaletype attribute to select the scale method.

We should add an option so we can override this when we want to compute different scale types from a results instance.
This could be reused for pearson chi2 and deviance scale in results instance,
and to handle excess dispersion for cov_type or LR and score test, even if the underlying scaletype attribute specifies a default.
i.e. scale type is mostly a fit argument, in terms of inference, but a model attribute because we use it to concentrate out scale in loglike and related.

(That part is still the mess because scale is both a model parameter and an auxiliary parameter irrelevant for estimation of mean parameters.)

Activity

  1. added this to the 0.10 milestone on May 30, 2018
  2. josef-pkt commented on May 30, 2018

    @josef-pkt
    MemberAuthor

    scale is a fit_option !

    The attribute before calling fit doesn't matter. GLM.fit sets the scale to the value of the keyword argument which is None by default.

    I tried to change the scaletype model attribute before calling fit and it didn't have any effect.

  3. josef-pkt commented on May 30, 2018

    @josef-pkt
    MemberAuthor

    another annoying thing
    scaletype='x2'
    should be
    scale_type='chi2'

  4. josef-pkt commented on May 30, 2018

    @josef-pkt
    MemberAuthor

    fit_constrained does not propagate scale
    i.e. model.scaletype is None after calling fit_constrained

  5. thequackdaddy commented on May 30, 2018

    @thequackdaddy
    Member

    If I can comment, I think it might also be helpful for estimate_scale to handle OLS (identity normal GLM) because I think the denominator is slightly different in that case.

  6. thequackdaddy commented on May 30, 2018

    @thequackdaddy
    Member

    For example, scale is divided by wnobs, not df_resid.

    @cache_readonly
    def llf(self):
    _modelfamily = self.family
    if (isinstance(self.family, families.Gaussian) and
    isinstance(self.family.link, families.links.Power) and
    (self.family.link.power == 1.)):
    scale = (np.power(self._endog - self.mu, 2) * self._iweights).sum()
    scale /= self.model.wnobs
    else:
    scale = self.scale
    val = _modelfamily.loglike(self._endog, self.mu,
    var_weights=self._var_weights,
    freq_weights=self._freq_weights,
    scale=scale)
    return val

  7. josef-pkt commented on May 30, 2018

    @josef-pkt
    MemberAuthor

    I thought we had already changed this.

    maybe there was a merge conflict
    https://github.com/statsmodels/statsmodels/pull/3856/files#diff-724e15f4019b2a24906f6b271d67e370R1538
    added the special handling of linear gaussian, which I thought we had dropped in a previous round

  8. josef-pkt commented on May 30, 2018

    @josef-pkt
    MemberAuthor

    Maybe I was thinking about something else
    #3856 (comment)

    I also opened #4665 when I was reading through parts of the code.

  9. josef-pkt commented on Jun 1, 2018

    @josef-pkt
    MemberAuthor
  10. josef-pkt commented on Oct 2, 2021

    @josef-pkt
    MemberAuthor

    bump to add scale_type option to GLM.estimate_scale

    I wanted to check how much scale estimates differ across scaletype and it requires manipulating the attribute.
    also #7526 for adding MLE profile scale

    _estimate_x2_scale is available as separate method, but none for dev scale

  11. modified the milestones: 0.10, 0.14 on Oct 2, 2021
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