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.
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
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.
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:
Now exponentiate the entire sum:
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.
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:
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
Therefore,
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
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
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.
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,
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.
Check Your Understanding
For each question, show the design vector, the linear predictor, and the fitted mean where a calculation is requested.
- A fitted model has intercept and slope estimates \(-0.20\) and \(0.30\). Calculate the fitted mean at \(x=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\).
- In a model with terms \(1,c,t,ct\), what design vector corresponds to \(c=2,t=1\)?
- Why does exponentiating the separate terms and adding them not give the fitted mean?
- If coefficients are rounded before calculation, which design profiles can be especially sensitive to that rounding, according to the bound in this tutorial?