Skip to content

GLM with Gamma family gives DomainWarning on v.0.8.0rc1 #3316

Open

Description

@yoavram

Running the example from the docs on statsmodels 0.8.0rc1 gives a DomainWarning:

/Users/xxx/miniconda3/envs/xxx/lib/python3.5/site-packages/statsmodels/genmod/generalized_linear_model.py:244: DomainWarning: The inverse_power link function does not respect the domain of the Gamma family.
  DomainWarning)

Reproducible example in notebook gist.

Python 3.5 on macosx.

Activity

  1. josef-pkt commented on Dec 12, 2016

    @josef-pkt
    Member

    We intentionally added the Warning. Even though the inverse power link is the canonical link function for gamma, it doesn't force the mean to be in the support of the distribution > 0. As a consequence there might be numerical problems for some datasets.

    A common solution is to use the log link instead of inverse power link, which will force the mean prediction to be strictly positive.

    We did not switch to log link as the default, but that might be better.

    see #2208 especially last comment, and #2212 for the PR that changed this.

    I'm adding the FAQ label

  2. josef-pkt commented on Dec 12, 2016

    @josef-pkt
    Member

    @yoavram The updated documentation and examples are at http://www.statsmodels.org/devel/examples/notebooks/generated/glm.html
    which also shows the warning.

    It would be better to add an explanation to the notebook, and add log link as the recommended link.

    Thanks for pointing this out. It is difficult to maintain and improve the documentation given that the documentation does not complain on changes in contrast to the unit tests.

  3. yoavram commented on Dec 13, 2016

    @yoavram
    Author

    Thanks I appreciate your prompt and detailed answers. I did search the issues/PR but must have missed it.

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