2

My question is part statistical and part coding.

Say I have fitted a gamma log-link GLM. doc example

# Instantiate a gamma family model with the default link function.
gamma_model = sm.GLM(y, X, family=sm.families.Gamma())
gamma_results = gamma_model.fit()

The gamma is a two parameter distribution of shape and scale.

My understanding is that, as in OLS regression, the fitted GLM predicts values y that are the estimates of the mean and shape of the gamma distribution for a combination of X inputs. Therefore I can use the GLM to estimate the shape parameter values for a given Xi. But how do I obtain the scale?

What I would like to achieve is to make predictions on Xi and to then sample the resulting distribution as per doc example.

# sample gamma distribution 
shape, scale = 2., 2. 
s = np.random.gamma(shape, scale, 1000)
BenP
  • 825
  • 1
  • 10
  • 30
  • 1
    see comments here https://stackoverflow.com/questions/60215085/calculating-scale-dispersion-of-gamma-glm-using-statsmodels (I have not fully verified an answer) – Josef Apr 18 '20 at 17:54
  • I think this is promising- not at my computer to check right now. https://math.stackexchange.com/questions/2873763/is-it-possible-to-determine-shape-and-scale-for-a-gamma-distribution-from-a-mean?newreg=d61b4517cd304ecca335b8e69220bf0c – BenP Apr 19 '20 at 09:25

0 Answers0