Likelihood for Independent Gamma Responses
A gamma generalized linear model specifies a positive mean for each observation and a dispersion parameter that controls variability around that mean. For independent responses, the joint likelihood is the product of their gamma densities. Writing it out carefully matters: the dispersion appears not only in the exponential term, but also in the gamma normalization and the power of the response. Those terms contribute to the dispersion score.
Use the gamma parameterization with mean \(\mu_i\) and common dispersion \(\phi>0\), so that the shape is \(1/\phi\), the scale is \(\phi\mu_i\), and \(\operatorname{Var}(Y_i)=\phi\mu_i^2\). The observations \(y_1,\ldots,y_n\) are assumed positive. Let \(x_i\) be a fixed \(p\)-vector of predictors, let \(\beta\) be a \(p\)-vector of regression coefficients, and set \(\eta_i=x_i^{\mathsf T}\beta\). A link \(g\) relates the mean to the linear predictor by \(g(\mu_i)=\eta_i\). Write \(h=g^{-1}\), so \(\mu_i=h(\eta_i)\), and assume the inverse link is differentiable at each predictor considered and gives \(\mu_i>0\).
For \(y_i>0\), the gamma density in this parameterization is
Independence gives the likelihood by multiplication. Taking logarithms yields a sum, which is the convenient form for differentiation.
Here \(\Gamma\) is the gamma function. Define the digamma function by \(\psi(a)=\Gamma'(a)/\Gamma(a)\) for \(a>0\). All score formulas below concern interior parameter values \(\phi>0\) and means in the domain of the inverse link.
Regression-Coefficient Score for a General Link
The mean contribution to one observation’s log-likelihood has a particularly simple derivative. Holding \(\phi\) fixed, the terms depending on \(\mu_i\) are \(-y_i/(\phi\mu_i)-(1/\phi)\log\mu_i\). Differentiate them with respect to \(\mu_i\), then use the chain rule through \(\eta_i=x_i^{\mathsf T}\beta\).
To verify the formula, differentiate the log-likelihood first with respect to an individual mean. The gamma normalization terms that depend on \(\mu_i\) are included in this derivative.
Since \(\partial\mu_i/\partial\beta=h'(\eta_i)x_i\), the chain rule gives
The expression uses the derivative of the inverse link, not the derivative of the link itself. The reciprocal form follows from differentiating \(g(h(\eta))=\eta\): when \(g'(\mu_i)\ne0\), \(g'(\mu_i)h'(\eta_i)=1\). No particular link has been assumed.
Worked Example: Coefficient Score With a Nonlinear Link
Consider one observation with \(x_1=1\), \(\eta_1=\beta\), and the differentiable link \(g(\mu)=\mu^2\) on \(\mu>0\). At \(\beta=4\), the fitted mean is \(\mu_1=2\). Let \(y_1=3\) and \(\phi=1/4\). Calculate the coefficient score.
The inverse link is \(h(\eta)=\sqrt{\eta}\) for \(\eta>0\), so \(h'(4)=1/(2\sqrt{4})=1/4\). Substitution into the general score gives
As a check, \(\partial\ell/\partial\mu_1=(3-2)/((1/4)2^2)=1\), and \(d\mu_1/d\beta=h'(4)=1/4\). Their product is \(1/4\), as above.
Dispersion Score
The dispersion derivative must account for every occurrence of \(\phi\), including those inside \(\log(\phi\mu_i)\) and \(\Gamma(1/\phi)\). Differentiating one summand of the log-likelihood gives
For the derivative, treat the means as fixed when differentiating with respect to \(\phi\). In a GLM, \(\mu_i\) depends on \(\beta\), not on \(\phi\). The four terms in the summand differentiate as follows:
Adding these contributions and combining the two logarithms produces the stated score. In particular, omitting the derivative of the gamma normalization would remove the digamma term and would not give the derivative of this likelihood.
Worked Example: Evaluating the Dispersion Score
Suppose there are two independent observations with fitted means \(\mu_1=2\), \(\mu_2=3\), observed values \(y_1=2\), \(y_2=6\), and common dispersion \(\phi=1/2\). Evaluate \(U_\phi\).
Here \(1/\phi=2\) and \(\psi(2)=1-\gamma\), where \(\gamma\approx0.577216\) is Euler’s constant, so \(\psi(2)\approx0.422784\). The bracket for the first observation is
For the second observation the bracket is
Since \(1/\phi^2=4\), the total score is
Equivalently, the sum of the two brackets is \(1+2\psi(2)-\log(8)\), which gives the same value. This is the score evaluated at the specified parameters; it is not, by itself, a dispersion estimate.
Why the Scores Have Mean Zero
At the true parameter values, each score has expectation zero under the model. This is a useful check on the formulas, though it does not imply that a score computed from a particular finite sample will equal zero.
For the coefficient contribution, the mean parameterization gives \(E[Y_i]=\mu_i\). Therefore
For the dispersion contribution, put \(k=1/\phi\) and \(Z_i=Y_i/(\phi\mu_i)\). Then \(Z_i\) has a gamma distribution with shape \(k\) and scale 1. The identity \(E[\log Z_i]=\psi(k)\) follows by differentiating the gamma integral
Indeed, for \(k>0\), differentiation under this integral is justified locally: on any compact interval of positive \(k\)-values, the differentiated integrand is bounded near zero by an integrable constant times \(z^{a-1}|\log z|\) for some \(a>0\), and at infinity by an integrable exponential tail times a polynomial and \(\log z\). Thus
Because \(Y_i=\phi\mu_i Z_i\), it follows that \(E[Y_i/\mu_i]=\phi E[Z_i]=1\) and \(E[\log(\phi\mu_i/Y_i)]=-\psi(1/\phi)\). Substitution into the dispersion bracket gives
Common Pitfall and Practical Checks
A frequent error is to treat the gamma shape \(1/\phi\) as if it were the dispersion \(\phi\), or to differentiate only the exponential part of the density. The shape and dispersion are reciprocals in this parameterization, and the normalization depends on dispersion too. Retaining the \(\log\Gamma(1/\phi)\) term is essential for the correct dispersion score.
A second error is to multiply by \(g'(\mu_i)\) in the coefficient score. The chain rule uses \(d\mu_i/d\eta_i=h'(\eta_i)\); if expressed using the link derivative, this is \(1/g'(\mu_i)\), provided that derivative is nonzero. The two worked calculations above illustrate how to check this chain rule and how to assemble the dispersion terms.
These scores are the derivatives of the full independent-observation log-likelihood. In likelihood-based fitting, stationary interior estimates satisfy score equations, but evaluating the equations, solving them, and assessing dispersion estimates are distinct tasks. The formulas here apply when all observed responses are positive, the means are positive, and the parameters are interior; they do not assign a gamma density to a zero response.
Check Your Understanding
Use the likelihood and score formulas to answer the following questions.
- Why does independence make the joint log-likelihood a sum, and which part of the gamma density contributes the digamma term to the dispersion score?
- For a differentiable inverse link \(h\), identify the chain-rule factor in the coefficient score. How is it written in terms of \(g'\) when \(g'(\mu_i)\ne0\)?
- If \(y_i=\mu_i\), what is the contribution of observation \(i\) to the coefficient score? Does that force its dispersion-score contribution to be zero?
- Explain why the expected dispersion-score contribution is zero even though its value for an individual observed response need not be zero.
- What condition on the responses is required for the gamma likelihood written here to apply?