Tutorials › Generalized Linear Models › Combining Offsets, Trials, and Weights

Offsets Weights and Trials · Tutorial 135 of 981

Combining Offsets, Trials, and Weights

Learn to keep offsets, trial counts, and likelihood weights distinct when forming and interpreting binomial and Poisson GLMs.

Intermediate 10 min read

What You'll Learn

  • Write binomial and Poisson weighted log-likelihoods with known offsets.
  • Distinguish a binomial trial count from a generic observation weight.
  • Derive weighted score equations for models with offsets.
  • Calculate a coefficient estimate from a combined binomial example.
  • Calculate fitted means in a weighted Poisson model with exposure offsets.
  • Recognize what multiplying all likelihood weights changes—and what it leaves unchanged.

Three Components, Three Roles

A generalized linear model can contain a known offset, a trial count, and an observation weight at the same time. These quantities may all appear as multipliers or additions in likelihood calculations, but they do different jobs. An offset is a known contribution to the linear predictor; a trial count specifies the binomial sampling distribution; and an observation weight scales an observation’s contribution to a chosen weighted likelihood or likelihood criterion.

Keeping those roles separate is essential for interpretation. In a binomial model, changing the trial count changes the number of Bernoulli outcomes represented by an observation. A generic likelihood weight does not automatically create additional trials. In a Poisson model with a log link, an exposure offset changes the mean in proportion to exposure, while a weight changes how strongly the observation contributes to estimation.

Definition: For observation \(i\), let \(o_i\) be a known offset, \(a_i\geq 0\) an observation weight, and \(x_i^\mathsf{T}\beta\) the estimated part of the linear predictor. The linear predictor is \(x_i^\mathsf{T}\beta+o_i\). A weighted log-likelihood criterion is \(\ell_w(\beta)=\sum_i a_i\ell_i(\beta)\), where \(\ell_i\) is the observation’s model log-likelihood, including its trial count when the response is binomial. A weight of zero removes that observation’s contribution to this criterion.

The weight’s sampling interpretation depends on how it was defined. An integer frequency weight can represent replicated observations, so its weighted likelihood agrees with the likelihood for those replications, up to parameter-free constants. Other weights, such as relative-precision weights, define a weighted likelihood convention or criterion; they do not, by themselves, assert that the observation was literally replicated. The calculations below state the weighting convention explicitly.

Binomial Likelihood With an Offset and a Weight

Suppose \(Y_i\) is the number of successes among \(m_i\) trials, with \(Y_i\sim\operatorname{Binomial}(m_i,p_i)\). Use a logit link with a known offset:

$$ \operatorname{logit}(p_i)=\log\!\left(\frac{p_i}{1-p_i}\right) =x_i^\mathsf{T}\beta+o_i. $$

For a known nonnegative weight \(a_i\), the binomial log-likelihood contribution is

$$ \ell_i(\beta)= \log {m_i\choose y_i} +y_i\log(p_i)+(m_i-y_i)\log(1-p_i), \qquad \ell_w(\beta)=\sum_i a_i\ell_i(\beta). $$

The trial count \(m_i\) determines the number of successes and failures in the binomial contribution. The offset \(o_i\) enters through \(p_i\) but is not estimated as a coefficient. The weight \(a_i\) scales the entire contribution under the stated convention.

Result: If \(p_i=\operatorname{logit}^{-1}(x_i^\mathsf{T}\beta+o_i)\), then the weighted score for \(\beta\) is \(\displaystyle U_w(\beta)=\sum_i a_i x_i(y_i-m_i p_i)\).

To derive this, differentiate the binomial log-likelihood with respect to its linear predictor \(\eta_i=x_i^\mathsf{T}\beta+o_i\). Since \(dp_i/d\eta_i=p_i(1-p_i)\),

$$ \frac{\partial\ell_i}{\partial\eta_i} = \left(\frac{y_i}{p_i}-\frac{m_i-y_i}{1-p_i}\right)p_i(1-p_i) =y_i-m_i p_i. $$

The offset is fixed, so \(\partial\eta_i/\partial\beta=x_i\). Multiplying the resulting score by \(a_i\) and summing gives the stated expression. In particular, the score depends on \(m_i\) through the expected success count \(m_i p_i\); replacing \(m_i\) by \(a_i\) would change the model rather than apply the specified weight. \(\square\)

Worked Example: Binomial Trials, a Fixed Offset, and Unequal Weights

Consider two binomial observations with a common intercept \(\beta\), the same known offset \(o_i=\log 2\), and weights \(a_1=1\), \(a_2=2\). The data are \(y_1=4,m_1=10\) and \(y_2=12,m_2=20\). Find the weighted maximum-likelihood estimate of \(\beta\).

The linear predictor is \(\beta+\log 2\) for both observations, so both have the same success probability \(p=\operatorname{logit}^{-1}(\beta+\log 2)\). The intercept score is

$$ U_w(\beta) =1(4-10p)+2(12-20p) =28-50p. $$

Setting the score to zero gives \(p=28/50=0.56\). Thus the fitted odds are \(0.56/0.44=14/11\). Since those odds equal \(\exp(\beta+\log 2)=2\exp(\beta)\),

$$ \widehat{\beta}=\log(14/11)-\log 2 =\log(7/11)\approx -0.452. $$

The offset shifts the log odds by \(\log 2\); it is not estimated. The binomial trial counts are 10 and 20, and the weights multiply their respective score contributions. For example, the second observation contributes \(2(12-20p)\), not a binomial contribution with 40 trials. The weighted score is zero at the reported estimate, as required.

Poisson Likelihood With an Exposure Offset and a Weight

For a Poisson response \(Y_i\sim\operatorname{Poisson}(\mu_i)\), the log-link model with a known offset is

$$ \log(\mu_i)=x_i^\mathsf{T}\beta+o_i. $$

When \(o_i=\log(E_i)\), where \(E_i>0\) is known exposure, this is equivalent to \(\mu_i=E_i\exp(x_i^\mathsf{T}\beta)\). With weights \(a_i\geq0\), the weighted log-likelihood is

$$ \ell_w(\beta) =\sum_i a_i\left[y_i\log(\mu_i)-\mu_i-\log(y_i!)\right]. $$

The exposure changes the expected count through the offset. The observation weight scales the log-likelihood contribution. A Poisson count is not a binomial trial count: there is no binomial denominator \(m_i\) here.

Result: For the Poisson log-link model above, the weighted score is \(\displaystyle U_w(\beta)=\sum_i a_i x_i(y_i-\mu_i)\).

For a complete derivation, differentiate one contribution with respect to \(\eta_i=x_i^\mathsf{T}\beta+o_i=\log(\mu_i)\). Since \(d\mu_i/d\eta_i=\mu_i\),

$$ \frac{\partial\ell_i}{\partial\eta_i} = \left(\frac{y_i}{\mu_i}-1\right)\mu_i =y_i-\mu_i. $$

As the offset is fixed, differentiating \(\eta_i\) with respect to \(\beta\) gives \(x_i\). Scaling each score by its weight and summing yields the result. \(\square\)

Worked Example: Weighted Poisson Counts With Different Exposures

Suppose \(Y_1=3\) and \(Y_2=4\) are independent Poisson counts, with exposures \(E_1=2\) and \(E_2=5\). Fit an intercept-only log-rate model \(\log(\mu_i)=\beta+\log(E_i)\), using weights \(a_1=1\) and \(a_2=2\). Find \(\widehat{\beta}\) and both fitted means.

Here \(\mu_1=2\exp(\beta)\) and \(\mu_2=5\exp(\beta)\). The score equation is

$$ 0=1(3-\mu_1)+2(4-\mu_2) =11-12\exp(\beta). $$

Therefore \(\exp(\widehat{\beta})=11/12\), so \(\widehat{\beta}=\log(11/12)\approx-0.0870\). The fitted means are

$$ \widehat{\mu}_1=2(11/12)=11/6\approx1.833, \qquad \widehat{\mu}_2=5(11/12)=55/12\approx4.583. $$

The exposure ratio is reflected in the fitted means: \(\widehat{\mu}_2/\widehat{\mu}_1=5/2\). The weights enter the intercept score, giving weighted observed total \(3+2(4)=11\) and weighted exposure total \(2+2(5)=12\). The score at the estimate is \(11-12(11/12)=0\).

What Rescaling All Weights Does

A useful check is to distinguish changing relative weights from multiplying every weight by the same positive constant. Assume the model and offsets are fixed, \(c>0\), and the unpenalized weighted likelihood has a maximizer. Replacing every \(a_i\) by \(ca_i\) multiplies the entire criterion by \(c\):

$$ \ell_{cw}(\beta)=\sum_i ca_i\ell_i(\beta)=c\ell_w(\beta). $$

For any two parameter values, multiplication by a positive constant preserves their likelihood ordering: \(\ell_w(\beta_1)\geq\ell_w(\beta_2)\) if and only if \(c\ell_w(\beta_1)\geq c\ell_w(\beta_2)\). Thus the set of maximizers is unchanged. At a regular interior maximum, the observed information, defined as the negative Hessian of the log-likelihood, is multiplied by \(c\) as well. This is a statement about the curvature of this criterion; the inferential interpretation of standard errors depends on what the weights mean and on the model’s dispersion convention.

Worked Example: Rescaling Weights Without Changing the Estimate

In the binomial example, the score equation was \(28-50p=0\), giving \(p=0.56\) and \(\widehat{\beta}=\log(7/11)\). If both weights are doubled, the score becomes

$$ 2(4-10p)+4(12-20p)=56-100p. $$

Its zero is still \(p=56/100=0.56\), and the same offset conversion gives \(\widehat{\beta}=\log(7/11)\). The data contributions have been scaled together, so their relative balance and the coefficient estimate remain unchanged. This does not mean that doubling a single weight has no effect: changing only one weight alters the relative balance of observations and can change the estimate.

Common Mistake: Treating Every Multiplier as the Same Thing

A tempting but incorrect shortcut is to combine a binomial trial count and a generic weight into a new trial count, or to treat an exposure offset as though it were an observation weight. The terms have different mathematical locations. In the binomial model, \(m_i\) appears in the sampling distribution and in \(m_i p_i\); \(a_i\) multiplies the log-likelihood contribution; and \(o_i\) enters the predictor that determines \(p_i\). In the Poisson model, exposure enters the mean through \(\exp(o_i)\), while \(a_i\) scales the contribution.

For an integer frequency weight, replication may give a literal sampling interpretation, but that interpretation does not turn every weight into a trial count. A relative-precision or other prior weight is not automatically extra data. Before calculating, write the model mean or probability and the weighted log-likelihood separately; then check that each quantity appears in its intended place.

Key takeaway: Keep the three roles visible: offsets are known predictor terms, binomial trial counts specify the response distribution, and observation weights scale likelihood contributions under a stated convention. Their effects can interact in estimation, but they are not interchangeable.

Check Your Understanding

Use the model equations and weighted likelihoods above to answer these questions.

  1. In a binomial-logit model, which quantity determines the expected number of successes \(m_i p_i\), and which quantity scales the observation’s likelihood contribution?
  2. A Poisson model has exposure \(E_i\) and a log link. Write its mean in terms of \(E_i\), \(x_i^\mathsf{T}\beta\), and identify where an observation weight enters.
  3. Why does replacing \(m_i\) by \(a_i m_i\) generally change the binomial model rather than merely apply the specified observation weight?
  4. If every positive likelihood weight is multiplied by the same positive constant, what happens to the set of maximizers of an unpenalized weighted log-likelihood? Explain.
  5. In the weighted Poisson example, verify the intercept score at the fitted coefficient using the two fitted means.
Clinical Biostats