Tutorials › Generalized Linear Models › Beta-Binomial Predictions for Grouped Successes

Negative-Binomial and Beta-Binomial · Tutorial 733 of 981

Beta-Binomial Predictions for Grouped Successes

Learn to construct and interpret beta-binomial predictions for future group counts, including exact probabilities, variance decomposition, and discrete prediction intervals.

Advanced 12 min read

What You'll Learn

  • Derive the beta-binomial predictive probability mass function by mixing a binomial count over a beta-distributed group probability
  • Calculate predictive means and variances and separate their heterogeneity and sampling components
  • Construct discrete equal-tail prediction intervals using a precise quantile convention
  • Distinguish prediction for a new group from prediction of additional outcomes in an observed group
  • Recognize what is and is not included when model parameters are estimated and then plugged into predictions

Why Prediction Requires Two Sources of Variation

For a future group with a fixed number of trials, its success count is uncertain for two reasons. The group may have a success probability unlike the population average, and even after its probability is fixed, the outcomes of its trials vary. A beta-binomial prediction includes both sources: it first allows a group probability to vary across groups, then allows the count to vary given that probability.

This distinction matters in practice. A binomial prediction using the average success probability accounts for trial-to-trial sampling but treats every group as if it had exactly the same probability. When groups differ, that prediction generally understates how often unusually low or high counts will occur.

Definition: Let \(P\) be a group's success probability, with \(P\sim\operatorname{Beta}(\alpha,\beta)\), where \(\alpha>0\) and \(\beta>0\). Conditional on \(P=p\), let the group's number of successes among \(m\) trials satisfy \(Y\mid P=p\sim\operatorname{Binomial}(m,p)\), where \(m\) is a positive integer. The marginal distribution of \(Y\), after averaging over \(P\), is the beta-binomial distribution with parameters \(m,\alpha,\beta\).

Here the beta distribution describes variation in the underlying probability from group to group; the conditional binomial describes variation in outcomes within a group. Write \(s=\alpha+\beta\), \(\mu=\alpha/s\), and \(\rho=1/(s+1)\). Then \(\mu=E[P]\), while \(\rho\) is the correlation between two distinct Bernoulli outcomes in the same group under this mixture model. The parameter \(\rho\) is positive for finite positive \(\alpha,\beta\).

Predictive Probabilities

For an integer \(y\) between 0 and \(m\), the predictive probability averages the binomial probability at each possible group probability, weighted by the beta density. The beta function is \(B(a,b)=\int_0^1 p^{a-1}(1-p)^{b-1}\,dp\) for \(a,b>0\).

Theorem: Under the beta-binomial model,
$$ P(Y=y)=\binom{m}{y}\frac{B(\alpha+y,\beta+m-y)}{B(\alpha,\beta)},\qquad y=0,1,\ldots,m. $$

To derive this formula, multiply the conditional binomial probability by the beta density and integrate out \(P\):

$$ \begin{aligned} P(Y=y) &=\int_0^1 P(Y=y\mid P=p)f_P(p)\,dp\\ &=\int_0^1 \binom{m}{y}p^y(1-p)^{m-y} \frac{p^{\alpha-1}(1-p)^{\beta-1}}{B(\alpha,\beta)}\,dp\\ &=\binom{m}{y}\frac{1}{B(\alpha,\beta)} \int_0^1 p^{\alpha+y-1}(1-p)^{\beta+m-y-1}\,dp\\ &=\binom{m}{y}\frac{B(\alpha+y,\beta+m-y)}{B(\alpha,\beta)}. \end{aligned} $$

The integral is finite because both beta-function arguments are positive. The probabilities sum to one: summing the integral expression over \(y=0,\ldots,m\) brings a finite sum inside the integral, and the binomial theorem makes that sum \((p+(1-p))^m=1\). The remaining integral is the integral of the beta density, hence equals one.

Worked Example: Predicting a Group with Beta(2, 2) Probabilities

Suppose a future group has \(m=4\) trials and its probability has distribution \(P\sim\operatorname{Beta}(2,2)\). Find its predictive count probabilities and its 80th percentile.

Using the formula, or evaluating the beta integrals, the probabilities for \(y=0,1,2,3,4\) are respectively \(1/7,8/35,9/35,8/35,1/7\). For example, \(P(Y=0)=B(2,6)/B(2,2)=(1/42)/(1/6)=1/7\); and \(P(Y=1)=4B(3,5)/B(2,2)=4(1/105)/(1/6)=8/35\). The remaining values follow by the same substitution: \(P(Y=2)=6B(4,4)/B(2,2)=9/35\), \(P(Y=3)=4B(5,3)/B(2,2)=8/35\), and \(P(Y=4)=B(6,2)/B(2,2)=1/7\). They sum to \(5/35+8/35+9/35+8/35+5/35=1\).

The cumulative probabilities through \(y=0,1,2,3,4\) are \(1/7,13/35,22/35,30/35,1\). In particular, the cumulative probability through \(y=3\) is \(22/35+8/35=30/35\), not \(31/35\).

Define the \(u\)-quantile as \(q_u=\min\{y\in\{0,\ldots,m\}:P(Y\le y)\ge u\}\). Since \(P(Y\le2)=22/35<0.80\), while \(P(Y\le3)=30/35\ge0.80\), the 80th percentile is \(q_{0.80}=3\).

Mean and Variance: Separating the Sources

The predictive mean and variance follow from conditioning on the group's probability. The mean is the number of trials times the population-average probability. The variance is larger than the binomial variance at that mean whenever the group probability varies.

Theorem: For \(Y\) in the beta-binomial model, with \(s=\alpha+\beta\), \(\mu=\alpha/s\), and \(\rho=1/(s+1)\),
$$ E[Y]=m\mu,\qquad \operatorname{Var}(Y)=m\mu(1-\mu)\{1+(m-1)\rho\}. $$

Proof. Conditional on \(P\), the binomial mean and variance are \(E[Y\mid P]=mP\) and \(\operatorname{Var}(Y\mid P)=mP(1-P)\). By iterated expectation,

$$ E[Y]=E[E[Y\mid P]]=mE[P]=m\mu. $$

For the variance, the law of total variance gives

$$ \begin{aligned} \operatorname{Var}(Y) &=E[\operatorname{Var}(Y\mid P)]+\operatorname{Var}(E[Y\mid P])\\ &=mE[P(1-P)]+m^2\operatorname{Var}(P). \end{aligned} $$

The beta distribution has \(\operatorname{Var}(P)=\mu(1-\mu)/(s+1)=\mu(1-\mu)\rho\). Also \(E[P(1-P)]=E[P]-E[P^2]=\mu(1-\mu)-\operatorname{Var}(P)=\mu(1-\mu)(1-\rho)\). Substituting these identities yields

$$ \begin{aligned} \operatorname{Var}(Y) &=m\mu(1-\mu)(1-\rho)+m^2\mu(1-\mu)\rho\\ &=m\mu(1-\mu)\{1+(m-1)\rho\}. \end{aligned} $$

Thus the variance contribution from binomial sampling, averaged over groups, is \(m\mu(1-\mu)(1-\rho)\), and the contribution from variation in group probabilities is \(m^2\operatorname{Var}(P)=m^2\mu(1-\mu)\rho\). Their sum is the predictive variance. \(\square\)

Worked Example: Quantifying Extra Variation

Let \(P\sim\operatorname{Beta}(2,2)\), and predict the success count for a group with \(m=4\) trials. Here \(s=4\), \(\mu=1/2\), and \(\rho=1/5\). Therefore \(E[Y]=4(1/2)=2\), and

$$ \operatorname{Var}(Y)=4\left(\frac12\right)\left(\frac12\right) \left\{1+3\left(\frac15\right)\right\} =1\left(\frac85\right)=\frac85=1.6. $$

A binomial model with probability fixed at the same average, \(1/2\), would have variance \(4(1/2)(1/2)=1\). The extra \(0.6\) is the variation in group probabilities: \(m^2\operatorname{Var}(P)=16(1/20)=0.8\). The averaged within-group sampling component is \(mE[P(1-P)]=4(1/5)=0.8\), so the total is \(0.8+0.8=1.6\). The comparison is not “binomial sampling versus no sampling”; both predictions include sampling variation, but only the beta-binomial includes between-group heterogeneity.

Discrete Predictive Intervals

A predictive interval is a range intended to contain the future count with a stated probability under the model. Counts are discrete, so an interval's actual probability will often exceed its nominal level. A precise convention avoids ambiguity: use the smallest integer \(q_u\) whose cumulative probability is at least \(u\). An equal-tail interval at nominal level \(1-2a\) is \([q_a,q_{1-a}]\), for \(0<a<1/2\).

This interval has probability at least \(1-2a\). Indeed, \(P(Y\le q_{1-a})\ge1-a\), while \(P(Y<q_a)<a\), by the definition of the quantiles. Subtracting gives \(P(q_a\le Y\le q_{1-a})\ge(1-a)-a=1-2a\). The result is a model-based predictive statement for the specified group size and beta-binomial parameters, not a guarantee about every realized sequence of groups.

Worked Example: An Exact 80% Predictive Interval

Take \(m=5\), \(\alpha=2\), and \(\beta=3\). The beta-binomial probabilities for \(y=0,1,2,3,4,5\) are \(1/6,5/21,5/21,4/21,5/42,1/21\). They sum to \(1\), since in forty-seconds they are \(7/42+10/42+10/42+8/42+5/42+2/42=42/42\).

The cumulative probabilities are \(1/6,17/42,27/42,35/42,40/42,1\). For an equal-tail 80% interval, set \(a=0.10\). Because \(F(0)=1/6\ge0.10\), \(q_{0.10}=0\). Since \(F(3)=35/42=5/6<0.90\) and \(F(4)=40/42=20/21\ge0.90\), \(q_{0.90}=4\). The resulting interval is \([0,4]\), with actual predictive probability \(P(0\le Y\le4)=20/21\), approximately \(0.952\). Its coverage exceeds \(0.80\) because the count distribution is discrete.

Prediction After Observing Outcomes in the Same Group

Prediction for a new group and prediction of additional outcomes in an already observed group are related but distinct. For a new group, use the population distribution of its probability. If \(x\) successes and \(n-x\) failures have already been observed in the same group, then under the beta-binomial model its probability has the conditional distribution \(\operatorname{Beta}(\alpha+x,\beta+n-x)\). Predicting additional trials for that group uses this updated distribution, not the original one.

Worked Example: Additional Trials in an Observed Group

Suppose the initial group-probability model is \(P\sim\operatorname{Beta}(1,1)\), and the group has produced 2 successes in 3 trials. Its conditional probability distribution is \(\operatorname{Beta}(1+2,1+1)=\operatorname{Beta}(3,2)\). Let \(Z\) be the successes in 2 additional trials. The beta-binomial formula gives \(P(Z=0)=1/5\), \(P(Z=1)=2/5\), and \(P(Z=2)=2/5\). For example, \(P(Z=0)=B(3,4)/B(3,2)=(1/60)/(1/12)=1/5\), and \(P(Z=1)=2B(4,3)/B(3,2)=2(1/60)/(1/12)=2/5\). The last probability is \(B(5,2)/B(3,2)=(1/30)/(1/12)=2/5\). These probabilities sum to one.

The predictive mean is \(2(3/5)=1.2\). Here \(s=5\), \(\rho=1/6\), and the predictive variance is \(2(3/5)(2/5)\{1+1/6\}= (12/25)(7/6)=14/25=0.56\). If the probability were fixed at its conditional mean \(3/5\), the binomial variance would instead be \(2(3/5)(2/5)=12/25=0.48\). The difference, \(0.08\), reflects residual uncertainty about this group's probability after its first three outcomes.

What a Plug-In Prediction Includes

In applications, \(\alpha\) and \(\beta\), or equivalently mean and dispersion parameters, are usually estimated from groups. Substituting estimates into the beta-binomial formula gives a plug-in predictive distribution. It includes variation in a future group's probability as represented by the fitted beta distribution and binomial sampling variation conditional on that probability.

A plug-in calculation does not, by itself, integrate over uncertainty in the estimated model parameters. Its probabilities and intervals are conditional on the fitted parameter values. A prediction that also propagates uncertainty in those parameters requires an additional probability model or inferential procedure for them. This distinction is separate from the within-model heterogeneity captured by \(\rho\).

Common Mistakes

  • Using only a binomial variance. A binomial distribution at \(p=\mu\) omits variation in group probabilities. For finite positive beta parameters and \(m>1\), the beta-binomial variance exceeds \(m\mu(1-\mu)\).
  • Confusing the two uncertainties. The beta distribution represents differences in probabilities across groups; the conditional binomial represents sampling variation among trials within a group. Both contribute to a future count.
  • Reading a discrete quantile as an exact tail probability. The cumulative probability at the selected integer can be greater than the target \(u\). Check the cumulative sum at the quantile and at the preceding integer.
  • Updating the wrong group probability. Observations from a group update predictions for further trials in that same group. They do not turn the probability of a distinct future group into that group's posterior probability.
  • Calling a plug-in interval fully parameter-uncertainty-adjusted. Plugging in fitted values accounts for beta-binomial variability at those values, not for uncertainty in the values themselves.
Key takeaway: A beta-binomial prediction is a mixture: a future group's success probability varies across groups, and its count varies conditionally given that probability. Integrating both stages yields predictive probabilities and intervals that reflect both sources of variation.

Check Your Understanding

Use the beta-binomial model and the quantile convention defined above.

  1. For a future group with \(m\) trials, explain in words what each stage of the hierarchy \(P\sim\operatorname{Beta}(\alpha,\beta)\), \(Y\mid P\sim\operatorname{Binomial}(m,P)\) represents.
  2. For \(m=6\), \(\mu=0.4\), and \(\rho=0.2\), calculate the predictive mean and variance.
  3. Why does a binomial model with probability \(\mu\) generally give a narrower predictive distribution than a beta-binomial model with the same mean?
  4. In a discrete equal-tail 90% interval, why can the actual predictive probability be greater than 90%?
  5. A group has prior probability distribution \(\operatorname{Beta}(2,3)\) and records 4 successes and 2 failures. What is the conditional beta distribution for predicting additional trials in that group?
Clinical Biostats