Tutorials › Generalized Linear Models › Log-Transformed Gaussian Versus Gamma Log Models

Choosing Continuous Families · Tutorial 651 of 981

Log-Transformed Gaussian Versus Gamma Log Models

Learn how the two models differ in their mean interpretation and distributional assumptions, and how to translate their predictions back to the response scale.

Intermediate 11 min read

What You'll Learn

  • Distinguish a conditional mean of the log response from the log of the conditional arithmetic mean
  • Derive the response-scale mean and variance implied by Gaussian errors on the log scale
  • Interpret the gamma log link as a model for the conditional arithmetic mean
  • Compare the two models’ relative variance and distributional assumptions
  • Correctly back-transform fitted values for means, medians, and individual predictions
  • Identify when matching means and variances still leaves substantively different models

Two Models, Two Mean Targets

For a positive response \(Y\), a regression on \(\log Y\) and a gamma GLM with a log link can both describe how outcomes change multiplicatively with predictors. Their formulas can look similar, but the quantities on the response scale are not automatically the same. The distinction matters whenever a reported prediction is meant to be an average outcome rather than a typical value on the log scale.

Let \(x\) denote a predictor vector. In a Gaussian model for the transformed response, the conditional mean is specified for \(\log Y\). In a gamma GLM with a log link, the conditional mean is specified for \(Y\) itself. Back-transformation is therefore part of the model interpretation, not just a final computational step.

Definition: A Gaussian regression on the log-transformed response has $$ \log Y\mid x \sim N(m(x),\sigma^2), $$ where \(\sigma^2>0\) is constant across \(x\) in the homoscedastic model. A gamma GLM with a log link has $$ Y\mid x \sim \operatorname{Gamma}\!\left(\frac{1}{\phi},\,\phi\mu(x)\right), \qquad \log\mu(x)=\eta(x), $$ where the gamma parameters are shape and scale, respectively, \(\phi>0\), and \(\mu(x)=E[Y\mid x]\).

In ordinary regression notation, one often takes \(m(x)=x^\mathsf{T}\beta\) for the transformed Gaussian model and \(\eta(x)=x^\mathsf{T}\beta\) for the gamma GLM, possibly with different coefficient vectors in the two fits. The same linear-predictor form does not make the two conditional means equal: \(m(x)\) is \(E[\log Y\mid x]\), whereas \(\eta(x)\) is \(\log E[Y\mid x]\).

What the Log-Transformed Gaussian Model Implies

Exponentiating a fitted conditional mean of \(\log Y\) gives the conditional median of \(Y\), not its arithmetic mean. The arithmetic mean is larger when the log-scale variance is positive. The variance on the original scale also depends on the mean, even though the Gaussian errors have constant variance on the log scale.

Theorem: If \(\log Y\mid x\sim N(m(x),\sigma^2)\) with \(0<\sigma^2<\infty\), then $$ \operatorname{Median}(Y\mid x)=e^{m(x)},\qquad E[Y\mid x]=e^{m(x)+\sigma^2/2}, $$ and $$ \operatorname{Var}(Y\mid x) =e^{2m(x)+\sigma^2}\bigl(e^{\sigma^2}-1\bigr). $$ In particular, writing \(\mu(x)=E[Y\mid x]\), the variance is $$ \operatorname{Var}(Y\mid x)=\mu(x)^2\bigl(e^{\sigma^2}-1\bigr). $$

Proof. Write \(Z=\log Y\). For a normal random variable \(Z\sim N(m,\sigma^2)\), its moment-generating function is \(E[e^{tZ}]=e^{tm+t^2\sigma^2/2}\), which is finite for every real \(t\). Thus \(E[Y\mid x]=E[e^Z\mid x]=e^{m+\sigma^2/2}\), and \(E[Y^2\mid x]=E[e^{2Z}\mid x]=e^{2m+2\sigma^2}\). Subtracting the square of the mean gives $$ \operatorname{Var}(Y\mid x)=e^{2m+2\sigma^2}-e^{2m+\sigma^2} =e^{2m+\sigma^2}(e^{\sigma^2}-1). $$ Because the exponential function is strictly increasing, the median of \(Y=e^Z\) is the exponential of the median of \(Z\), namely \(e^m\). Finally, \(\mu^2=e^{2m+\sigma^2}\), giving the stated variance in terms of \(\mu\). \(\square\)

Worked Example: Correcting a Back-Transformed Prediction

Suppose a fitted Gaussian regression has \(m(x)=\log(10)+(\log 2)x\) and residual variance \(\sigma^2=0.09\). Find the conditional median and arithmetic mean at \(x=0\) and \(x=1\).

At \(x=0\), \(m(0)=\log(10)\). The back-transformed fitted value is \(e^{m(0)}=10\), which is the conditional median. The arithmetic mean includes the variance correction: $$ E[Y\mid x=0]=e^{\log(10)+0.09/2}=10e^{0.045}\approx 10.4603. $$

At \(x=1\), \(m(1)=\log(10)+\log(2)=\log(20)\). The conditional median is \(20\), while the arithmetic mean is $$ E[Y\mid x=1]=e^{\log(20)+0.045}=20e^{0.045}\approx 20.9206. $$

Thus exponentiating the fitted log-scale mean returns a median in both cases. If the scientific target is the arithmetic mean, the factor \(e^{0.045}\) must be included under this model. The correction is constant here because the log-scale variance is assumed constant.

What the Gamma Log Model Implies

The gamma GLM directly models the conditional arithmetic mean. Under the shape-and-scale convention above, a gamma random variable with shape \(a\) and scale \(b\) has mean \(ab\) and variance \(ab^2\). Substituting \(a=1/\phi\) and \(b=\phi\mu(x)\) gives the model’s response-scale mean and variance.

Result: Under the gamma log model, $$ E[Y\mid x]=\mu(x)=e^{\eta(x)},\qquad \operatorname{Var}(Y\mid x)=\phi\mu(x)^2. $$ Hence the conditional coefficient of variation, defined as the conditional standard deviation divided by the conditional mean, is \(\sqrt{\phi}\), constant across \(x\) when \(\phi\) is constant.

Derivation. The conditional gamma shape is \(a=1/\phi\), and its scale is \(b=\phi\mu(x)\). Therefore $$ E[Y\mid x]=ab=\frac{1}{\phi}\phi\mu(x)=\mu(x), \qquad \operatorname{Var}(Y\mid x)=ab^2 =\frac{1}{\phi}\bigl(\phi\mu(x)\bigr)^2 =\phi\mu(x)^2. $$ Since \(\mu(x)>0\), the conditional coefficient of variation is \(\sqrt{\phi\mu(x)^2}/\mu(x)=\sqrt{\phi}\). \(\square\)

Both models therefore imply variance proportional to the square of the conditional arithmetic mean, provided their respective dispersion parameters are constant. For the log-transformed Gaussian model, the proportionality factor is \(e^{\sigma^2}-1\); for the gamma GLM, it is \(\phi\). These factors need not agree. If \(\phi=e^{\sigma^2}-1\), the models have the same conditional mean and variance at a given mean level, but that agreement does not make their conditional distributions the same.

Worked Example: Comparing Implied Variances

Compare the models at conditional arithmetic means \(\mu=5\) and \(\mu=20\). For the log-transformed Gaussian model, take \(\sigma^2=0.09\) and choose \(m=\log\mu-0.045\), so that the arithmetic mean is \(\mu\). For the gamma GLM, take \(\phi=0.09\).

The Gaussian model’s variance factor is \(e^{0.09}-1\approx0.0941742837\). Consequently, $$ \operatorname{Var}_{\text{log-Gaussian}}(Y\mid\mu=5) =5^2(e^{0.09}-1)\approx 2.354, $$ $$ \operatorname{Var}_{\text{log-Gaussian}}(Y\mid\mu=20) =20^2(e^{0.09}-1)\approx 37.670. $$ The second result uses the unrounded factor: \(400(e^{0.09}-1)=37.669713\ldots\), which rounds to \(37.670\).

For the gamma model with \(\phi=0.09\), $$ \operatorname{Var}_{\text{gamma}}(Y\mid\mu=5)=0.09(5^2)=2.25, \qquad \operatorname{Var}_{\text{gamma}}(Y\mid\mu=20)=0.09(20^2)=36. $$ In both models the variance grows quadratically with the mean. Here the proportionality factors differ because \(0.09\ne e^{0.09}-1\). If instead the gamma dispersion were set to \(\phi=e^{0.09}-1\), its variances at both mean levels would match those of the log-transformed Gaussian model.

Matching Moments Does Not Match Distributions

Even when the conditional means and variances agree, the models retain different distributional assumptions. The log-transformed Gaussian model implies that \(Y\mid x\) is lognormal: it is positive, and \(\log Y\mid x\) is exactly Gaussian. The gamma GLM instead assumes a gamma conditional distribution. These distributions generally differ in their shape and tail behavior.

The difference is not merely that one model uses a transformed response. The Gaussian model asserts normality and constant variance for \(\log Y\); the gamma model asserts a particular positive-response family and a mean–variance relationship governed by \(\phi\). A model may provide a useful conditional mean while its assumed distribution is a poor description of individual outcomes. Conversely, a distributional fit does not by itself establish that the chosen mean function is scientifically appropriate.

Worked Example: Setting a Log-Scale Model to Target a Mean

Suppose the desired conditional arithmetic mean at a particular predictor value is \(10\), and the fitted log-scale residual variance is \(0.09\). What value should the Gaussian regression’s conditional log mean \(m\) take?

The log-transformed Gaussian result gives \(E[Y\mid x]=e^{m+0.09/2}\). Setting this equal to \(10\) yields $$ e^{m+0.045}=10,\qquad m=\log(10)-0.045. $$ The corresponding back-transformed fitted value is \(e^m=10e^{-0.045}\approx9.55997\), the conditional median. The arithmetic mean is $$ e^{m+0.045}=e^{\log(10)}=10. $$

By contrast, in a gamma GLM the predictor is set to \(\eta=\log(10)\), so that \(\mu=e^\eta=10\) directly. The numerical linear predictors differ because they target different quantities.

Choosing and Reporting the Prediction

The appropriate comparison begins by naming the target. If the question concerns the conditional arithmetic mean, the gamma log link targets it directly. A log-transformed Gaussian fit can also produce that mean under its assumptions, but it requires the variance correction. If the intended summary is the conditional median or a typical multiplicative level, \(e^{m(x)}\) from the transformed model has a direct interpretation as the conditional median.

For an individual-level prediction, neither model’s fitted mean is the entire predictive distribution. The transformed Gaussian model can generate predictions by drawing a normal error on the log scale and exponentiating; the gamma model generates predictions from its fitted gamma distribution. Their means might coincide while prediction intervals and tail probabilities differ. State which quantity is being reported and which model supplies the uncertainty distribution.

1
Identify the response-scale target.
Decide whether the scientific question asks for a conditional mean, a median, or a distribution for individual outcomes.
2
Read the modeled quantity.
For transformed Gaussian regression, \(m(x)=E[\log Y\mid x]\). For the gamma log model, \(\eta(x)=\log E[Y\mid x]\).
3
Transform using the chosen model.
For the transformed Gaussian mean, use \(e^{m(x)+\sigma^2/2}\); for its median, use \(e^{m(x)}\). For the gamma mean, use \(e^{\eta(x)}\).
4
Compare the variance implications.
Under constant dispersion, both models have variance proportional to the squared arithmetic mean, but the factors are \(e^{\sigma^2}-1\) and \(\phi\), respectively.

Common Mistake

A frequent error is to say, “The model predicts \(\log Y=m(x)\), so the predicted mean of \(Y\) is \(e^{m(x)}\).” This silently treats exponentiation as if it preserved expectations. It does not: generally \(E[e^Z]\ne e^{E[Z]}\). Under the specified normal model, the correct calculation is \(E[Y\mid x]=e^{m(x)+\sigma^2/2}\), while \(e^{m(x)}\) is the conditional median. The gamma log model has a different interpretation: \(e^{\eta(x)}\) is the conditional arithmetic mean by definition of its link and mean structure.

A second error is to claim that one of these models necessarily has a variance that grows quadratically with the mean while the other does not. With constant log-scale variance in the first model and constant gamma dispersion in the second, both have that same quadratic form. Their variance factors and distributional assumptions, rather than the power of the mean alone, distinguish them.

Key takeaway: A Gaussian model for \(\log Y\) models \(E[\log Y\mid x]\); exponentiating that quantity gives a conditional median, and the arithmetic mean requires a variance correction. A gamma GLM with a log link models \(\log E[Y\mid x]\), so exponentiating its linear predictor gives the arithmetic mean directly. Both imply variance proportional to the squared mean under constant dispersion, but they do not imply the same response distribution.

Check Your Understanding

Use the model assumptions stated in each question.

  1. If \(\log Y\mid x\sim N(m(x),0.16)\), what is the conditional median of \(Y\), and what is its conditional arithmetic mean?
  2. A gamma GLM has \(\eta(x)=\log(12)\) and dispersion \(\phi=0.2\). Find its conditional mean and variance.
  3. For a log-transformed Gaussian model with constant \(\sigma^2\), explain why the variance on the original scale changes as the conditional mean changes.
  4. What value of \(\phi\) makes the gamma model’s variance factor match that of a log-transformed Gaussian model with variance \(\sigma^2\)?
  5. Two fitted models have the same conditional mean and variance at a predictor value. Why might their individual-level predictive distributions still differ?
Clinical Biostats