Signature
alpha = mu * (mu * (1 - mu) / s^2 - 1); beta = (1 - mu) * (mu * (1 - mu) / s^2 - 1)
| Inputs | Definition | Unit |
|---|---|---|
mu | Reported mean of the probability, above zero and below one | probability |
s | Standard error of mu, not the standard deviation across patients | probability |
alpha | First shape parameter of the fitted beta distribution | none |
|---|---|---|
beta | Second shape parameter of the fitted beta distribution | none |
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.
Computational function
Computational function: reported mean and standard error to a fitted beta with its interval and a PSA draw
Takes the inputs a model usually holds for a bounded parameter, a reported mean, its standard error and a uniform random number, and returns the fitted beta parameters, the central 95% interval and a sampled value. It checks the existence condition, applies the method-of-moments formula HE-FM-BETA-003 and then inverts the cumulative beta distribution numerically, which has no closed form: Excel BETA.INV searches for the value whose cumulative probability equals the target, and R qbeta and Python scipy.stats.beta.ppf return the same inverse. The inputs therefore differ from the formula's variables: the uniform draw u and the interval levels are extra, and the outputs include quantiles that the formula cannot give.
Inputs and outputs:
mu: Reported mean, above zero and below one; required. Unit: probability, or utility for a bounded mean utility.;s: Standard error of the mean; required, above zero, with s squared below mu times (1 minus mu). Unit: as mu.;u: Uniform random number for one PSA iteration, or 0.5 for the median; optional, default 0.5. Unit: probability.;alpha,beta: Fitted shape parameters. Unit: none.;q_lo,q_hi: 2.5th and 97.5th percentiles of the fitted beta. Unit: as mu.;p_u: Value of the fitted beta at cumulative probability u, a PSA draw when u is random. Unit: as mu.Assumption: The quantity is bounded by zero and one, s is the standard error of the mean rather than a patient-level standard deviation, and a beta matched on two moments represents the evidence. Draws for different parameters use independent uniform numbers unless a correlation is modelled.
Worked example (Progression probability of 0.20 with standard error 0.05): The article's step 2 gives Beta(12.6, 50.4), a central 95% interval of about 0.112 to 0.306 and a median of about 0.197, just below the mean because the distribution is right-skewed.
mu = 0.20; s = 0.05; u = 0.5; alpha = 12.6; beta = 50.4; q_lo = 0.1116; q_hi = 0.3064; p_u = 0.1968Worked example (Severe-state utility of 0.10 with standard error 0.08): The article's severe state gives Beta(1.30625, 11.75625), with all its weight above zero, a median of about 0.080 and a central 95% interval of about 0.006 to 0.304.
mu = 0.10; s = 0.08; u = 0.5; alpha = 1.30625; beta = 11.75625; q_lo = 0.0058; q_hi = 0.3036; p_u = 0.0800Worked example (Standard error too large for the mean returns no fit): A mean of 0.20 with a standard error of 0.45 gives s squared of 0.2025, above mu times (1 minus mu) of 0.16, so alpha + beta would be negative and the function stops with no fit rather than return an invalid distribution.
mu = 0.20; s = 0.45; alpha = none; beta = noneExcel:
=IF(StdErr^2<MeanProb*(1-MeanProb),MeanProb*(MeanProb*(1-MeanProb)/StdErr^2-1),NA())returns alpha in a cell named AlphaParam, and the same formula with (1-MeanProb) as the first factor returns beta in BetaParam. Then=BETA.INV(0.025,AlphaParam,BetaParam)and=BETA.INV(0.975,AlphaParam,BetaParam)return the interval, and=BETA.INV(RAND(),AlphaParam,BetaParam)one PSA draw.R:
fit_beta <- function(mu, s, u = 0.5) { k <- mu * (1-mu) / s^2; if (k <= 1) stop("no beta distribution has this mean and standard error"); a <- mu * (k-1); b <- (1-mu) * (k-1); c(alpha = a, beta = b, q_lo = qbeta(0.025, a, b), q_hi = qbeta(0.975, a, b), p_u = qbeta(u, a, b)) }Base R only;fit_beta(0.20, 0.05, runif(1))returns the fit with one PSA draw.Python:
def fit_beta(mu, s, u=0.5): k = mu*(1-mu)/s**2; assert k > 1, "no beta distribution has this mean and standard error"; a, b = mu*(k-1), (1-mu)*(k-1); return dict(alpha=a, beta=b, q_lo=stats.beta.ppf(0.025, a, b), q_hi=stats.beta.ppf(0.975, a, b), p_u=stats.beta.ppf(u, a, b))Needsfrom scipy import stats; stats.beta.ppf is the inverse cumulative beta.Test (Lower interval limit returns its cumulative probability): Passing the 2.5th percentile back through the cumulative beta returns 0.025. Expected result: TRUE. FALSE shows a failed numerical inversion or parameters entered in the wrong order. Excel check:
=ABS(BETA.DIST(BETA.INV(0.025,AlphaParam,BetaParam),AlphaParam,BetaParam,TRUE)-0.025)<1E-6Test (Interval contains the reported mean): For a fit with both parameters above one, the reported mean lies inside the central 95% interval. Expected result: TRUE. Excel check:
=AND(BETA.INV(0.025,AlphaParam,BetaParam)<MeanProb,MeanProb<BETA.INV(0.975,AlphaParam,BetaParam))Common error (Normal distribution used for a probability near a boundary): For a probability with mean 0.10 and standard error 0.08, the mean plus or minus 1.96 standard errors runs from about minus 0.057 to 0.257, and about 11% of normal draws fall below zero, which breaks the model logic. The fitted beta keeps every draw above zero.
Source: Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB. Bayesian Data Analysis. 3rd edition. Boca Raton: Chapman & Hall/CRC; 2013. Appendix A, equation A.3, p. 585, for the method-of-moments fit. Microsoft. BETA.INV function. Microsoft Support; accessed 1 October 2026, for the inverse cumulative beta used for the interval and the PSA draw.
alpha = mu * (mu * (1 - mu) / s^2 - 1), only if s^2 < mu * (1 - mu); beta = (1 - mu) * (mu * (1 - mu) / s^2 - 1); q_lo = F^-1(0.025 | alpha, beta); q_hi = F^-1(0.975 | alpha, beta); p_u = F^-1(u | alpha, beta)
Try this function
Implementations
Excel
Beta moments fit in two cells with an existence check
With named cells MeanProb and StdErr, the two formulas return alpha and beta, or #N/A when no beta distribution has this mean and standard error.
=IF(StdErr^2<MeanProb*(1-MeanProb),MeanProb*(MeanProb*(1-MeanProb)/StdErr^2-1),NA()); =IF(StdErr^2<MeanProb*(1-MeanProb),(1-MeanProb)*(MeanProb*(1-MeanProb)/StdErr^2-1),NA())
Assumptions
Existence condition for a beta moments fit
s squared is below mu (1 minus mu). Otherwise alpha + beta is zero or negative and no beta distribution has the reported mean and standard error.
Standard error of the mean as the beta moments input
s measures the precision of the mean, that is parameter uncertainty. A standard deviation across patients describes variation between individuals and gives a distribution far too wide for parameter uncertainty.
Beta moments fit checked for parameters below one
When s is large relative to mu, one or both parameters can fall below one, which piles the distribution up against a boundary and rarely reflects what the evidence says. The fitted parameters are therefore inspected before use.
Worked examples
Beta moments fit to a progression probability of 0.20 with standard error 0.05
The article's second step: alpha + beta is 63, so alpha is 12.6 and beta 50.4. Excel BETA.INV gives a central 95% interval of about 0.112 to 0.306, wider than the 0.134 to 0.276 of Beta(24, 96).
mu = 0.20; s = 0.05; alpha = 12.6; beta = 50.4
Beta moments fit to a severe-state utility of 0.10 with standard error 0.08
The article's illustrative severe state gives Beta(1.30625, 11.75625), shown as Beta(1.31, 11.76). All its weight lies above zero and its median is about 0.08.
mu = 0.10; s = 0.08; alpha = 1.30625; beta = 11.75625
Beta moments fit with a large standard error giving parameters below one
Illustrative figures: a mean of 0.10 with a standard error of 0.25 gives alpha + beta of only 0.44, so alpha is 0.044 and beta 0.396. Both are below one and the distribution is U-shaped, with most of its weight near zero and one.
mu = 0.10; s = 0.25; alpha = 0.044; beta = 0.396
Common errors
Patient-level standard deviation entered in a beta moments fit
For a binary outcome with mean 0.20, the standard deviation across patients is the square root of 0.20 times 0.80, which is 0.40. Entered as s, it makes alpha + beta exactly zero, so no beta distribution exists; with other data a patient-level standard deviation gives a distribution far too wide for parameter uncertainty.
Beta moments fit used without checking for parameters below one
A mean of 0.10 with a standard error of 0.25 gives Beta(0.044, 0.396). About three quarters of its draws fall below 0.01 and about 4% above 0.9, so a probability with a mean of 0.10 is sampled mostly at the extremes, which rarely matches the evidence.
Sources
Method-of-moments beta fit 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. Appendix A, equation A.3, p. 585, which gives the method-of-moments estimates alpha + beta = E(1 minus E)/var minus 1, alpha = (alpha + beta)E and beta = (alpha + beta)(1 minus E).
Beta for binomial data and standard error versus standard deviation in the ISPOR-SMDM report
Briggs AH, Weinstein MC, Fenwick EAL, Karnon J, Sculpher MJ, Paltiel AD. Model parameter estimation and uncertainty: a report of the ISPOR-SMDM Modeling Good Research Practices Task Force-6. Value in Health. 2012;15(6):835-842. Page 838, which states that beta distributions are a natural match for binomial data, and pp. 836-837, which liken parameter uncertainty to the standard error of an estimate and variation between patients to the standard deviation.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0