Use a hierarchical Bayesian model with binomial observation errors and a common distribution for the underlying risks:
Give a shared hyperprior, or parameterize them by mean and concentration and put priors on and . Conditional on these hyperparameters, the risks are independent and identically distributed; after integrating them out they are exchangeable random variables with shared uncertainty. The data estimate the overall risk level and between-hospital variation. Conditional Beta-binomial conjugacy gives
and full Bayes point estimates under squared-error loss are
An Empirical Bayes method instead estimates the hyperparameters from the marginal beta-binomial distribution likelihood
and inserts their fitted values in the conditional posterior means. Both approaches provide partial pooling, stronger for smaller hospitals. Full Bayes also propagates hyperparameter uncertainty into the credible intervals. If systematic covariates are needed, one can place exchangeable residual effects in a logistic regression model rather than assuming a common unconditional risk distribution.
Put , , and . Integrate the future binomial distribution against the current beta distribution posterior density:
This is the beta-binomial distribution. For positive integer , the Gamma function values reduce to factorials, giving
Using and rewrites this as
Substitution of gives exactly the two required factors. The probability is zero outside .