Statsmodels: GLM with Gamma family gives DomainWarning on v.0.8.0rc1

Created on 12 Dec 2016  路  3Comments  路  Source: statsmodels/statsmodels

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.

FAQ comp-docs comp-genmod

Most helpful comment

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

All 3 comments

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

@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.

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

Was this page helpful?
0 / 5 - 0 ratings