Signature
alpha = alpha_0 + r; beta = beta_0 + n - r; E_p = alpha / (alpha + beta)
| Inputs | Definition | Unit |
|---|---|---|
alpha_0 | First parameter of the beta prior: 0 for the limiting prior, 1 for a uniform prior | none, a prior count of events |
r | Number of patients who had the event during the observation period | patients |
beta_0 | Second parameter of the beta prior: 0 for the limiting prior, 1 for a uniform prior | none, a prior count of non-events |
n | Number of patients at risk at the start of the observation period, at least r | patients |
alpha | First shape parameter of the fitted or posterior beta distribution | none, a count of events plus any prior count |
|---|---|---|
beta | Second shape parameter of the fitted or posterior beta distribution | none, a count of non-events plus any prior count |
E_p | Mean of the fitted beta distribution, equal to r/n under the limiting prior | probability, above zero and below one |
Function
Beta distribution density, moments and fitting for an uncertain probability
Maps two positive shape parameters, alpha and beta, to a probability density on the unit interval that describes uncertainty about a probability, such as a transition probability in a decision tree or Markov model. The parameters are fitted from event counts, with alpha counting events and beta non-events, or from a reported mean and standard error by the method of moments, and the fitted distribution is sampled in probabilistic sensitivity analysis. The formulae below give the mean and variance, the two fitting routes, the gamma alternative for a utility decrement and the Dirichlet extension for states with three or more exits. Gamma(.) in the density is the gamma function.
Try this function
Implementations
Excel
Beta parameters from event counts and a prior in two cells
With named cells PriorAlpha, PriorBeta, Events and AtRisk, the two formulas return the shape parameters, which can then be passed to BETA.INV.
=PriorAlpha+Events; =PriorBeta+AtRisk-Events
Assumptions
Binomial evidence for a beta fit from counts
Each of the n patients has the same probability of the event over the observation period, outcomes are independent and every patient is followed for the whole period, so the count r is binomial.
Observation period of the counts matching the model cycle
The counts cover the model cycle length. When they cover a different period, the distribution is fitted on the observed period and each sampled value is converted to the cycle length through rate-to-probability conversion.
Prior for small or zero event counts stated
With large counts the choice of prior hardly matters. With small or zero counts it does, and the limiting prior fails when r is 0 or equal to n, because one parameter is then zero.
Worked examples
Beta(24, 96) from 24 progressions under the limiting prior
With no prior counts, 24 progressions among 120 patients give alpha of 24 and beta of 96, the article's step 1, with mean 0.20.
alpha_0 = 0; beta_0 = 0; r = 24; n = 120; alpha = 24; beta = 96; E_p = 0.20
Zero deaths among 120 patients with a uniform beta prior
A study with no deaths among 120 patients gives alpha of 0 under the limiting prior, which is not a valid beta distribution. A uniform prior gives Beta(1, 121), with a mean of about 0.008197, the article's 0.008.
alpha_0 = 1; beta_0 = 1; r = 0; n = 120; alpha = 1; beta = 121; E_p = 0.008197
Uniform beta prior added to 24 progressions among 120 patients
Adding a uniform prior to the progression counts gives Beta(25, 97), with a mean of about 0.204918 against 0.20, so the prior hardly matters with counts of this size.
alpha_0 = 1; beta_0 = 1; r = 24; n = 120; alpha = 25; beta = 97; E_p = 0.204918
Common errors
Entering the number at risk as the second beta parameter
Setting beta to n rather than n minus r counts every patient as a non-event. For 24 progressions among 120 patients, Beta(24, 120) has a mean of about 0.167 instead of 0.20, and the error grows with the event proportion.
Beta fitted to a zero event count without a prior
With no deaths among 120 patients the counts rule gives Beta(0, 120), which is not a valid distribution, and Excel BETA.INV returns the #NUM! error. A uniform prior gives Beta(1, 121) instead, with a mean of about 0.008.
Sources
Conjugate beta prior for binomial data in Bayesian Data Analysis
Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB. Bayesian Data Analysis. 3rd edition. Boca Raton: Chapman & Hall/CRC; 2013. Section 2.4, pp. 34-35, which shows that a Beta(alpha, beta) prior with y successes in n binomial trials gives the posterior Beta(alpha + y, beta + n minus y) and calls this conjugacy; and Appendix A, p. 584, which gives Beta(1, 1) as the uniform distribution and alpha = beta = 0 as a noninformative choice.
Excel BETA.INV error for a zero beta shape parameter
Microsoft. BETA.INV function. Microsoft Support; accessed 1 October 2026. The function returns the inverse of the cumulative beta distribution and the #NUM! error when alpha or beta is zero or below.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0