Tutorials › Generalized Linear Models › Why Trial Counts Are Not Generic Weights

Offsets Weights and Trials · Tutorial 131 of 981

Why Trial Counts Are Not Generic Weights

Learn when binomial trial counts and Bernoulli weights produce matching score equations, and why that does not make them interchangeable sampling models.

Intermediate 12 min read

What You'll Learn

  • Write the likelihood for grouped binomial counts and for weighted Bernoulli responses
  • Derive the condition under which their score vectors agree
  • Distinguish equality of score equations from equality of likelihood values
  • Explain the combinatorial constant arising when Bernoulli trials are aggregated
  • Identify the error in weighting a binary outcome by a group’s trial count

Why the Meaning of a Weight Matters

A group with 3 successes in 10 trials is not a single Bernoulli observation equal to 1, nor is its observed success proportion a Bernoulli outcome. The count comes from 10 trials, and that sampling structure determines its likelihood and variance. Yet a weighted Bernoulli likelihood can produce the same score equations as the grouped binomial likelihood. The key is to match both the weight and the response correctly.

This distinction matters because matching score equations means the parameter estimates may agree, but it does not turn every weighted response into a binomial count or make the two sampling interpretations interchangeable. The calculation below isolates exactly what agrees and what does not.

Two Likelihood Contributions

Suppose groups \(i=1,\ldots,m\) are independent. In group \(i\), \(n_i\) is a positive integer number of trials and \(y_i\) is the number of successes, where \(y_i\in\{0,\ldots,n_i\}\). All trials in that group have success probability \(p_i\). Let \(p_i=h(\eta_i)\), where \(h\) is a differentiable inverse link, \(\eta_i=x_i^{\mathsf T}\beta+o_i\), \(x_i\) is a fixed design vector, and \(o_i\) is a fixed offset. We consider parameter values for which \(0<p_i<1\).

Under the grouped binomial model, \(Y_i\sim\operatorname{Binomial}(n_i,p_i)\), and the log-likelihood contribution is

$$ \ell_i^{\mathrm{bin}}(\beta) = \log {n_i\choose y_i} +y_i\log p_i+(n_i-y_i)\log(1-p_i). $$

Alternatively, record the observed proportion \(r_i=y_i/n_i\) and form a Bernoulli log-likelihood kernel weighted by \(n_i\):

$$ \ell_i^{\mathrm{wt}}(\beta) = n_i\left\{r_i\log p_i+(1-r_i)\log(1-p_i)\right\}. $$

This weighted expression is a likelihood kernel in \(p_i\), not a claim that the fractional value \(r_i\) is itself a Bernoulli observation. Substituting \(r_i=y_i/n_i\) gives \(n_i r_i=y_i\) and \(n_i(1-r_i)=n_i-y_i\). Thus the two expressions contain the same terms that depend on \(\beta\); the binomial expression also contains a combinatorial term that does not depend on \(\beta\).

Definition: A grouped binomial observation records \(y_i\) successes out of \(n_i\) trials. Its observed proportion is \(r_i=y_i/n_i\). The weighted Bernoulli kernel with response \(r_i\) and weight \(n_i\) uses the contribution \(n_i\{r_i\log p_i+(1-r_i)\log(1-p_i)\}\). The match requires both \(r_i=y_i/n_i\) and weight \(n_i\).

Worked Example: Same Parameter-Dependent Likelihood, Different Values

One group has \(n=10\) trials and \(y=3\) successes. The binomial likelihood is \({10\choose3}p^3(1-p)^7\); the weighted-proportion kernel uses \(r=3/10=0.3\) and weight 10.

The weighted log-likelihood contribution is \(10\{0.3\log p+0.7\log(1-p)\}=3\log p+7\log(1-p)\). The binomial log-likelihood contribution is this same expression plus \(\log{10\choose3}=\log(120)\). Therefore their difference is \(\log(120)\) at every \(p\), not just at the estimate.

For this intercept-only model, both are maximized at \(\hat p=y/n=0.3\). At that value, the weighted contribution is \(3\log(0.3)+7\log(0.7)\approx-6.108643\). The binomial log-likelihood is \(-6.108643+\log(120)\approx-1.321151\). Their numerical values differ, while their maximizer is the same.

When the Score Equations Coincide

For the binomial model, differentiate the parameter-dependent part of the contribution with respect to \(\eta_i\). Since \(p_i=h(\eta_i)\), the chain rule gives

$$ \frac{\partial \ell_i^{\mathrm{bin}}}{\partial \eta_i} = \left(\frac{y_i}{p_i}-\frac{n_i-y_i}{1-p_i}\right)h'(\eta_i) = (y_i-n_i p_i)\frac{h'(\eta_i)}{p_i(1-p_i)}. $$

The offset is fixed, so \(\partial\eta_i/\partial\beta=x_i\). The full score contribution is therefore the last expression multiplied by \(x_i\). For the weighted kernel, the derivative with respect to \(\eta_i\) is

$$ n_i\left(\frac{r_i}{p_i}-\frac{1-r_i}{1-p_i}\right)h'(\eta_i) = n_i(r_i-p_i)\frac{h'(\eta_i)}{p_i(1-p_i)}. $$

When \(r_i=y_i/n_i\), this is exactly the binomial derivative. The equality holds for any differentiable inverse link on the stated interior parameter range; it is not limited to the logit link.

Theorem: For independent grouped binomial observations with \(n_i\geq1\), \(0\leq y_i\leq n_i\), and \(0<p_i=h(x_i^{\mathsf T}\beta+o_i)<1\), the binomial log-likelihood and the weighted Bernoulli kernel with response \(r_i=y_i/n_i\) and weight \(n_i\) have identical score vectors. Their log-likelihoods differ only by \(\sum_i\log{n_i\choose y_i}\), which is independent of \(\beta\).

Proof. For each \(i\), substitution of \(r_i=y_i/n_i\) into the weighted contribution gives \(\ell_i^{\mathrm{wt}}=y_i\log p_i+(n_i-y_i)\log(1-p_i)\). Hence \(\ell_i^{\mathrm{bin}}-\ell_i^{\mathrm{wt}}=\log{n_i\choose y_i}\). Summing over groups gives the stated constant difference. Differentiating that constant with respect to \(\beta\) gives zero, so the score vectors agree. Equivalently, the chain-rule derivatives above agree group by group, and multiplication by \(x_i\) and summation preserve equality. \(\square\)

Consequently, where the maxima exist, the two expressions have the same maximizing parameter values. Their observed derivatives of every order also agree wherever those derivatives exist, since their difference is constant in \(\beta\). This statement concerns the likelihood as a function of the model parameters; the data probability model still has to be specified correctly.

Worked Example: Matching Scores in a Logistic Model

Consider two groups with \(x_1=0\), \(x_2=1\), no offsets, and logistic probabilities \(p_i=\exp(\eta_i)/(1+\exp(\eta_i))\), where \(\eta_i=\beta_0+\beta_1x_i\). Let group 1 have \(n_1=4,y_1=1\), and group 2 have \(n_2=6,y_2=4\). The observed proportions are \(r_1=1/4\) and \(r_2=4/6=2/3\).

For the logit link, \(h'(\eta_i)=p_i(1-p_i)\), so the score contribution is \(x_i(y_i-n_i p_i)\). The total score is therefore \(\sum_i x_i(y_i-n_i p_i)\), with the intercept component using \(x_i\)'s intercept coordinate 1.

At \(\beta_0=\log(1/3)\) and \(\beta_1=\log(2)-\log(1/3)=\log(6)\), the fitted probabilities are \(p_1=1/4\) and \(p_2=2/3\). The group residuals \(y_i-n_i p_i\) are \(1-4(1/4)=0\) and \(4-6(2/3)=0\). Thus both score components are zero. The weighted-kernel residuals are \(n_i(r_i-p_i)\), which are also \(0\) in each group. The matching scores follow directly from the matched proportions and trial-count weights, not from any special feature of this particular fitted value.

Why the Binomial Constant Is There

The binomial coefficient has a sampling interpretation. Suppose there are \(n\) independent Bernoulli trials, each with success probability \(p\), and the recorded data are the ordered trial outcomes. Any particular ordered sequence with \(y\) successes has probability \(p^y(1-p)^{n-y}\). If instead the data record only the count \(y\), there are \({n\choose y}\) different ordered sequences that produce that count. Adding their probabilities gives

$$ P(Y=y) = {n\choose y}p^y(1-p)^{n-y}. $$

This explains why the probability of a count includes the combinatorial factor, while the likelihood for one particular ordered sequence does not. The factor is constant with respect to \(p\), so it does not change the score or likelihood ratios for this model. But it is part of the probability assigned to the recorded count.

Result: If \(n\) independent Bernoulli trials have the same success probability \(p\), their success count has a binomial distribution. The probability of the count equals the likelihood of any one ordered sequence with that count multiplied by \({n\choose y}\).

Proof. There are \({n\choose y}\) ways to choose which \(y\) of the \(n\) trial positions are successes. By independence, each such sequence has probability \(p^y(1-p)^{n-y}\). These sequences are mutually exclusive and exhaust the event that the count is \(y\). Summing their equal probabilities gives \({n\choose y}p^y(1-p)^{n-y}\), as claimed. \(\square\)

The same counting argument also clarifies the interpretation of the weighted kernel: after aggregation, its parameter-dependent part matches the likelihood of the count, but the kernel alone does not include the factor that makes it the binomial probability mass function.

Worked Example: Aggregating Individual Bernoulli Trials

Suppose 4 independent patients each have probability \(p\) of responding to treatment, and the observed outcomes are response, no response, response, no response. The likelihood of this particular ordered sequence is \(p(1-p)p(1-p)=p^2(1-p)^2\).

If the record retains only the count of 2 responses out of 4, then there are \({4\choose2}=6\) ordered sequences with that count. The probability of the recorded count is \(6p^2(1-p)^2\). The two likelihoods differ by the factor 6, independent of \(p\), and hence have the same score for \(p\). The count likelihood, rather than the likelihood of one particular ordering, is the appropriate probability model when the observed datum is the count.

When a Trial Count Is Not the Right Weight

A common mistake is to take a single binary observation and multiply its Bernoulli log-likelihood by the number of people in its group, without first replacing the binary response by the group’s success proportion. That calculation treats every member of the group as if their outcome were the one observed binary value. It is not the grouped binomial likelihood.

Worked Example: Weighting a Binary Outcome Incorrectly

Suppose a group has \(n=4\) trials and \(y=1\) success. The correct binomial score for the logit linear predictor is \(y-np=1-4p\). At \(p=0.5\), it is \(1-2=-1\).

If instead the analyst uses one Bernoulli response equal to 1 and assigns it weight 4, the weighted score is \(4(1-p)\). At \(p=0.5\), that score is \(4(0.5)=2\), not \(-1\). The error is also visible in the parameter-dependent log-likelihood: the incorrect expression is \(4\log p\), whereas the correct binomial expression is \(\log{4\choose1}+\log p+3\log(1-p)\).

The weighted Bernoulli representation matches the binomial contribution only if the response is \(r=y/n=1/4\) and its weight is 4. Then its contribution is \(4\{(1/4)\log p+(3/4)\log(1-p)\}=\log p+3\log(1-p)\), which differs from the binomial log-likelihood only by \(\log 4\).

A generic weight \(w_i\) and an observed binary response \(Y_i\in\{0,1\}\) contribute \(w_i\{Y_i\log p_i+(1-Y_i)\log(1-p_i)\}\). That is a different expression from a grouped binomial contribution unless the response and weight encode the matching proportion and trial count. In particular, assigning a group’s trial count to a single binary response does not reconstruct the group’s successes and failures.

The distinction is also reflected in variability: under the binomial sampling model, \(\operatorname{Var}(Y_i)=n_i p_i(1-p_i)\), so the proportion has variance \(\operatorname{Var}(Y_i/n_i)=p_i(1-p_i)/n_i\). A weighted fractional-response kernel does not, by itself, assert that a fractional observation arose from that binomial sampling process. Use the binomial model when the data are success counts out of known numbers of trials; use a weighted Bernoulli expression only when its response and weight have the intended meaning.

Key takeaway: A binomial trial count \(n_i\) matches a weighted Bernoulli kernel when the response is the observed proportion \(y_i/n_i\). Then the score equations agree and the log-likelihoods differ by a data-only combinatorial constant. A trial count is not a generic instruction to multiply the likelihood of a single binary response.

Check Your Understanding

Use the distinction between the sampling model and the parameter-dependent likelihood kernel.

  1. For \(n=8\) trials with \(y=2\) successes, what response and weight give a weighted Bernoulli kernel with the same parameter-dependent terms as the binomial likelihood?
  2. Why do the binomial and matched weighted-kernel score vectors agree even when the inverse link is not logistic?
  3. For \(n=5\) and \(y=1\), what is the difference between the binomial log-likelihood and the matched weighted-kernel log-likelihood?
  4. Explain why weighting one observed binary response by a group’s trial count generally does not represent the grouped binomial likelihood.
  5. In the Bernoulli aggregation argument, what does the factor \({n\choose y}\) count?
Clinical Biostats