Tutorials › Generalized Linear Mixed Models (GLMM) › The Log Link for Positive Conditional Means

From GLM to GLMM · Tutorial 20 of 698

The Log Link for Positive Conditional Means

Learn to transform finite linear predictors into positive conditional-mean predictions and compare those predictions through multiplicative factors.

Beginner 9 min read

What You'll Learn

  • Define the log link for a strictly positive conditional mean.
  • Derive the inverse link and explain why it maps finite predictors to positive values.
  • Calculate response-scale predictions from given linear predictors.
  • Compare two predictions using a mean ratio and a percentage change.
  • Distinguish positivity of a mean from positivity of every observed response.
  • Identify boundary and interpretation pitfalls when using the log link.

Why Use a Log Link?

Some response distributions have means that must be positive. A model that predicts a conditional mean directly from a linear predictor can produce zero or negative values, which are not valid for a strictly positive mean. The log link addresses this constraint by expressing the logarithm of the mean as the quantity modeled by the linear predictor. A finite linear predictor then corresponds to a positive mean after transformation back to the response scale.

The key calculation is straightforward: take the exponential of the linear-predictor value to obtain the predicted conditional mean. The log link also turns a difference between two linear predictors into a ratio between their predicted means. These relationships apply to conditional means; they do not imply that every observed response must be positive.

Definition: For a conditional mean \(\mu=E(Y\mid \mathbf{x})\) with \(\mu>0\), the log link is \(g(\mu)=\log(\mu)\). In a model with linear predictor \(\eta\), the link equation is \(\log(\mu)=\eta\). The logarithm here is the natural logarithm.

The condition \(\mu>0\) is essential because the real logarithm is defined only for positive arguments. For the log link, the predictor \(\eta\) can be any finite real number. This link is used with response settings whose conditional means are positive, including common count and positive continuous-response settings. The response distribution and its support still need to make sense for the application: choosing the log link does not, by itself, choose a response distribution.

Deriving the Inverse Link

Starting from the link equation, exponentiate both sides. Since the exponential function and the natural logarithm are inverse functions, this recovers the mean.

$$ \log(\mu)=\eta \quad\Longrightarrow\quad \exp\{\log(\mu)\}=\exp(\eta) \quad\Longrightarrow\quad \mu=\exp(\eta). $$
Result: The inverse log link is \(g^{-1}(\eta)=\exp(\eta)\). Thus a finite linear predictor \(\eta\in\mathbb{R}\) gives the response-scale conditional-mean prediction \(\hat{\mu}=\exp(\eta)>0\). The prediction has the same units as the response mean.

The positivity follows because \(\exp(\eta)>0\) for every finite real \(\eta\). As \(\eta\) becomes very negative, the prediction approaches zero, but it does not equal zero at any finite \(\eta\). As \(\eta\) becomes very positive, the prediction grows without bound. Consequently, the log link guarantees a positive prediction, not a prediction within every other constraint that an application might impose.

Worked Predictions on the Response Scale

Worked Example: Predicting a Positive Mean

Suppose a hypothetical model for the mean number of service requests per workday gives \(\eta=1.2\) for a specified predictor setting. Calculate and interpret the response-scale prediction.

The inverse link is the exponential function, so

$$ \hat{\mu}=\exp(\eta)=\exp(1.2)\approx 3.320. $$

The model predicts a conditional mean of approximately 3.320 service requests per workday at that predictor setting. This is a mean, not a claim that an individual workday will have a fractional number of requests.

The arithmetic is equally direct for negative predictors. A negative \(\eta\) does not imply a negative mean; it implies a mean between zero and one response unit when \(\eta<0\), because \(\exp(\eta)<1\).

Worked Example: A Negative Predictor Still Gives a Positive Mean

In a hypothetical model, the linear predictor for a specified setting is \(\eta=-0.7\). Find the predicted mean number of events per observation.

Substitute the predictor into the inverse link:

$$ \hat{\mu}=\exp(-0.7)\approx 0.4966. $$

The predicted conditional mean is about 0.4966 events per observation. It is positive, as required for a log-linked mean. If the outcome is a count, individual observations remain whole numbers; the predicted mean need not be an integer.

Differences on the Link Scale Become Ratios of Means

A particularly useful property follows by comparing two predictor settings. Let their finite linear predictors be \(\eta_1\) and \(\eta_0\), with positive conditional means \(\mu_1\) and \(\mu_0\). The log-link equations give \(\log(\mu_1)=\eta_1\) and \(\log(\mu_0)=\eta_0\). Subtract the second equation from the first and use the logarithm rule for a ratio:

$$ \eta_1-\eta_0 =\log(\mu_1)-\log(\mu_0) =\log\left(\frac{\mu_1}{\mu_0}\right). $$

Exponentiating both sides yields the mean ratio. This derivation requires only positive means and the log-link equations; it does not depend on a particular response distribution.

$$ \frac{\mu_1}{\mu_0}=\exp(\eta_1-\eta_0). $$

Thus, a difference of \(d\) on the linear-predictor scale corresponds to a multiplicative factor of \(\exp(d)\) between the conditional means. When a percentage change is useful, the factor can be expressed as \(100\{\exp(d)-1\}\%\), relative to the mean at the reference setting. This is a comparison of model-predicted means, holding whatever other predictors define the comparison fixed.

Worked Example: Comparing Two Predictor Settings

A hypothetical model predicts mean daily counts at two settings, with \(\eta_0=0.4\) and \(\eta_1=1.1\). Calculate both means, their ratio, and the percentage difference relative to setting 0.

First transform each linear predictor:

$$ \hat{\mu}_0=\exp(0.4)\approx 1.492, \qquad \hat{\mu}_1=\exp(1.1)\approx 3.004. $$

The linear-predictor difference is \(1.1-0.4=0.7\). Therefore, the ratio of predicted means is

$$ \frac{\hat{\mu}_1}{\hat{\mu}_0} =\exp(0.7) \approx 2.014. $$

The prediction at setting 1 is about 2.014 times the prediction at setting 0. The corresponding percentage difference is

$$ 100\{\exp(0.7)-1\}\% =100(2.014-1)\% \approx 101.4\%. $$

So the model predicts a mean daily count about 101.4% higher at setting 1 than at setting 0. The comparison concerns predicted conditional means, not individual outcomes.

Assumptions and Checks in Use

The inverse-link calculations are valid under a concise set of conditions. The target is a conditional mean that is strictly positive; the model uses the equation \(\log(\mu)=\eta\); and the linear predictor is finite at the setting being evaluated. If the model is intended to represent a particular response distribution, that distribution must also be appropriate for the response and its support. The log link alone does not establish those distributional assumptions.

A practical check is to calculate the prediction by applying the inverse link and then ask whether its size and units are plausible in context. For example, a predicted mean number of events per day should be reported in events per day, not as a probability. Also inspect whether the relevant predictor settings produce extreme \(\eta\) values. Very large positive values can yield implausibly large means; very negative values can yield values numerically close to zero. These may signal extrapolation, a poor model fit, or a numerical issue rather than an error in the inverse-link formula.

For count responses, zero observations are allowed even when the conditional mean is positive. The log link constrains the mean, not each realization of the response. Conversely, if the scientific setting requires a mean exactly equal to zero, no finite linear predictor under the log link gives that value. A prediction approaching zero is not the same as a model that permits an exact zero mean.

How the Log Link Differs from Alternatives

The appropriate link depends on the scale and constraints of the conditional mean. The identity link models the mean directly, so its predictions can be nonpositive even when the application requires positive means. For a binary response, the logit and probit links map probabilities into a linear predictor and return predictions between zero and one; they answer a different constraint problem. The complementary log-log link is another link for probabilities, with a different shape. These links are not interchangeable merely because they all connect a mean to a predictor.

LinkInverse transformationTypical constraint addressed
Log\(\mu=\exp(\eta)\)Strictly positive conditional means
Identity\(\mu=\eta\)No positivity constraint is enforced by the link
Logit\(\mu=1/\{1+\exp(-\eta)\}\)Conditional means that are probabilities
Probit\(\mu=\Phi(\eta)\)Conditional means that are probabilities

The log link has important limits. It ensures positivity but does not ensure that predictions are realistic, that the response distribution is correctly specified, or that a predictor comparison is causal. It also does not by itself determine how uncertainty in estimated model parameters should be reflected in an interval; the calculations here concern predictions from specified linear-predictor values.

Common Mistakes

  • Using the wrong direction of transformation. If \(\eta=\log(\mu)\), the response-scale prediction is \(\exp(\eta)\), not \(\log(\eta)\).
  • Calling a negative predictor a negative mean. A negative \(\eta\) produces \(\exp(\eta)>0\); for example, \(\exp(-0.7)\approx0.4966\).
  • Treating a positive mean as proof that every response is positive. A conditional mean is an average over the response distribution. Count outcomes can include zero while their mean is positive.
  • Comparing predictors by subtraction on the response scale. The difference \(\eta_1-\eta_0\) gives a log mean ratio; exponentiate it to obtain the ratio of means.
  • Assuming positivity guarantees suitability. A positive prediction can still be implausibly large, or the response distribution and link may not suit the data-generating setting.
Key takeaway: With the log link, \(\log(\mu)=\eta\) and \(\mu=\exp(\eta)\). A difference between two finite linear predictors becomes a ratio of positive conditional means: \(\mu_1/\mu_0=\exp(\eta_1-\eta_0)\).

Check Your Understanding

Answer each question, then compare your work with the solutions below.

  1. A log-linked model gives \(\eta=0.5\). What is the predicted conditional mean, to three significant figures?
  2. Two settings have predictors \(\eta_0=-0.2\) and \(\eta_1=0.3\). What is the ratio of their predicted means?
  3. Can a finite predictor under the log link give a predicted mean of exactly zero? Explain.
  4. A count outcome includes observed zeros. Does that fact alone contradict using a log link for its conditional mean? Explain.

Solutions. (1) \(\hat{\mu}=\exp(0.5)\approx1.65\), in the same units as the response mean. (2) The predictor difference is \(0.3-(-0.2)=0.5\), so \(\hat{\mu}_1/\hat{\mu}_0=\exp(0.5)\approx1.65\). (3) No. For every finite \(\eta\), \(\exp(\eta)>0\); it approaches zero only as \(\eta\) tends toward negative infinity. (4) No. The link constrains the conditional mean to be positive, not every observed count. A positive mean can arise from a distribution that assigns positive probability to zero.

Clinical Biostats