3

I am trying to model an outcome using a generalized linear model and the Gamma distribution with a log link function using the glm() function in R. I went to Wikipedia to look at the parameterizations for the Gamma distribution. Now I would like to state the model formally with $shape = k$ and $scale = \theta$ in a manuscript. What I would like to do is something along those lines:

$y_{i}\sim \Gamma(k,\theta_{i})$

$E(y_{i})=k\theta_{i}$ and $var(y_{i}) =k\theta_{i}^{2}$

$log(k\theta_{i})=\alpha +\beta_{1}X_{i}$

My question is whether this is correct? I read that the glm() function in R only models the scale parameter $\theta$ as a function of the independent variables (hence the index for $\theta$) whereas the shape parameter $k$ is constant and appears as the dispersion parameter $\phi = 1/k$ in the glm() output.

My second question would be how can I change the variance specification ($Var(y_{i}) =k\theta_{i}^{2}$) when I want $k\theta_{i} = \mu_{i}$ so that the model would look like:

$log(\mu_{i})=\alpha +\beta_{1}X_{i}$

This doesn't seem correct: $var(y_{i}) = \mu_{i}\theta_{i}$, or does it?

Stefan
  • 6,431
  • 1
    You will probably want to use the shape-mean parameterization. Quite a few posts on site discuss this parameterization. See https://stats.stackexchange.com/questions/136909/prior-for-gamma-distribution-in-mean-form/136932#136932 for an explicit density, One reference that explicitly discusses it is the book by de Jong and Heller. – Glen_b Aug 25 '20 at 05:09
  • 1
    Thank you @Glen_b for the comment and the links. I think I did found my answer now in Faraway 2006, page 149, where he suggest that in a GLM setting it is more convenient to reparameterize the distribution with $\lambda = \nu/\mu$, which then results in $E(Y)=\mu$ and $var(Y)=\mu^2/\nu$ – Stefan Aug 25 '20 at 14:20
  • Sure, that would be starting with $\nu$ as shape and $\lambda$ as a rate parameter (in your question's notation, these would be $k$ and $1/\theta$). You could post an answer along the lines of your comment if you wish, – Glen_b Aug 25 '20 at 23:42
  • See https://stats.stackexchange.com/questions/474326/deviance-for-gamma-glm It is specifically for the gamma deviance but, on the way, it clarifies the parametrization for gamma glms. – Gordon Smyth Aug 26 '20 at 02:09
  • @GordonSmyth Thanks for the link! – Stefan Aug 26 '20 at 05:06

1 Answers1

1

Using the shape ($\nu$) and rate ($\lambda$) parameterizations for the density of the Gamma distribution we get:

$$f(y)=\frac{1}{\Gamma(\nu)}\lambda^\nu y^{\nu-1}e^{-\lambda y}\qquad y>0$$

Now we can reparameterize by setting $\lambda=\nu/\mu$ and get:

$$f(y)=\frac{1}{\Gamma(\nu)}\left(\frac{\nu}{\mu}\right)^\nu y^{\nu-1}e^{-\left(\frac{y\nu}{\mu}\right)}\qquad y>0$$

Now: $$EY=\mu \quad \mathbb{and} \quad var\,Y=\frac{\mu^2}{\nu}$$

To translate this into your notation:

$$y_{i}\sim \Gamma(\mu_{i},\nu)$$ $$E(y_{i})=\mu_{i}\quad \mathbb{and} \quad var(y_{i})=\frac{\mu_{i}^2}{\nu}$$ $$log(\mu_{i})=\alpha +\beta_{1}X_{i}$$


Reference: Faraway (2006): Extending the linear model with R (page 149).

Stefan
  • 6,431