Tutorials › Generalized Linear Mixed Models (GLMM) › The Binomial Distribution With Trial Counts

From GLM to GLMM · Tutorial 9 of 698

The Binomial Distribution With Trial Counts

Learn how a fixed number of independent Bernoulli trials produces a Binomial response and how its trial count enters the exponential-family representation and variance.

Beginner 9 min read

What You'll Learn

  • State the assumptions that make a response a Binomial success count.
  • Write its probability mass function in exponential-family form.
  • Identify the natural parameter, sufficient statistic, and trial-count-dependent log-partition function.
  • Derive the mean and variance from the log-partition function.
  • Distinguish the variance of a success count from the variance of a sample proportion.
  • Recognize when changing trial counts or dependence among trials makes a Binomial model inappropriate.

Why the Number of Trials Matters

A binary response records one success or failure. Many data sets instead record how many successes occurred among a known number of opportunities: for example, how many of 12 items passed inspection, or how many of 20 attempts produced a response. The response is then a count, and its distribution depends not only on the success probability but also on the number of trials.

The trial count affects the possible values, the expected count, and the variability. It also appears in the exponential-family representation. Keeping these roles distinct is important when trial counts differ across observational units: a count of 6 successes out of 10 trials is not the same response-scale quantity as a count of 6 out of 20.

Definition: A random variable \(Y\) has a Binomial distribution with fixed trial count \(m\) and success probability \(p\), written \(Y\sim\operatorname{Binomial}(m,p)\), if it counts successes in \(m\) independent trials, each of which has success probability \(p\). Here \(m\) is a known positive integer and \(0<p<1\). Its support is \(y=0,1,\ldots,m\), and its probability mass function is $$ P(Y=y)=\binom{m}{y}p^y(1-p)^{m-y}. $$

The standard model assumes a fixed number of trials, independence between trials, and a common success probability for all trials counted in the same response. In a regression setting, the probability can depend on predictors (and, where relevant, other conditioning variables); the Binomial statement is then conditional on those variables. The trials within a counted response must still satisfy the specified conditional independence and common-probability assumptions.

The Bernoulli distribution is the special case \(m=1\): the response can only be 0 or 1. For \(m>1\), the response \(Y\) is a number of successes, not a single binary outcome. The trial count \(m\) is part of the response structure and is not itself the number of observational units.

Exponential-Family Form

Use the exponential-family representation with dispersion equal to 1:

$$ f(y;\theta)=\exp\{y\theta-b_m(\theta)+c(y,m)\}. $$

For the Binomial model, define the natural parameter \(\theta=\log\{p/(1-p)\}\), so \(p=e^\theta/(1+e^\theta)\). Substitution into the Binomial probability gives

$$ \begin{aligned} P(Y=y) &=\binom{m}{y} \left(\frac{e^\theta}{1+e^\theta}\right)^y \left(\frac{1}{1+e^\theta}\right)^{m-y}\\ &=\exp\left\{y\theta-m\log(1+e^\theta)+\log\binom{m}{y}\right\}. \end{aligned} $$

Thus the sufficient statistic for \(\theta\) is \(Y\), the log-partition function is \(b_m(\theta)=m\log(1+e^\theta)\), and the term not involving \(\theta\) is \(c(y,m)=\log\binom{m}{y}\). The subscript on \(b_m\) emphasizes that the log-partition function depends on the known trial count. In the ordinary Binomial model, there is no additional dispersion parameter.

Key representation: For \(Y\sim\operatorname{Binomial}(m,p)\), the exponential-family components are \(T(Y)=Y\), \(\theta=\log\{p/(1-p)\}\), \(b_m(\theta)=m\log(1+e^\theta)\), and \(c(Y,m)=\log\binom{m}{Y}\). The trial count \(m\) changes the log-partition function and the support, even though the natural parameter is determined by \(p\).

Deriving the Mean and Variance

The log-partition function can be derived by requiring the probabilities over the support to sum to 1. Starting from the exponential-family form, the normalizing sum is

$$ \begin{aligned} \sum_{y=0}^{m}\binom{m}{y}\exp(y\theta) &=(1+\exp(\theta))^m,\\ b_m(\theta) &=\log\left\{\sum_{y=0}^{m}\binom{m}{y}\exp(y\theta)\right\} =m\log(1+\exp(\theta)). \end{aligned} $$

This uses the binomial theorem and identifies exactly how the fixed trial count enters normalization. Differentiating gives

$$ \begin{aligned} b_m'(\theta) &=\frac{m\exp(\theta)}{1+\exp(\theta)} =mp,\\ b_m''(\theta) &=\frac{m\exp(\theta)}{\{1+\exp(\theta)\}^2} =mp(1-p). \end{aligned} $$

For an exponential family with dispersion 1, the first derivative of the log-partition function is the mean of its sufficient statistic, and the second derivative is its variance. Since the sufficient statistic here is \(Y\), these derivatives give the mean and variance of the success count directly.

Result: If \(Y\sim\operatorname{Binomial}(m,p)\), then \(E(Y)=mp\) and \(\operatorname{Var}(Y)=mp(1-p)\). For the sample proportion \(\hat{p}=Y/m\), \(E(\hat{p})=p\) and \(\operatorname{Var}(\hat{p})=p(1-p)/m\). The count and the proportion are different response scales and have different variances.

Worked Examples

Worked Example: A Success Count and Its Probability

Suppose, hypothetically, that a laboratory procedure is repeated 8 times under the same conditions. Assume the trials are independent and each has success probability \(p=0.30\). Let \(Y\) be the number of successes. Find its mean, variance, and the probability of exactly 2 successes.

The fixed trial count is \(m=8\), and the stated assumptions make \(Y\sim\operatorname{Binomial}(8,0.30)\). The mean count is $$ E(Y)=mp=8(0.30)=2.4\text{ successes}. $$ The variance is $$ \operatorname{Var}(Y)=mp(1-p)=8(0.30)(0.70)=1.68\text{ successes}^2. $$ For exactly 2 successes, substitute \(y=2\), \(m=8\), and \(p=0.30\) into the probability mass function: $$ P(Y=2)=\binom{8}{2}(0.30)^2(0.70)^6 =28(0.09)(0.117649) \approx 0.2965. $$ Thus the model assigns about a 29.65% probability to exactly 2 successes. The expected count of 2.4 is an average over repetitions, not a claim that a single run can produce a fractional number of successes.

Worked Example: Counts and Proportions With Different Trial Counts

In a hypothetical process, each trial succeeds independently with probability \(p=0.60\). Compare a response based on \(m=10\) trials with one based on \(m=20\) trials. Calculate the expected count and variance for each, then calculate the variance of the corresponding sample proportion.

For 10 trials, the success count \(Y_{10}\) has $$ E(Y_{10})=10(0.60)=6,\qquad \operatorname{Var}(Y_{10})=10(0.60)(0.40)=2.4. $$ The sample proportion \(\hat{p}_{10}=Y_{10}/10\) has variance $$ \operatorname{Var}(\hat{p}_{10})=\frac{0.60(0.40)}{10}=0.024. $$ For 20 trials, the expected count and count variance are $$ E(Y_{20})=20(0.60)=12,\qquad \operatorname{Var}(Y_{20})=20(0.60)(0.40)=4.8. $$ But the proportion variance is $$ \operatorname{Var}(\hat{p}_{20})=\frac{0.60(0.40)}{20}=0.012. $$ The 20-trial count has twice the expected number of successes and twice the count variance. In contrast, its sample proportion has half the variance. The standard deviations of the proportions are \(\sqrt{0.024}\approx0.1549\) and \(\sqrt{0.012}\approx0.1095\), respectively. More trials do not make the count less variable; they make the proportion more precise under these assumptions.

Worked Example: Writing the Canonical Form

Suppose, hypothetically, that 9 of 12 independent trials succeed, and that the model specifies a common success probability \(p=0.65\). Express the probability of this observed count in canonical exponential-family form and evaluate it approximately.

The natural parameter and log-partition function are $$ \theta=\log\left(\frac{0.65}{0.35}\right)\approx0.6190,\qquad b_{12}(\theta)=12\log(1+\exp(\theta))\approx12.598. $$ The observed sufficient statistic is \(y=9\), and the base-measure term is \(\log\binom{12}{9}=\log(220)\approx5.394\). Therefore, $$ \begin{aligned} \log P(Y=9) &=9\theta-b_{12}(\theta)+\log\binom{12}{9}\\ &\approx9(0.6190)-12.598+5.394\\ &\approx-1.633. \end{aligned} $$ Exponentiating gives \(P(Y=9)\approx\exp(-1.633)=0.1954\). As a check using the original probability mass function, $$ \binom{12}{9}(0.65)^9(0.35)^3 =220(0.65)^9(0.35)^3 \approx0.1954. $$ The two calculations agree. The combinatorial term belongs to the base measure; the dependence on \(p\) is carried by \(\theta\) and \(b_{12}(\theta)\).

Choosing the Response Scale and Checking the Model

A Binomial count records \(Y\), while a proportion records \(Y/m\). When trial counts vary, those two choices have different implications. The count has a mean and variance proportional to \(m\); the proportion has mean \(p\) and variance \(p(1-p)/m\). A model must therefore use the actual number of trials for each response rather than treating counts with different denominators as interchangeable.

Before using the Binomial form, check that the denominator is fixed and known for the response, that each trial has the same modeled success probability, and that trials are conditionally independent. A recorded denominator that includes trials with unknown outcomes, or trials with different probabilities that are not represented in the model, can invalidate the assumed distribution. Dependence among trials can also produce variability that differs from \(mp(1-p)\). These are reasons to investigate the data-generating process and model fit, not to change the Binomial variance formula without justification.

The main alternatives depend on what was observed. A single yes/no outcome is represented by the Bernoulli distribution, the \(m=1\) case. A count with a known fixed number of opportunities and binary outcomes is naturally represented as a Binomial response. If the data are recorded only as a proportion, the denominator is still needed to know the model-based precision; a proportion alone does not reveal whether it came from 2 trials or 200.

The Binomial model has clear limitations: it does not accommodate a random trial count as if that count were fixed, and the ordinary form does not allow dependence or unexplained extra variability among the trials. A useful diagnostic is to compare observed counts or proportions with what the fitted Binomial model predicts, paying particular attention to whether residual variation is systematically greater than expected or whether results cluster by groups of trials. Such patterns suggest that at least one modeling assumption deserves review.

Common Mistake

A frequent error is to use \(p(1-p)\) as the variance of a Binomial count. That is the variance of a single Bernoulli outcome, not of the total over \(m\) trials. For the count, independence gives \(mp(1-p)\); dividing the count by \(m\) gives a proportion with variance \(p(1-p)/m\). The denominator must match the response being analyzed.

1
Identify what is counted.
Confirm that the response is a number of successes \(Y\) among \(m\) known trials.
2
Check the trial assumptions.
Assess whether the trials are independent and share a common success probability under the model.
3
Use the matching variance.
For a count use \(mp(1-p)\); for the proportion \(Y/m\) use \(p(1-p)/m\).
Key takeaway: A fixed-trial Binomial response is an exponential-family success count with natural parameter \(\log\{p/(1-p)\}\) and trial-count-dependent log-partition function \(m\log(1+e^\theta)\). The trial count determines both the support and the scale of the response variance.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A response counts successes in 6 independent trials, each with probability \(0.25\). What are its mean and variance?
  2. For a Binomial response with \(m=15\), write the natural parameter and log-partition function in terms of \(p\) and \(\theta\).
  3. If \(Y\sim\operatorname{Binomial}(20,0.40)\), what is the variance of \(Y/20\)?
  4. Why is a success count based on 5 trials not interchangeable with a count of the same value based on 10 trials?

Solutions. (1) \(E(Y)=6(0.25)=1.5\) successes, and \(\operatorname{Var}(Y)=6(0.25)(0.75)=1.125\) successes squared. (2) \(\theta=\log\{p/(1-p)\}\) and \(b_{15}(\theta)=15\log(1+e^\theta)\). (3) \(\operatorname{Var}(Y/20)=p(1-p)/20=(0.40)(0.60)/20=0.012\). (4) The counts have different denominators and different distributions: their supports are \(0,\ldots,5\) and \(0,\ldots,10\), and a given count represents a different proportion of successes in each case.

Clinical Biostats