Skip to content

Gamma GLM fails easily with reciprocal link #1932

Open

Description

@kshedden

The gamma GLM seems to fail easily during optimization when using the canonical reciprocal link. It works OK with clean simulated data, but fails with real data sets or complicated models. With the exponential link it is more stable. I will put together some examples.

Activity

  1. added this to the 0.7 milestone on Aug 25, 2014
  2. josef-pkt commented on Sep 18, 2014

    @josef-pkt
    Member

    @kshedden Do you have an example where optimization fails?

    link to our collection: #1649

  3. kshedden commented on Sep 19, 2014

    @kshedden
    ContributorAuthor

    I need to look into this more, but the code below produces a result with NaN as the likelihood, and many of the fitted values are negative. My understanding is that R considers any parameter vector that produces out-of-domain fitted values to be "invalid". If it can't find a valid MLE, it fails with an exception.

    import numpy as np
    from statsmodels.genmod.generalized_linear_model import GLM
    from statsmodels.genmod.families import Gamma, Gaussian
    n = 100
    exog = -np.log(np.random.uniform(size=(n, 3)))
    exog[:, 0] = 1
    endog = exog[:, 1:].sum(1) + np.random.uniform(size=n)
    fa = Gamma()
    model = GLM(endog, exog, family=fa)
    rslt = model.fit()
    
  4. modified the milestones: 0.8, 0.7 on Feb 6, 2015
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions