From a Prior and Event Count to a Posterior
A trial’s binary endpoint can be summarized by the number of participants who experienced the event and the number who did not. To infer the event probability from those counts, Bayesian updating combines a probability model for the data with a prior distribution for that probability. For a binomial likelihood and a beta prior, the resulting posterior is also a beta distribution. The calculation is compact, but it rests on specific assumptions about the endpoint and how participants’ outcomes arise.
This tutorial derives that update and checks it with hypothetical trial data. The focus is the distributional update itself: the posterior shape parameters and the conditions that make the calculation appropriate.
Assumptions Behind the Update
The binomial model treats each participant’s endpoint as a binary outcome with the same event probability \(p\). Conditional on \(p\), participants’ outcomes are assumed independent. The count \(Y\) therefore records \(y\) events and \(n-y\) non-events, with a likelihood proportional to \(p^y(1-p)^{n-y}\). The prior is a proper beta distribution: its parameters satisfy \(a>0\) and \(b>0\), so its density is defined and integrates to one.
In a trial, these assumptions require an endpoint and observation window that are sufficiently well defined for participants to be classified as event or non-event. The simple model also presumes that the participants represented by \(p\) have a common event probability. Important departures include clustering, meaningful differences in risks across participants, and outcome status that is missing or not yet observed. In those settings, the observed count may not have the stated binomial likelihood.
The sample size \(n\) is the number of participants whose binary outcomes contribute to the count. In the standard application here, their endpoint statuses are observed. A missing status should not automatically be counted as a non-event: the model for missing or censored outcomes must be addressed before applying a count-based update.
Deriving the Posterior
Bayes’ rule says that the posterior density is proportional to the likelihood times the prior density. The binomial probability of observing \(Y=y\), conditional on \(p\), includes the combinatorial factor \(\binom{n}{y}\). That factor depends on the data but not on \(p\), so it cancels when the posterior density is normalized.
For \(y\) events among \(n\) participants, \(L(p\mid y)=\binom{n}{y}p^y(1-p)^{n-y}\). As a function of \(p\), its kernel is \(p^y(1-p)^{n-y}\).
The beta prior contributes the kernel \(p^{a-1}(1-p)^{b-1}\). Adding exponents gives the unnormalized posterior kernel.
The resulting kernel has the form of a beta density, so its normalizing constant is \(B(a+y,b+n-y)\).
To normalize, divide this kernel by its integral over \(0<p<1\). By the definition of the beta function, that integral is \(B(a+y,b+n-y)\). Thus the normalized posterior density is
which is the density of \(\operatorname{Beta}(a+y,b+n-y)\). This establishes the update: the event count \(y\) is added to the first shape parameter, and the non-event count \(n-y\) is added to the second. The same algebra applies when all observed outcomes are events or all are non-events, provided the prior has \(a>0\) and \(b>0\); the model assumptions still need to be assessed.
Worked Trial Updates
Worked Example: Updating a Beta Prior With Five Events
Hypothetical trial data. A trial follows 20 participants to a prespecified binary endpoint, and 5 experience the event. Suppose the event probability is modeled as common across participants, outcomes are conditionally independent given \(p\), and all 20 endpoint statuses are observed. Use a \(\operatorname{Beta}(2,8)\) prior.
The event count is \(y=5\), and the non-event count is \(n-y=20-5=15\). The prior shapes are \(a=2\) and \(b=8\), so the posterior parameters are
Therefore,
The updated distribution is a posterior for the event probability in this model. This calculation does not establish that the common-risk or independence assumptions are realistic; those are features of the sampling model that must be justified separately.
Worked Example: A Uniform Prior and Twelve Events
Hypothetical trial data. In a trial with 30 participants, 12 experience the binary event and 18 do not. Assume independent outcomes with a common event probability and complete endpoint ascertainment. Use a uniform prior on \(p\), which is \(\operatorname{Beta}(1,1)\).
The likelihood kernel is \(p^{12}(1-p)^{18}\). The prior density is constant on \(0<p<1\), so its kernel adds no powers of \(p\) or \(1-p\). The posterior parameters are
Hence,
A uniform prior is a particular modeling choice, not a statement that every possible scale or parameterization has a uniform prior. Its use should be stated explicitly rather than treated as an absence of assumptions.
Worked Example: Building a Prior From a Mean and Concentration
Hypothetical trial data. Suppose a clinical team specifies a prior mean event probability of \(0.20\) and chooses a prior concentration of \(\kappa=10\). For this example, define the concentration by \(a+b=\kappa\). The trial then observes 14 events and 26 non-events among 40 participants. Assume complete endpoint ascertainment, a common event probability, and conditional independence.
For a \(\operatorname{Beta}(a,b)\) distribution, the prior mean is \(a/(a+b)\). Setting \(a+b=10\) and \(a/(a+b)=0.20\) gives \(a=0.20(10)=2\), and then \(b=10-2=8\). The prior is \(\operatorname{Beta}(2,8)\).
There are \(40-14=26\) non-events. The posterior shapes are
Thus,
The mean and concentration specify this prior because the beta mean is \(a/(a+b)\) and the concentration is defined here as \(a+b\). They are prior inputs, not observations from the current trial.
How to Specify and Check the Update
A useful way to specify a beta prior is through a chosen prior mean \(m\), with \(0<m<1\), and a positive concentration \(\kappa\). Under the definition \(\kappa=a+b\), setting \(a=m\kappa\) and \(b=(1-m)\kappa\) gives a beta prior with mean \(m\). This is a parameterization of the prior; \(\kappa\) should be selected to represent the intended prior concentration, not chosen mechanically from the current data.
Although the update adds \(y\) and \(n-y\) to the shape parameters, \(a\) and \(b\) are not generally literal prior event and non-event counts. In particular, the beta density’s exponents are \(a-1\) and \(b-1\), not \(a\) and \(b\). Describing the shapes as if they were observed counts can therefore misstate the prior’s meaning, especially when the shapes are small.
Before applying the formula, verify that the event is defined consistently, \(y\) is an integer between 0 and \(n\), and the remaining \(n-y\) participants truly have observed non-event outcomes. Then consider whether a single \(p\) and independent outcomes are reasonable for the trial. These checks are not optional algebraic details: if the likelihood is not binomial, multiplying it by a beta prior does not justify this posterior.
Alternatives and Limitations
The beta-binomial update is attractive because it is transparent, uses only two shape parameters, and has a closed-form posterior. A frequentist analysis of the same binomial data instead uses a sampling-based estimation and uncertainty framework; it does not combine a prior density with the likelihood. A Bayesian analysis could also use a prior that is not beta, but the posterior may then lack a simple named form and require numerical methods. These approaches answer related questions under different assumptions; the beta-binomial formula is not a substitute for checking the trial’s design and endpoint data.
The conjugate model is limited when participant risks differ in ways the model needs to represent, outcomes are correlated within sites or families, or endpoint status is incomplete. A hierarchical model may represent structured variation across groups; a model for time to event may be needed when follow-up duration and event timing matter. Those alternatives require additional structure and cannot be obtained merely by changing \(a\) and \(b\). Likewise, a count of events alone cannot repair an endpoint definition or missing-data process that is incompatible with the binomial likelihood.
Common Mistakes
- Reversing the update. The event count is added to \(a\), and the non-event count is added to \(b\). The posterior is \(\operatorname{Beta}(a+y,b+n-y)\), not \(\operatorname{Beta}(a+n-y,b+y)\).
- Adding the sample size to both shapes. The total count is split: \(y+(n-y)=n\). Each shape receives only its corresponding outcome count.
- Treating a missing endpoint as a non-event. A non-event count requires an observed non-event status under the endpoint definition. Missing or censored statuses need an appropriate model.
- Assuming conjugacy validates the model. The posterior has a beta form because the specified likelihood and prior have matching kernels. That algebra does not demonstrate common risk, independence, or complete ascertainment.
Check Your Understanding
For each question, identify the relevant update or assumption before checking the solutions below.
- With prior \(\operatorname{Beta}(3,7)\), a hypothetical trial observes 4 events among 18 participants. What is the posterior distribution?
- A prior has mean \(0.30\) and concentration \(\kappa=20\), defined as \(a+b\). What are \(a\) and \(b\)? If a hypothetical trial then observes 9 events among 25 participants, what is the posterior?
- Why is the factor \(\binom{n}{y}\) absent from the unnormalized posterior kernel as a function of \(p\)?
- A trial count includes all enrolled participants, but several participants have unknown endpoint status. Why is it not valid to count every unknown status as a non-event and apply the standard update without further assumptions?
Solutions. (1) There are \(18-4=14\) non-events, so the posterior is \(\operatorname{Beta}(3+4,7+14)=\operatorname{Beta}(7,21)\). (2) \(a=0.30(20)=6\) and \(b=20-6=14\). The trial has \(25-9=16\) non-events, giving \(\operatorname{Beta}(6+9,14+16)=\operatorname{Beta}(15,30)\). (3) \(\binom{n}{y}\) depends on the observed counts but not on \(p\), so it is a constant with respect to \(p\) and is absorbed into the posterior’s normalizing constant. (4) Unknown status does not establish an observed non-event. The likelihood for the observed data, including the missingness or censoring process if relevant, must be specified before a posterior update is justified.