Tutorials › Generalized Linear Models › Computing Fitted Poisson Means

Poisson Regression Foundations · Tutorial 419 of 981

Computing Fitted Poisson Means

Practice assembling design rows, calculating linear predictors, and exponentiating them to obtain fitted Poisson means.

Intermediate 10 min read

What You'll Learn

  • Write a covariate profile as a design row that matches the fitted coefficient order
  • Calculate a linear predictor using the row-by-vector product
  • Exponentiate the predictor to obtain a fitted conditional mean
  • Check computations by expressing the fitted mean as a product
  • Assess how rounding coefficients can affect a calculated fitted mean

From a Fitted Model to a Fitted Mean

Once a Poisson regression has been fitted, calculating its predicted mean for a particular covariate profile is a direct two-step operation: evaluate the linear predictor, then apply the inverse log link. The arithmetic is simple, but it is easy to get a wrong answer by changing the order of the coefficients and covariates, omitting an intercept, or exponentiating before all terms have been added.

This tutorial treats the fitted coefficient vector as given. The goal is to calculate and check the fitted conditional mean at specified covariate values, not to estimate the coefficients or assess their uncertainty.

Definition: For observation \(i\), let \(x_i\) be the column vector of design variables, including an intercept component when the model has an intercept, and let \(\hat{\beta}\) be the fitted coefficient vector in the corresponding order. The fitted linear predictor is \(\hat{\eta}_i=x_i^T\hat{\beta}\). Under the Poisson model with log link, the fitted conditional mean is \(\hat{\mu}_i=\exp(\hat{\eta}_i)\).

The design vector contains the values actually used by the model. For example, if the model includes an intercept and one continuous predictor \(z\), then \(x_i=(1,z_i)^T\). If a binary predictor is represented by an indicator \(g_i\), its value is 0 or 1 in the design vector. With several predictors, the coefficient and design-vector entries must be paired in exactly the same order as in the fitted model. Terms such as interactions must also be represented in that vector.

The result \(\hat{\mu}_i\) is on the response scale: it is the fitted conditional mean count for the specified covariate profile. It need not be an integer. A conditional mean of 2.8, for instance, is a mean count, not a claim that an individual observation must equal 2.8.

The Calculation in Two Steps

1
Build the design vector.
Write every model term in the specified coefficient order, using the covariate values for the profile. Include the intercept entry and any constructed terms, such as an interaction, when the model contains them.
2
Evaluate and exponentiate.
Multiply corresponding entries and add them to obtain \(\hat{\eta}_i=x_i^T\hat{\beta}\). Then calculate \(\hat{\mu}_i=\exp(\hat{\eta}_i)\).

For an intercept and two predictors, for example, if the coefficient order is \((\beta_0,\beta_1,\beta_2)\), the matching design vector is \((1,x_{i1},x_{i2})^T\). Thus the fitted predictor is \(\hat{\beta}_0+x_{i1}\hat{\beta}_1+x_{i2}\hat{\beta}_2\). The intercept is multiplied by 1, not by one of the observed predictor values.

Worked Example: One Continuous Predictor

Suppose the fitted model has an intercept and a continuous predictor \(z\), with \(\hat{\beta}_0=0.40\) and \(\hat{\beta}_1=0.18\). Calculate the fitted mean for a profile with \(z=3.5\).

The coefficient order is intercept, then \(z\), so the design vector is \(x=(1,3.5)^T\), and the fitted coefficient vector is \(\hat{\beta}=(0.40,0.18)^T\). First calculate the linear predictor:

$$ \hat{\eta}=1(0.40)+3.5(0.18)=0.40+0.63=1.03. $$

Now exponentiate the entire sum:

$$ \hat{\mu}=\exp(1.03)\approx 2.8017. $$

The fitted conditional mean is approximately 2.80. The exponent is positive, so the fitted mean is greater than 1, which is consistent with \(\exp(1.03)>1\).

Products as a Calculation Check

Exponentiating a sum can also be written as multiplying exponentiated terms. This identity is useful for checking hand calculations: each term contributes a factor, and their product must equal the exponential of the full linear predictor.

Result: For a finite-dimensional design vector \(x_i=(x_{i1},\ldots,x_{ip})^T\) and coefficient vector \(\hat{\beta}=(\hat{\beta}_1,\ldots,\hat{\beta}_p)^T\), the fitted mean satisfies \(\hat{\mu}_i=\prod_{j=1}^p \exp(x_{ij}\hat{\beta}_j)\).

Proof. By the definition of the fitted predictor and the row-by-vector product, \(\hat{\eta}_i=\sum_{j=1}^p x_{ij}\hat{\beta}_j\). The fitted mean is the exponential of this sum. The exponential of a finite sum is the product of the exponentials of its terms:

$$ \hat{\mu}_i =\exp\left(\sum_{j=1}^p x_{ij}\hat{\beta}_j\right) =\prod_{j=1}^p\exp(x_{ij}\hat{\beta}_j). $$

The identity is exact; any discrepancy between the two forms in a hand calculation is due to arithmetic or rounding. \(\square\)

Worked Example: Two Predictors and an Indicator

Suppose the fitted model has an intercept, a continuous predictor \(a\), a binary indicator \(g\), and a continuous predictor \(w\). The coefficients, in that order, are \((-0.70,0.25,0.60,-0.30)\). Calculate the fitted mean for \(a=2\), \(g=1\), and \(w=4\).

The design vector follows the same order as the coefficients: \(x=(1,2,1,4)^T\). The linear predictor is

$$ \hat{\eta} =1(-0.70)+2(0.25)+1(0.60)+4(-0.30) =-0.70+0.50+0.60-1.20=-0.80. $$

Therefore,

$$ \hat{\mu}=\exp(-0.80)\approx 0.4493. $$

As a check, the product form gives \(\exp(-0.70)\exp(0.50)\exp(0.60)\exp(-1.20)=\exp(-0.80)\approx0.4493\). The binary predictor contributes its coefficient because \(g=1\); had \(g=0\), its term in the linear predictor would have been zero.

Design Rows Must Match the Model

A coefficient vector is meaningful only together with its design-variable order and definitions. The number of entries in the design vector must equal the number of coefficients, and each entry must represent the term associated with the coefficient in that position. In particular, a model with an interaction requires an interaction entry in the design row; using only the original predictor values omits part of the specified linear predictor.

Worked Example: Including an Interaction Term

Suppose a fitted model uses an intercept, a centered age variable \(c\), a treatment indicator \(t\), and their interaction \(ct\), in that order. Let \(\hat{\beta}=(0.20,0.10,-0.40,0.05)^T\). Calculate the fitted mean for \(c=5\) and \(t=1\), then compare it with the fitted mean at \(c=5\) and \(t=0\).

For \(c=5,t=1\), the interaction value is \(ct=5(1)=5\). The complete design vector is \(x_1=(1,5,1,5)^T\), so

$$ \hat{\eta}_1 =1(0.20)+5(0.10)+1(-0.40)+5(0.05) =0.20+0.50-0.40+0.25=0.55. $$

Thus the fitted mean is \(\hat{\mu}_1=\exp(0.55)\approx1.7333\).

For \(c=5,t=0\), the interaction is \(ct=5(0)=0\), so \(x_0=(1,5,0,0)^T\). Then

$$ \hat{\eta}_0=1(0.20)+5(0.10)+0(-0.40)+0(0.05)=0.70, \qquad \hat{\mu}_0=\exp(0.70)\approx2.0138. $$

The two calculated means are different even though \(c\) is the same, because the indicator and interaction entries differ. The example also shows why an interaction must be calculated from the covariate values before evaluating the row-by-vector product.

Rounding and Numerical Accuracy

Fitted coefficients are often displayed with fewer digits than the software used internally. Replacing the full coefficients with rounded values can change the calculated predictor and therefore the fitted mean. The next result gives a direct bound on that change.

Result: Let \(\hat{\beta}\) be the coefficient vector used for the fitted mean, and let \(\tilde{\beta}\) be a rounded version satisfying \(|\tilde{\beta}_j-\hat{\beta}_j|\leq\epsilon_j\) for every \(j\). For a fixed finite design vector \(x_i\), define \(B_i=\sum_{j=1}^p |x_{ij}|\epsilon_j\). If \(\hat{\mu}_i=\exp(x_i^T\hat{\beta})\) and \(\tilde{\mu}_i=\exp(x_i^T\tilde{\beta})\), then \(\exp(-B_i)\leq\tilde{\mu}_i/\hat{\mu}_i\leq\exp(B_i)\).

Proof. The difference between the predictors is \[ x_i^T\tilde{\beta}-x_i^T\hat{\beta} =\sum_{j=1}^p x_{ij}(\tilde{\beta}_j-\hat{\beta}_j). \] By the triangle inequality and the assumed coefficient-wise bounds,

$$ \left|x_i^T\tilde{\beta}-x_i^T\hat{\beta}\right| \leq \sum_{j=1}^p |x_{ij}|\,|\tilde{\beta}_j-\hat{\beta}_j| \leq \sum_{j=1}^p |x_{ij}|\epsilon_j=B_i. $$

Since the ratio of the two means is the exponential of the predictor difference, \[ \frac{\tilde{\mu}_i}{\hat{\mu}_i} =\exp\left(x_i^T\tilde{\beta}-x_i^T\hat{\beta}\right). \] Exponentiation preserves order, so the bound on the predictor difference yields the stated lower and upper bounds. \(\square\)

The bound depends on the design values as well as on the coefficient rounding. A large covariate value can magnify the effect of a small coefficient discrepancy. For a reported calculation, retain enough digits to avoid avoidable discrepancies, and state that the final fitted mean is approximate when using rounded coefficients.

Common Mistakes

  • Exponentiating each term and adding the results. The link requires exponentiating the sum: \(\exp(a+b)\), not \(\exp(a)+\exp(b)\). Equivalently, one may multiply the exponentiated terms.
  • Leaving out the intercept. If the model includes an intercept, its design entry is 1 for every profile.
  • Pairing coefficients with the wrong covariates. Write the coefficient and design-vector orders beside one another before multiplying.
  • Omitting a constructed term. When an interaction is in the fitted model, calculate its value and include its coefficient contribution.
  • Calling the fitted mean a guaranteed observed count. The calculation returns a conditional mean, which may be non-integer; it does not determine the next observed count.
Key takeaway: For a specified covariate profile, assemble the design vector in the fitted model's order, calculate \(x_i^T\hat{\beta}\), and exponentiate the complete sum. The result is the fitted Poisson conditional mean for that profile.

Check Your Understanding

For each question, show the design vector, the linear predictor, and the fitted mean where a calculation is requested.

  1. A fitted model has intercept and slope estimates \(-0.20\) and \(0.30\). Calculate the fitted mean at \(x=2\).
  2. A model has coefficients \((0.10,-0.20,0.40)\) for an intercept, \(u\), and a binary indicator \(g\), respectively. Calculate the fitted mean at \(u=3,g=0\).
  3. In a model with terms \(1,c,t,ct\), what design vector corresponds to \(c=2,t=1\)?
  4. Why does exponentiating the separate terms and adding them not give the fitted mean?
  5. If coefficients are rounded before calculation, which design profiles can be especially sensitive to that rounding, according to the bound in this tutorial?
Clinical Biostats