Tutorials › Generalized Linear Models › Likelihood Deviance With Offsets and Weights

Offsets Weights and Trials · Tutorial 136 of 981

Likelihood Deviance With Offsets and Weights

Learn to derive weighted deviances with fixed offsets and determine whether a weight represents replication, precision, or binomial trials.

Intermediate 12 min read

What You'll Learn

  • Define fitted-versus-saturated deviance contributions for exponential-family GLMs
  • Derive how frequency and precision weights scale likelihood-ratio contributions
  • Explain why fixed offsets affect fitted means but are absorbed by saturated means
  • Calculate Poisson deviance with an exposure offset and frequency weight
  • Calculate binomial deviance using trial counts without treating them as generic weights
  • State when differences in deviance equal likelihood-ratio statistics

Why Weights and Offsets Matter for Deviance

A deviance compares the likelihood of a fitted model with the likelihood of a saturated model, one that can fit each observation separately. In a generalized linear model, a fixed offset contributes to each fitted linear predictor, while weights determine how strongly each observation contributes to the likelihood. Both details matter when calculating the comparison.

The key distinction is that the offset changes the fitted mean, whereas the saturated model can usually absorb the same fixed offset into its unrestricted predictor. Weights, by contrast, scale the likelihood contribution under the weight convention being used. A frequency weight, a precision weight, and a binomial trial count can therefore lead to different likelihood interpretations even when they appear in similar places in software output.

Definition: For observations \(y_i\) with fitted means \(\hat{\mu}_i\), the likelihood deviance is \(D=2\{\ell_{\mathrm{sat}}-\ell_{\mathrm{fit}}\}\), where \(\ell_{\mathrm{sat}}\) is the maximized log-likelihood in the saturated model and \(\ell_{\mathrm{fit}}\) is the maximized log-likelihood in the model being assessed. A weighted deviance uses the likelihood appropriate to the specified weights; it is not defined by multiplying an unweighted deviance by an arbitrary number.

Likelihood Contributions and Fixed Offsets

For an exponential-dispersion family, write the parameter-dependent part of an observation’s log-likelihood as \(\{y_i\theta_i-b(\theta_i)\}/a(\phi)\), where \(\theta_i\) is the canonical parameter, \(b\) is the cumulant function, and \(\phi\) is the dispersion parameter. The mean is \(\mu_i=b'(\theta_i)\). Terms that do not depend on the model mean are omitted here. The unit deviance is twice the loss in this numerator relative to the saturated fit.

$$ d(y_i,\mu_i) =2\left\{y_i\theta_{y_i}-b(\theta_{y_i}) -\left[y_i\theta_i-b(\theta_i)\right]\right\}, \qquad b'(\theta_{y_i})=y_i. $$

When the observed value is on the boundary of the mean parameter space, such as zero successes in a binomial observation, the saturated expression is interpreted by its limit. The familiar convention \(0\log 0=0\) gives the same finite deviance formulas.

An offset \(o_i\) is a known, fixed quantity included in the linear predictor, for example \(\eta_i=x_i^\mathsf{T}\beta+o_i\). The fitted mean is determined by the inverse link applied to this predictor. In a saturated model, each observation has an unrestricted predictor \(\eta_i^{\mathrm{sat}}\). For any admissible saturated mean, that predictor can be written as a free component plus the same offset \(o_i\). Thus, for a fixed offset and an unrestricted saturated model, the offset does not prevent the saturated fit from attaining its usual observation-by-observation maximum. It still changes the fitted-model mean, and therefore changes the deviance indirectly.

How Weight Conventions Enter

Suppose a row has a nonnegative weight \(w_i\). When its meaning is frequency replication, \(w_i\) is an integer number of identical records. Its log-likelihood contribution is repeated \(w_i\) times. When a valid precision-weight likelihood is specified, the likelihood contribution is also weighted, but the underlying sampling model gives \(w_i\) a precision interpretation. In either case, if the log-likelihood has the weighted exponential-family form below, the unscaled deviance contribution is \(w_i d(y_i,\hat{\mu}_i)\).

$$ \ell_{\mathrm{sat}}-\ell_{\mathrm{fit}} =\sum_i \frac{w_i}{a(\phi)} \left[ \{y_i\theta_{y_i}-b(\theta_{y_i})\} -\{y_i\hat{\theta}_i-b(\hat{\theta}_i)\} \right], \qquad D_w=\sum_i w_i d(y_i,\hat{\mu}_i). $$

The likelihood-ratio statistic is \(2(\ell_{\mathrm{sat}}-\ell_{\mathrm{fit}})=D_w/a(\phi)\) when the same known dispersion parameter applies to both likelihoods. For Poisson and binomial models, \(a(\phi)=1\). For a Gaussian model with variance \(\phi/w_i\), the unscaled deviance is weighted squared error, and the likelihood-ratio statistic divides that deviance by \(\phi\).

A weight can multiply a log-likelihood algebraically without defining a valid sampling distribution. In particular, software may use prior or analytic weights in a quasi-likelihood or estimating-equation calculation. If there is no specified likelihood, the resulting weighted deviance is not automatically a likelihood-ratio statistic. Its formula and inferential interpretation depend on the convention and model actually used.

Result: If the fitted and saturated likelihoods use the same observations, weight interpretation, fixed offsets, and likelihood constants, then \(D_w=2(\ell_{\mathrm{sat}}-\ell_{\mathrm{fit}})\) by definition for that likelihood. Under the weighted exponential-family form above, \(D_w=\sum_i w_i d(y_i,\hat{\mu}_i)\), with the likelihood-ratio statistic equal to \(D_w/a(\phi)\) when \(\phi\) is fixed and common to both fits.

Worked Deviance Calculations

Worked Example: Poisson Exposure Offset and Frequency Weight

A Poisson model uses exposure \(e=2\) as a log-link offset, so \(\eta=\log(2)+\beta\). Suppose \(\exp(\hat{\beta})=1.5\). The fitted mean is \(\hat{\mu}=2(1.5)=3\). The observed count is \(y=4\), and the row has frequency weight \(w=2\), meaning two identical records with count 4 and the same predictors and offset.

For one Poisson observation, the unit deviance is \(d(y,\mu)=2\{y\log(y/\mu)-(y-\mu)\}\). Substituting the observed and fitted means gives

$$ d(4,3) =2\left\{4\log(4/3)-(4-3)\right\} =2\{1.150728-1\} =0.301456. $$

The saturated mean for each replicated record is 4. The frequency-weighted deviance is therefore

$$ D_w=2d(4,3)=2(0.301456)=0.602912. $$

Since the Poisson dispersion factor is 1, this is also twice the log-likelihood difference between the saturated and fitted models. The offset enters the fitted mean 3; the saturated model reaches mean 4 by choosing its unrestricted predictor to accommodate the same offset.

Worked Example: Binomial Trials Are Already in the Likelihood

Suppose one grouped binomial observation has \(y=3\) successes in \(m=5\) trials. A logit model with fixed offset \(o=\log 2\) and coefficient \(\hat{\beta}=\log(1/4)\) has fitted linear predictor \(\hat{\eta}=\log 2+\log(1/4)=\log(1/2)\). Thus \(\hat{p}=1/3\), not \(0.4\). To illustrate the calculation with a fitted probability of \(0.4\), instead take \(\hat{\beta}=\log(1/3)\), giving \(\hat{\eta}=\log(2/3)\) and \(\hat{p}=0.4\).

The saturated success probability is \(3/5=0.6\). The binomial deviance for the grouped observation is

$$ d_{\mathrm{bin}} =2\left\{3\log\left(\frac{3}{5(0.4)}\right) +2\log\left(\frac{2}{5(0.6)}\right)\right\} =2\left\{3\log(1.5)+2\log(2/3)\right\} =0.810930. $$

The five trials are already represented by the success and failure counts in this likelihood. Multiplying this contribution by another weight of 5 would describe a different weighting operation, not merely the same five trials. The fixed offset helps determine the fitted probability, while the saturated probability is \(0.6\).

Worked Example: Gaussian Precision Weights and a Fixed Offset

Consider independent Gaussian observations with \(Y_i\sim N(\mu_i,\phi/w_i)\), known \(\phi=2\), weights \(w_1=3\) and \(w_2=0.5\), and observations \(y_1=2,y_2=4\). Suppose a fixed identity-link offset is included, and the fitted means are \(\hat{\mu}_1=1,\hat{\mu}_2=5\). The saturated means are \(2\) and \(4\). The log density for one observation is

$$ \ell_i(\mu_i) =-\frac{1}{2}\log\left(\frac{2\pi\phi}{w_i}\right) -\frac{w_i(y_i-\mu_i)^2}{2\phi}. $$

The normalizing terms are the same at the fitted and saturated means, so they cancel in the log-likelihood difference. The residuals from the fitted means are \(2-1=1\) and \(4-5=-1\), while both saturated residuals are zero. Hence

$$ D_w=\sum_i w_i(y_i-\hat{\mu}_i)^2 =3(1)^2+0.5(-1)^2=3.5. $$

The likelihood-ratio statistic is \(D_w/\phi=3.5/2=1.75\). The offset affects which fitted means the model produces, but the saturated means remain the observed values.

Comparing Two Fitted Models

Deviance also compares nested fitted models. Let model 0 be a submodel of model 1, fitted to the same data with the same likelihood, weights, and fixed offsets. Their saturated log-likelihood is the same. Write \(D_0=2(\ell_{\mathrm{sat}}-\ell_0)\) and \(D_1=2(\ell_{\mathrm{sat}}-\ell_1)\), where each log-likelihood is maximized within its model. Subtracting gives

$$ D_0-D_1 =2(\ell_{\mathrm{sat}}-\ell_0)-2(\ell_{\mathrm{sat}}-\ell_1) =2(\ell_1-\ell_0). $$

Thus, the reduction in deviance is exactly the likelihood-ratio statistic for the nested comparison when the likelihood is genuine. With known dispersion, the exponential-family unscaled deviance reduction is divided by \(a(\phi)\) to obtain that statistic. Under the usual regularity conditions for likelihood-ratio inference—including an identifiable, regular model, an interior true parameter, and a fixed-dimensional difference in model dimension—the statistic is asymptotically chi-squared with degrees of freedom equal to that difference. If dispersion is estimated or the weights define only a quasi-likelihood, do not assume this simple scaling or reference distribution without additional justification.

1
Fix the likelihood convention.
Decide whether each weight means replicated observations, precision under a specified sampling model, or a non-likelihood working weight.
2
Fit the model with its offset.
Compute the fitted mean from the predictor that includes the known offset.
3
Construct the saturated comparison.
Allow each observation its own mean, with the fixed offset still present in its predictor.
4
Take the likelihood difference.
Use the weight according to its stated meaning, and divide the unscaled deviance by the appropriate dispersion factor only when forming the likelihood-ratio statistic.

Common Mistake: Treating Every Number Called a Weight Alike

A frequent error is to see a number \(w_i\) beside a row and automatically multiply that row’s deviance by it, then interpret the result as a likelihood-ratio statistic. This overlooks whether the weight describes replication, precision, or something else. For a genuine frequency weight, multiplying the row log-likelihood by an integer replication count is justified. For a precision weight, the likelihood must match the specified sampling variance or other precision model. For a binomial observation, the trial count is part of the binomial response likelihood and is not an interchangeable generic weight.

A second error is to think a fixed offset must be removed from the saturated model, or that it contributes an extra deviance term. The correction is to use the same offset in both predictors. The saturated model’s unrestricted predictor absorbs it, so the offset does not create a separate saturated-versus-fitted term; it affects the fitted mean and therefore the resulting deviance.

Key takeaway: A weighted deviance is a likelihood comparison only when its weights correspond to the likelihood being compared. Keep fixed offsets in the fitted predictor, let the saturated predictor fit each observation, and use the appropriate dispersion scaling when converting deviance to a likelihood-ratio statistic.

Check Your Understanding

For each question, distinguish what changes the fitted mean from what scales or defines the likelihood.

  1. In a Poisson log-link model, what role does a fixed log-exposure offset play in the fitted mean and in the saturated fit?
  2. A row has frequency weight 4. What does that mean for its log-likelihood contribution, and what assumption makes the replication interpretation literal?
  3. Why should a grouped binomial observation with \(m\) trials not automatically receive an additional generic weight of \(m\)?
  4. For \(Y_i\sim N(\mu_i,\phi/w_i)\), what is the unscaled Gaussian deviance contribution, and how is it related to the likelihood-ratio statistic when \(\phi\) is known?
  5. Two nested models use the same data, weights, and offsets. Show in one line why their deviance reduction equals twice the difference in their maximized log-likelihoods.
Clinical Biostats