You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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()
Activity
josef-pkt commentedon Sep 18, 2014
@kshedden Do you have an example where optimization fails?
link to our collection: #1649
kshedden commentedon Sep 19, 2014
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.