Tutorials › Generalized Linear Models › Likelihood for Unequal Grouped Binomial Counts

Grouped Binomial Regression · Tutorial 388 of 981

Likelihood for Unequal Grouped Binomial Counts

Learn to write and interpret the full likelihood for independent binomial groups with unequal denominators, including models that assign probabilities through a parameter.

Intermediate 10 min read

What You'll Learn

  • Specify the observed success and trial counts for each independent group
  • Write the joint likelihood as a product of group-specific binomial probabilities
  • Expand the log-likelihood while retaining the binomial coefficients
  • Distinguish a full likelihood from its parameter-dependent kernel
  • Work likelihood calculations with unequal trial totals
  • Differentiate the log-likelihood when group probabilities depend on a parameter

Why Unequal Group Sizes Matter

Grouped binomial data record, for each group, a number of successes out of a possibly different number of trials. The denominator is part of the probability model: a count of 3 successes out of 5 trials is not interchangeable with 3 successes out of 30 trials. To construct a likelihood correctly, keep each group’s success count, failure count, trial total, and success probability together.

This tutorial develops the likelihood for independent groups. It covers both the case where each group has its own probability and the case where probabilities are specified through a shared parameter. The central calculation is direct, but it is easy to lose information by dropping denominators or treating observed proportions as if they were the data.

Definition: For groups \(i=1,\ldots,G\), let \(Y_i\) be the number of successes among \(m_i\) trials in group \(i\). Suppose the group counts are independent and \(Y_i\sim\operatorname{Binomial}(m_i,p_i)\), where \(m_i\) is a known positive integer and \(p_i\) is the success probability for that group. The observed count is \(y_i\), with \(y_i\in\{0,1,\ldots,m_i\}\). The likelihood is the joint probability of the observed counts, viewed as a function of the probability parameters: $$ L(p_1,\ldots,p_G) = \prod_{i=1}^{G} {m_i\choose y_i}p_i^{y_i}(1-p_i)^{m_i-y_i}. $$

The number of failures in group \(i\) is \(m_i-y_i\), not a separate free observation. The binomial model assigns probability to the success count \(y_i\); its probability mass includes the number \({m_i\choose y_i}\) of possible trial-level arrangements that produce that count.

Deriving the Joint Likelihood

For one group, the binomial probability mass function gives \(P(Y_i=y_i)={m_i\choose y_i}p_i^{y_i}(1-p_i)^{m_i-y_i}\). Independence means the probability of observing all group counts is the product of these group probabilities. Thus the joint probability, expressed as a function of the unknown probabilities, is the likelihood.

Theorem: If \(Y_1,\ldots,Y_G\) are independent and \(Y_i\sim\operatorname{Binomial}(m_i,p_i)\), then the likelihood of the observed vector \((y_1,\ldots,y_G)\) is the product of the group-specific binomial probability masses. If all \(p_i\) lie strictly between 0 and 1, its log-likelihood is $$ \ell(p_1,\ldots,p_G) = \sum_{i=1}^{G} \left[ \log {m_i\choose y_i} +y_i\log p_i +(m_i-y_i)\log(1-p_i) \right]. $$

Proof. By independence and the binomial probability mass function, $$ P(Y_1=y_1,\ldots,Y_G=y_G) = \prod_{i=1}^{G}P(Y_i=y_i) = \prod_{i=1}^{G}{m_i\choose y_i}p_i^{y_i}(1-p_i)^{m_i-y_i}. $$ This joint probability, considered as a function of the \(p_i\) with the observed counts and trial totals fixed, is the likelihood. For \(0<p_i<1\), every factor is positive, so its logarithm is defined. Applying the logarithm to the product gives the sum of the logarithms, and applying it to each group’s factors gives the displayed expression. \(\square\)

The binomial coefficients do not depend on the probabilities when the \(m_i\) and \(y_i\) are fixed. Therefore, when working with a likelihood as a function of the \(p_i\), one can also use the parameter-dependent kernel $$ L(p_1,\ldots,p_G) \propto \prod_{i=1}^{G}p_i^{y_i}(1-p_i)^{m_i-y_i}. $$ The symbol \(\propto\) means equality up to a positive factor that does not depend on the probability parameters. The full likelihood includes the binomial coefficients; the kernel omits them only to simplify expressions involving the parameters. Keeping the full form is useful for reporting the actual probability of the observed grouped counts.

Worked Likelihood Calculations

Worked Example: Three Groups With Different Probabilities

Suppose there are three independent groups with trial totals \(m_1=5\), \(m_2=4\), and \(m_3=3\). The observed success counts are \(y_1=3\), \(y_2=2\), and \(y_3=1\). Evaluate the likelihood at the specified probabilities \(p_1=0.4\), \(p_2=0.6\), and \(p_3=0.3\).

For group 1, there are \(5-3=2\) failures, so its contribution is \({5\choose3}(0.4)^3(0.6)^2=10(0.064)(0.36)=0.2304\).

For group 2, there are \(4-2=2\) failures. Its contribution is \({4\choose2}(0.6)^2(0.4)^2=6(0.36)(0.16)=0.3456\).

For group 3, there are \(3-1=2\) failures. Its contribution is \({3\choose1}(0.3)^1(0.7)^2=3(0.3)(0.49)=0.441\). Multiplying the independent contributions gives $$ L=(0.2304)(0.3456)(0.441)=0.07962624(0.441)=0.03511517184. $$ Thus the likelihood at these probabilities is approximately \(0.035115\). The corresponding log-likelihood is \(\ell=\log(0.2304)+\log(0.3456)+\log(0.441)\), approximately \(-3.349\).

Each group uses its own total and probability. Replacing the three terms with a single binomial term would describe a different probability model unless additional assumptions justified that change.

Worked Example: One Probability Shared Across Unequal Groups

Now suppose two independent groups have the same success probability \(p\), but different trial totals. Let \((m_1,y_1)=(3,2)\) and \((m_2,y_2)=(5,1)\). Write the likelihood as a function of \(p\), and evaluate it at \(p=0.4\).

The first group has one failure, and the second has four. Therefore, $$ L(p) = {3\choose2}p^2(1-p)^1 {5\choose1}p^1(1-p)^4 = 15p^3(1-p)^5. $$ The powers add because the probability is shared: there are \(2+1=3\) observed successes and \(1+4=5\) observed failures. The coefficient is \(3\times5=15\), not 30—so writing the product carefully gives $$ L(p)=15p^3(1-p)^5. $$ At \(p=0.4\), \(L(0.4)=15(0.4)^3(0.6)^5 =15(0.064)(0.07776)=0.0746496\).

The log-likelihood is \(\ell(p)=\log(15)+3\log p+5\log(1-p)\). At \(p=0.4\), this is approximately \(-2.595\), consistent with \(\log(0.0746496)\). The unequal denominators remain visible in the group-level expression; only after specifying a common \(p\) can the probability powers be combined.

Worked Example: Probabilities Specified by a Parameter

Consider two independent groups with \((m_1,y_1)=(4,1)\) and \((m_2,y_2)=(5,3)\). Suppose their probabilities depend on a scalar parameter \(\theta\) through \(p_1(\theta)=\theta\) and \(p_2(\theta)=(1+\theta)/2\), for \(0<\theta<1\). Write the likelihood and evaluate it at \(\theta=0.4\).

The first group contributes \({4\choose1}\theta(1-\theta)^3=4\theta(1-\theta)^3\). The second group contributes \({5\choose3}[(1+\theta)/2]^3[(1-\theta)/2]^2\). Thus $$ L(\theta) = 4\theta(1-\theta)^3 \cdot 10\left(\frac{1+\theta}{2}\right)^3 \left(\frac{1-\theta}{2}\right)^2. $$

At \(\theta=0.4\), the probabilities are \(p_1=0.4\) and \(p_2=0.7\). The first group’s contribution is \(4(0.4)(0.6)^3=0.3456\). The second group’s contribution is \(10(0.7)^3(0.3)^2=10(0.343)(0.09)=0.3087\). Hence $$ L(0.4)=(0.3456)(0.3087)=0.10668672. $$ This calculation illustrates the general substitution rule: first write each group’s binomial contribution using its own probability, then substitute the parameter-dependent probability for that group.

Log-Likelihood With Parameter-Dependent Probabilities

In an application, the group probabilities may be specified as functions of one or more unknown parameters. Write \(p_i(\theta)\) for the probability in group \(i\), where \(\theta\) denotes the parameter or parameter vector. Substitution into the grouped likelihood gives $$ L(\theta) = \prod_{i=1}^{G}{m_i\choose y_i} [p_i(\theta)]^{y_i} [1-p_i(\theta)]^{m_i-y_i}. $$ When all \(p_i(\theta)\) are strictly between 0 and 1, its log-likelihood is $$ \ell(\theta) = \sum_{i=1}^{G} \left[ \log {m_i\choose y_i} +y_i\log p_i(\theta) +(m_i-y_i)\log\{1-p_i(\theta)\} \right]. $$

This expression retains the group index throughout. It does not require the totals \(m_i\) to be equal, and it does not require the probabilities \(p_i(\theta)\) to be different. Whether the probabilities are shared or linked through a model is determined by the assumptions placed on them, not by the likelihood formula itself.

Result: If each \(p_i(\theta)\) is differentiable and \(0<p_i(\theta)<1\), then for a scalar \(\theta\), $$ \frac{d\ell(\theta)}{d\theta} = \sum_{i=1}^{G} \frac{y_i-m_i p_i(\theta)} {p_i(\theta)\{1-p_i(\theta)\}} \frac{dp_i(\theta)}{d\theta}. $$

Derivation. For one group, differentiate its log-likelihood contribution with respect to \(\theta\). The binomial coefficient is constant, so its derivative is zero. The chain rule gives $$ \frac{d}{d\theta} \left[ y_i\log p_i(\theta) +(m_i-y_i)\log\{1-p_i(\theta)\} \right] = \left[ \frac{y_i}{p_i(\theta)} -\frac{m_i-y_i}{1-p_i(\theta)} \right]\frac{dp_i(\theta)}{d\theta}. $$ Putting the bracket over the common denominator \(p_i(\theta)\{1-p_i(\theta)\}\) gives numerator \(y_i\{1-p_i(\theta)\}-(m_i-y_i)p_i(\theta)=y_i-m_i p_i(\theta)\). Summing these derivatives over the groups yields the result. \(\square\)

Common Pitfalls and Practical Checks

A grouped binomial likelihood is a joint probability for the recorded counts under the stated model. The different pieces of its formula serve different roles: \(y_i\) counts successes, \(m_i-y_i\) counts failures, \(m_i\) fixes the number of trials, and \(p_i\) determines the success chance within that group.

  • Dropping a denominator. A proportion \(y_i/m_i\) alone does not specify the group’s binomial contribution. Include both the success and failure exponents, \(y_i\) and \(m_i-y_i\).
  • Using a shared probability without an assumption. The expression with one \(p\) across groups is appropriate only when the model assigns the same success probability to every group.
  • Forgetting the binomial coefficient in the full likelihood. The coefficient is part of the binomial probability mass. It can be omitted from a parameter-dependent kernel when it is constant in the parameters, but the resulting expression is not the full probability of the observations.
  • Adding probabilities rather than multiplying group contributions. Under independence, the joint likelihood is the product of the group-specific probabilities. Its logarithm is the sum of their log contributions.

A useful check is to verify that each observed count satisfies \(0\leq y_i\leq m_i\), that the number of failures is calculated as \(m_i-y_i\), and that every group’s probability is paired with its own count and total. If probabilities depend on a parameter, substitute the group-specific function only after writing the group contribution clearly.

Check Your Understanding

Use the independent grouped-binomial likelihood to answer the following questions.

  1. For two independent groups with totals \(m_1=6\), \(m_2=3\) and success counts \(y_1=2\), \(y_2=1\), write the likelihood when the probabilities are \(p_1\) and \(p_2\).
  2. In a group with \(m_i=8\) and \(y_i=5\), what exponent belongs on \(1-p_i\), and what does it count?
  3. Suppose the two groups in Question 1 share a common probability \(p\). Write the full likelihood and its parameter-dependent kernel.
  4. Why is the binomial coefficient part of the full likelihood even though it can be omitted from the parameter-dependent kernel?
  5. State the independence assumption used to write the joint likelihood as a product of group contributions.
Clinical Biostats