Tutorials › Generalized Linear Models › Conditional Mean Predictions at Covariate Profiles

Count Effects and Predictions · Tutorial 477 of 981

Conditional Mean Predictions at Covariate Profiles

Use the fitted log-mean model and the profile’s known offset to calculate its conditional expected count, without confusing that quantity with a population average.

Intermediate 10 min read

What You'll Learn

  • Identify the covariate vector and known offset for a specified profile
  • Calculate a fitted Poisson conditional mean by substituting fitted coefficients
  • Interpret an exposure offset as scaling a rate to an expected count
  • Keep a profile-specific fitted mean distinct from an average over a population
  • Recognize why evaluating the model at average covariates need not give an average fitted mean

From a Covariate Profile to a Fitted Mean

A count-model prediction starts with a precise question: what is the expected count for an observation with these covariates and this known exposure? The answer is a model-based conditional mean for that specified profile. It is not the observed count, and it is not automatically an average for a wider population whose members may have different covariates.

For a Poisson generalized linear model with a log link, the conditional mean is determined by the linear predictor. A known offset is included in that predictor, but its coefficient is fixed at one rather than estimated. Once the fitted coefficients, covariates, and offset are specified, calculating the fitted mean is direct substitution followed by exponentiation.

Definition: Suppose \(Y_i\) is a count with a Poisson log-link model \(Y_i\mid x_i \sim \operatorname{Poisson}(\mu_i)\) and \(\log(\mu_i)=o_i+x_i^{\mathsf T}\beta\). Here \(x_i\) is the covariate vector, \(\beta\) is the coefficient vector, and \(o_i\) is a known offset. Given fitted coefficients \(\hat\beta\), the fitted conditional mean at covariate profile \(x_0\) and offset \(o_0\) is \(\hat\mu(x_0,o_0)=\exp(o_0+x_0^{\mathsf T}\hat\beta)\).

The covariate vector includes the model’s chosen coding: an intercept, continuous predictors, indicator variables, transformed variables, and interaction terms if they are in the specified model. The profile must be translated into that coding before calculation. An offset is on the log-mean scale. In the common exposure model, \(o_0=\log(t_0)\), where \(t_0>0\) is known exposure, so the same formula can be written as \(t_0\exp(x_0^{\mathsf T}\hat\beta)\).

Why the Calculation Is Exponentiation

The defining model equation is on the log scale. At the profile of interest, substitute \(x_0\), \(o_0\), and the fitted coefficient vector into that equation. Exponentiation reverses the logarithm and returns the mean on the count scale.

Derivation: At the specified profile, the fitted log mean is \(o_0+x_0^{\mathsf T}\hat\beta\). Since the link is \(g(\mu)=\log(\mu)\), its inverse is \(g^{-1}(z)=\exp(z)\). Therefore, \(\hat\mu(x_0,o_0)=g^{-1}(o_0+x_0^{\mathsf T}\hat\beta)=\exp(o_0+x_0^{\mathsf T}\hat\beta)\). When \(o_0=\log(t_0)\), the exponential rule gives \(\exp(\log(t_0)+x_0^{\mathsf T}\hat\beta)=t_0\exp(x_0^{\mathsf T}\hat\beta)\). Thus the offset scales the fitted rate by the known exposure.

This calculation treats the fitted coefficients as supplied values; it does not describe how they were estimated. The result is on the count scale, so it may be non-integer. An expected count of 14.8 is meaningful even though any one observed count must be an integer.

Worked Example: A Profile With a Known Exposure

Suppose a fitted model for a count has mean \(\log(\mu)=\log(t)+\log(2)+0.05(\text{age}-50)+\log(1.5)I(\text{treated})\), where \(t\) is known exposure. Calculate the fitted mean for a treated person aged 60 observed over \(t=3\) exposure units.

Step 1: Substitute the profile. The centered age is \(60-50=10\), the treatment indicator is 1, and the offset is \(\log(3)\). The fitted log mean is \(\log(3)+\log(2)+0.05(10)+\log(1.5)\).

Step 2: Exponentiate. Combine the terms: \(\hat\mu=3\times2\times\exp(0.5)\times1.5\). Using \(\exp(0.5)\approx1.6487\), \(\hat\mu\approx3\times2\times1.6487\times1.5=14.8383\).

The fitted conditional expected count for this specified profile and exposure is about 14.84. It is not a claim that an individual’s realized count will equal 14.84.

Offsets and the Meaning of the Prediction

When the offset is log exposure, \(x_0^{\mathsf T}\hat\beta\) describes the fitted log rate per exposure unit, while \(o_0+x_0^{\mathsf T}\hat\beta\) describes the fitted log mean count over the specified exposure. Keeping those interpretations separate prevents a common unit error.

Result: If the fitted model is \(\log(\mu)=\log(t)+x^{\mathsf T}\beta\) for known \(t>0\), then at a fixed profile \(x\), the fitted mean count is \(t\exp(x^{\mathsf T}\hat\beta)\). If the exposure changes from \(t\) to \(ct\), for \(c>0\), while the profile and fitted coefficients remain the same, the fitted mean changes to \(c\hat\mu\).

Proof. At exposure \(t\), the fitted mean is \(\hat\mu(t)=\exp(\log(t)+x^{\mathsf T}\hat\beta)=t\exp(x^{\mathsf T}\hat\beta)\). At exposure \(ct\), it is \(\hat\mu(ct)=ct\exp(x^{\mathsf T}\hat\beta)=c\hat\mu(t)\). The scaling follows from the fixed unit coefficient on \(\log(t)\). \(\square\)

Worked Example: Converting a Fitted Rate Into an Expected Count

A fitted model for events per patient-day has \(\log(\mu)=\log(t)+\log(0.6)+0.2I(\text{exposed})\). Calculate the fitted expected count for an exposed group observed for 5 patient-days.

The profile has \(I(\text{exposed})=1\) and \(t=5\). Substitution gives \(\hat\mu=\exp(\log(5)+\log(0.6)+0.2)\). Equivalently, \(\hat\mu=5\times0.6\times\exp(0.2)\). Since \(\exp(0.2)\approx1.2214\), the fitted count is \(\hat\mu\approx5\times0.6\times1.2214=3.6642\).

The fitted rate for this profile is \(0.6\exp(0.2)\approx0.7328\) events per patient-day. Multiplying by 5 patient-days gives the expected count, about 3.66 events. Reporting 0.7328 as the expected count would omit the exposure; reporting 3.66 as the rate would give the wrong units.

An offset need not always be an exposure. The defining feature is that its value is known and enters the linear predictor with coefficient one. For example, if a model uses a known adjustment \(o_0\) that is not expressed as log exposure, use \(\exp(o_0+x_0^{\mathsf T}\hat\beta)\) directly. Do not take another logarithm of an offset that is already supplied on the linear-predictor scale.

A Profile-Specific Mean Is Not a Population Average

A covariate profile describes particular predictor values, such as a specified age, treatment status, and exposure. Its fitted mean is conditional on those values. A population average instead concerns a distribution of profiles: it averages conditional means over the covariate and offset values represented in that population. These are different quantities whenever profiles vary, and neither should be substituted for the other without stating the target.

In notation, for a random covariate profile \(X\) and offset \(O\), the fitted model’s conditional mean at a profile is \(\exp(O+X^{\mathsf T}\hat\beta)\). An average over a target population concerns the expectation of this quantity as \(X\) and \(O\) vary under that population’s distribution. It is generally not obtained by simply entering average covariates into the profile formula.

Result: Let \(\eta=O+X^{\mathsf T}\hat\beta\), and suppose \(E[|\eta|]<\infty\) and \(E[\exp(\eta)]<\infty\). Then \(E[\exp(\eta)]\geq\exp(E[\eta])\), with strict inequality if \(\eta\) is not almost surely constant.

Proof. The exponential function is convex because its second derivative is \(\exp(z)>0\) for every real \(z\). Jensen’s inequality therefore gives \(E[\exp(\eta)]\geq\exp(E[\eta])\) when the stated expectations exist. Strict convexity implies strict inequality unless \(\eta\) is almost surely constant. Thus, even when the profile values are summarized by their average linear predictor, exponentiating that average generally does not produce the average of the profile-specific fitted means. \(\square\)

This inequality does not say that the average must be larger than the fitted mean at any particular profile. It compares the average of exponentiated linear predictors with the exponential of their average. A population average depends on the population’s distribution of profiles; a profile-specific prediction needs only the requested profile and offset.

Worked Example: Two Profiles and Their Population Average

Consider the fitted model \(\log(\mu)=\log(2)I(X=0)+\log(8)I(X=1)\), with no offset, in a population where half the observations have \(X=0\) and half have \(X=1\). Find each profile-specific fitted mean and the population average of those fitted means. Then compare this average with the fitted mean obtained by inserting the average value of the numeric indicator \(X\).

At profile \(X=0\), the fitted mean is \(\exp(\log(2))=2\). At profile \(X=1\), it is \(\exp(\log(8))=8\). Since the profiles each occur with probability \(1/2\), the population average of the fitted means in this example is \((1/2)(2)+(1/2)(8)=5\).

The average indicator value is \(E[X]=(1/2)(0)+(1/2)(1)=0.5\). In a log-linear parameterization with intercept \(\log(2)\) and coefficient \(\log(8)-\log(2)=\log(4)\), inserting \(X=0.5\) gives \(\exp(\log(2)+0.5\log(4))=2\exp(\log(2))=4\). This is not 5. The value 4 is the model’s fitted mean at the artificial covariate value \(X=0.5\); 5 is the average across the two actual profile-specific fitted means. They answer different questions.

Common Mistakes

  • Stopping at the linear predictor. The value \(o_0+x_0^{\mathsf T}\hat\beta\) is on the log-mean scale. Exponentiate it to obtain the fitted mean count.
  • Dropping or duplicating the offset. With \(o_0=\log(t_0)\), include the exposure once: \(\exp(\log(t_0)+x_0^{\mathsf T}\hat\beta)\). Do not omit \(t_0\), and do not multiply by it again after exponentiating the full expression.
  • Using the wrong profile coding. For an indicator, substitute the value dictated by its reference-category coding. For a centered predictor, use the centered value, not the raw value.
  • Calling a profile prediction a population average. A prediction at one specified profile conditions on that profile. It does not automatically average over the covariates of a population.
  • Expecting an integer result. A fitted conditional mean is an expectation and may be fractional; it is not a realized count.
Key takeaway: To obtain a fitted conditional expected count, encode the requested covariate profile, add its known offset on the log scale, and exponentiate using the fitted coefficients. State the profile and exposure so the prediction’s target and units are clear.

Check Your Understanding

For each question, distinguish the profile, offset, and quantity being requested.

  1. A fitted model has \(\log(\mu)=\log(t)+\log(1.2)+0.1x\). What is the fitted mean for \(x=3\) and \(t=4\)? Show the substitution and exponentiation.
  2. In a model with offset \(\log(t)\), what does the fitted count mean become if exposure doubles while all covariates remain fixed?
  3. Why is a fitted value of 6.4 a permissible conditional expected count even though observed counts are integers?
  4. Explain the difference between a fitted mean at one specified profile and an average of fitted means across a population with varying profiles.
  5. Why will inserting average covariate values into a log-link model generally fail to give the average of the profile-specific fitted means?
Clinical Biostats