Tutorials › Generalized Linear Models › Grouped Binomial Score Equations

Likelihood Scores and Equations · Tutorial 167 of 981

Grouped Binomial Score Equations

Learn how varying group sizes enter grouped-binomial logit score equations and likelihood curvature.

Intermediate 9 min read

What You'll Learn

  • Write the grouped-binomial likelihood and log-likelihood for independent groups with fixed trial counts.
  • Derive the logit regression score and express it using group proportions and trial-count weights.
  • Derive the observed Hessian and identify conditions for negative definiteness.
  • Check grouped-data calculations through examples with unequal trial counts.
  • Distinguish grouped-binomial score equations from unweighted residual equations.

Introduction

A grouped binomial response records a number of successes out of a known number of trials for each covariate pattern. For example, a clinic might report that 8 of 12 patients responded to a treatment at one dose and 3 of 5 responded at another. These are not two equally precise measurements of a response proportion: the groups have different numbers of trials. The likelihood, score, and curvature must retain that difference.

This tutorial derives the regression score and observed Hessian for independent grouped binomial counts under a logit link. The central feature is simple but consequential: a group contributes its success count minus its expected success count, \(y_i-m_i p_i\), to the score. Equivalently, its residual in proportion units is weighted by its trial count \(m_i\).

Grouped Binomial Logit Model

Definition: For groups \(i=1,\ldots,n\), suppose the responses \(Y_i\) are independent and \(Y_i\sim\operatorname{Binomial}(m_i,p_i)\), where \(m_i\) is a fixed positive integer, and \(Y_i\) counts successes among the \(m_i\) trials in group \(i\). Let \(x_i\in\mathbb{R}^p\) be the fixed covariate vector, including an intercept if desired. Under the logit regression model, \(\operatorname{logit}(p_i)=\log\{p_i/(1-p_i)\}=x_i^\mathsf{T}\beta\), so \(p_i=\exp(x_i^\mathsf{T}\beta)/\{1+\exp(x_i^\mathsf{T}\beta)\}\), for a coefficient vector \(\beta\in\mathbb{R}^p\).

The count \(Y_i\) takes values \(0,1,\ldots,m_i\). Conditional on the fixed design and trial counts, the probability of observing \(Y_i=y_i\) is

$$ P(Y_i=y_i)=\binom{m_i}{y_i}p_i^{y_i}(1-p_i)^{m_i-y_i}. $$

Independence makes the likelihood the product of these probabilities. Writing \(\eta_i=x_i^\mathsf{T}\beta\), the logit model gives \(\log(p_i)=\eta_i-\log(1+\exp(\eta_i))\) and \(\log(1-p_i)=-\log(1+\exp(\eta_i))\). Therefore the log-likelihood is

$$ \ell(\beta)=\sum_{i=1}^n\left[ \log\binom{m_i}{y_i}+y_i\eta_i-m_i\log\{1+\exp(\eta_i)\} \right]. $$

The binomial coefficient is part of the grouped-data likelihood, but it does not depend on \(\beta\). It contributes no terms to either the score or the Hessian.

Deriving the Score Equation

For each group, \(\partial\eta_i/\partial\beta=x_i\), while differentiating the log-likelihood contribution with respect to \(\eta_i\) gives \(y_i-m_i p_i\). The chain rule then gives the vector score.

Result: The grouped-binomial logit score is
$$ U(\beta)=\frac{\partial\ell(\beta)}{\partial\beta} =\sum_{i=1}^n x_i(y_i-m_i p_i). $$

A finite maximum-likelihood estimate \(\hat\beta\), if it exists in the parameter space, satisfies the score equations \(U(\hat\beta)=0\). In proportion units, when \(r_i=y_i/m_i\) is the observed group proportion, the same score is

$$ U(\beta)=\sum_{i=1}^n m_i x_i(r_i-p_i). $$

Thus a group with a larger trial count contributes more for the same discrepancy between its observed and fitted proportions. This weighting is not an additional modeling choice: it follows from the binomial likelihood.

Worked Example: Computing a Score and Hessian

Consider two groups with \((m_1,y_1)=(4,3)\) and \((m_2,y_2)=(6,2)\), and design vectors \(x_1=(1,0)^\mathsf{T}\) and \(x_2=(1,1)^\mathsf{T}\). Evaluate the score and Hessian at \(\beta=(0,-\log 2)^\mathsf{T}\).

For group 1, \(\eta_1=0\), so \(p_1=1/2\). Its success residual is \(y_1-m_1p_1=3-4(1/2)=1\). For group 2, \(\eta_2=-\log 2\), so \(p_2=1/3\), and its residual is \(2-6(1/3)=0\). Consequently,

$$ U(\beta)=x_1(1)+x_2(0) =\begin{pmatrix}1\\0\end{pmatrix}. $$

The Hessian contribution from group 1 has weight \(m_1p_1(1-p_1)=4(1/2)(1/2)=1\). The contribution from group 2 has weight \(m_2p_2(1-p_2)=6(1/3)(2/3)=4/3\). Hence

$$ H(\beta)=-\left[ 1\begin{pmatrix}1&0\\0&0\end{pmatrix} +\frac43\begin{pmatrix}1&1\\1&1\end{pmatrix} \right] =-\begin{pmatrix}7/3&4/3\\4/3&4/3\end{pmatrix}. $$

The score is not zero at this coefficient value, and the two groups affect the curvature according to both their trial counts and their fitted probabilities.

Observed Hessian and Likelihood Curvature

Differentiate the score once more. Since \(p_i=\exp(\eta_i)/\{1+\exp(\eta_i)\}\), its derivative with respect to \(\eta_i\) is \(p_i(1-p_i)\). Therefore the derivative of \(y_i-m_i p_i\) with respect to \(\beta\) is \(-m_i p_i(1-p_i)x_i\). The resulting observed Hessian is

Result: For the grouped-binomial logit model,
$$ H(\beta)=\frac{\partial^2\ell(\beta)}{\partial\beta\,\partial\beta^\mathsf{T}} =-\sum_{i=1}^n m_i p_i(1-p_i)x_i x_i^\mathsf{T}. $$

In this model the Hessian does not depend on the observed counts \(y_i\); for a fixed \(\beta\) it is also the expected Hessian. The negative sign describes downward likelihood curvature. More precisely, for any vector \(a\in\mathbb{R}^p\),

$$ a^\mathsf{T}H(\beta)a =-\sum_{i=1}^n m_i p_i(1-p_i)(x_i^\mathsf{T}a)^2\leq 0. $$

Thus the Hessian is negative semidefinite at every finite \(\beta\). Because \(m_i>0\) and finite logit probabilities satisfy \(0<p_i<1\), it is negative definite exactly when the design vectors span \(\mathbb{R}^p\). If they do not, some nonzero direction \(a\) has \(x_i^\mathsf{T}a=0\) for every group, and the quadratic form in that direction is zero. If they do span \(\mathbb{R}^p\), every nonzero \(a\) has at least one nonzero \(x_i^\mathsf{T}a\), making the sum strictly negative. This is a statement about curvature; it does not by itself guarantee that a finite maximum-likelihood estimate exists.

Worked Example: An Intercept-Only Fit

Suppose three independent groups have trial-success pairs \((5,4)\), \((10,3)\), and \((5,2)\). Fit a model with an intercept only, so every group has the same success probability \(p\) and \(\eta=\beta\).

The score equation is the sum of the group success residuals:

$$ U(\beta)=(4-5p)+(3-10p)+(2-5p)=9-20p. $$

Setting the score to zero gives \(p=9/20=0.45\). The corresponding logit estimate is \(\hat\beta=\log\{0.45/(1-0.45)\}=\log(9/11)\). The fitted success counts are \(5(0.45)=2.25\), \(10(0.45)=4.5\), and \(5(0.45)=2.25\). Their sum is 9, equal to the observed total number of successes, as the intercept score equation requires.

At this fit, the Hessian is

$$ H(\hat\beta)=-\{5+10+5\}(0.45)(0.55)=-4.95. $$

All groups contribute to the curvature, and their trial counts sum to 20.

Why Aggregation and Trial Counts Matter

A group count can also be understood as a compressed record of \(m_i\) Bernoulli outcomes that share the same success probability. If those outcomes were observed separately, their likelihood contribution would be \(p_i^{y_i}(1-p_i)^{m_i-y_i}\). The grouped count likelihood multiplies this by \(\binom{m_i}{y_i}\), the number of distinct binary sequences producing that count. This factor is independent of \(\beta\), so expanding or grouping the observations gives the same score and Hessian when all trials in a group have the same covariates and probability.

This equivalence concerns the likelihood for \(\beta\); it does not mean that one may discard the trial counts. They determine how many Bernoulli outcomes each group represents and therefore appear in both the expected counts \(m_i p_i\) and the curvature weights \(m_i p_i(1-p_i)\).

Worked Example: Why Unweighted Proportion Residuals Fail

Consider an intercept-only model with two groups: \(m_1=2,y_1=2\) and \(m_2=8,y_2=0\). Evaluate the score at \(p=1/2\). The observed proportions are 1 and 0, so their unweighted residuals are \(1-1/2=1/2\) and \(0-1/2=-1/2\). These happen to sum to zero.

But the grouped-binomial score is not the unweighted sum of proportion residuals. Its correct value is

$$ U(\beta)=(2-2(1/2))+(0-8(1/2))=1-4=-3. $$

Equivalently, weighting the proportion residuals by their trial counts gives \(2(1/2)+8(-1/2)=1-4=-3\). Therefore \(p=1/2\) does not solve the score equation. In fact, the intercept-only maximum-likelihood estimate is the pooled proportion \((2+0)/(2+8)=0.2\), not the unweighted average of the two observed proportions.

Common Pitfall

A common error is to replace the count residual \(y_i-m_i p_i\) with the proportion residual \(y_i/m_i-p_i\) and then sum those residuals without weights. The two forms are equivalent only when the proportion residual for each group is multiplied by \(m_i\). Omitting this factor treats a group based on two trials as equally informative as one based on twenty trials.

Key takeaway: For grouped binomial logit regression, the score is \(\sum_i x_i(y_i-m_i p_i)\), and the Hessian is \(-\sum_i m_i p_i(1-p_i)x_i x_i^\mathsf{T}\). The trial count enters both expressions; in proportion-residual form it is the explicit group weight.

Check Your Understanding

Use the grouped-binomial logit model and show the role of the trial count in each answer.

  1. Write the likelihood contribution of a group with \(m_i\) trials and \(y_i\) successes, including its binomial coefficient.
  2. Express the score using the observed proportion \(r_i=y_i/m_i\). What factor must multiply \(r_i-p_i\)?
  3. For an intercept-only model, explain why the score equation equates total observed successes with total fitted successes.
  4. State the grouped-binomial logit Hessian and explain why its quadratic form is never positive.
  5. Why does an unweighted sum of group proportion residuals generally fail to give the grouped-binomial score equation?
Clinical Biostats