Signature
alpha = alpha_0 + D; beta = beta_0 + T; E_r = alpha / beta; SD_r = sqrt(alpha) / beta
| Inputs | Definition | Unit |
|---|---|---|
alpha_0 | Shape parameter of the gamma prior for the event rate, above zero | none |
D | Number of events observed in the exposure, zero or above | events |
beta_0 | Rate parameter, or inverse scale, of the gamma prior, above zero | exposure, such as patient-years |
T | Total exposure over which the events were counted, above zero | exposure, in the unit of beta_0 |
alpha | Shape parameter of the gamma posterior | none |
|---|---|---|
beta | Rate parameter, or inverse scale, of the gamma posterior | exposure |
E_r | Mean of the posterior for the event rate | events per unit of exposure |
SD_r | Standard deviation of the posterior for the event rate | events per unit of exposure |
Function
Bayesian analysis function for a posterior and its decision summaries
Takes a prior distribution for an unknown model input, a likelihood and the observed data and returns the posterior distribution with the summaries a health technology assessment reads, such as a posterior mean, an expected value of perfect information and a model comparison statistic. The posterior is proportional to likelihood times prior, and HE-FN-BAD-001 gives the normalised form. Live records already hold the common conjugate updates, the beta for a probability in HE-FM-BETA-002, the normal for a treatment effect in HE-FM-BAD-001 and the Dirichlet for a transition row in HE-FM-DIRI-002. The posterior mean of HE-FM-BETA-002 is also the average of the prior mean and the trial proportion weighted by alpha_0 + beta_0 and n (derived). Posterior draws feed the acceptability curve HE-FM-CEAC-001 and EVPI from draws HE-FM-EVPI-002. This package adds the gamma update for an event rate, exact EVPI when incremental net benefit is linear in a beta probability, and the deviance information criterion. Notation follows the Bayesian Analysis article.
Try this function
Implementations
Excel
Gamma posterior for an event rate in four cells
With named cells PriorShape, PriorRate, EventCount and Exposure, the four formulas return PostShape, PostRate, PostMeanRate and PostSDRate. An interval comes from GAMMA.INV with the third argument set to 1/PostRate, because that argument is a scale (HE-ER-BETA-006).
=PriorShape+EventCount; =PriorRate+Exposure; =PostShape/PostRate; =SQRT(PostShape)/PostRate
Assumptions
Poisson count with one rate per unit of exposure
The count in each unit follows a Poisson distribution with mean equal to its exposure times one common rate, so the units can be pooled by adding events and adding exposure. A rate that changes over follow-up or between centres needs a richer model.
Prior shape and rate above zero in one exposure unit
alpha_0, beta_0 and T are above zero and beta_0 and T use the same exposure unit. The prior is written with an inverse scale, so a prior reported with a scale is converted first.
Prior for an event rate built on evidence other than the counts
The prior comes from evidence separate from D and T. A prior built from the same study counts those events twice.
Worked examples
Infection rate with a Gamma(2, 100) prior and 12 infections in 400 patient-years
Illustrative figures from the Gamma Distribution article. The posterior is Gamma(14, 500), with mean 0.028 per patient-year. Excel GAMMA.INV gives a central 95% interval of about 0.0153 to 0.0445, and HE-FM-TP-001 turns the mean rate into an annual probability of about 0.0276.
alpha_0 = 2; beta_0 = 100; D = 12; T = 400; alpha = 14; beta = 500; E_r = 0.028; SD_r = 0.00748
Asthma mortality with three deaths in one city year under a Gamma(3, 5) prior
The Gelman and colleagues example, with the rate per 100,000 persons per year and a city of 200,000 giving exposure 2. The posterior is Gamma(6, 7), and its mean of about 0.857 is the 0.86 they print.
alpha_0 = 3; beta_0 = 5; D = 3; T = 2; alpha = 6; beta = 7; E_r = 0.857; SD_r = 0.350
Asthma mortality with thirty deaths over ten city years
The same prior with ten years of data at the same crude rate gives Gamma(33, 25), mean 1.32, as Gelman and colleagues print. The data now hold more of the weight, with the prior mean of 0.6 and the crude rate of 1.5 either side.
alpha_0 = 3; beta_0 = 5; D = 30; T = 20; alpha = 33; beta = 25; E_r = 1.32; SD_r = 0.2298
No events in 400 patient-years under a Gamma(2, 100) prior
Illustrative limiting case. A zero count still gives a valid posterior because the prior shape is above zero, with mean 2 / 500 = 0.004 per patient-year.
alpha_0 = 2; beta_0 = 100; D = 0; T = 400; alpha = 2; beta = 500; E_r = 0.004; SD_r = 0.00283
Common errors
Prior and exposure in different time units for a gamma rate
Taking beta_0 of 100 in patient-years but the 400 patient-years of follow-up as 4,800 patient-months gives a posterior mean of 14 / 4,900, about 0.0029, which is neither a yearly nor a monthly rate. The yearly answer is 0.028 and the monthly equivalent about 0.0023.
Prior for an event rate built on the same counts
Using the posterior Gamma(14, 500) as the prior and adding the same 12 infections in 400 patient-years again gives Gamma(26, 900). The mean hardly moves, about 0.0289 against 0.028, but the standard deviation falls about 24%, about 0.0057 against 0.0075, which is false precision.
Sources
Gelman and colleagues on the gamma posterior for a Poisson rate with exposure
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.6, subsection Poisson model parameterized in terms of rate and exposure, equations 2.14 and 2.15, pp. 44-45, which gives the posterior Gamma(alpha + sum y_i, beta + sum x_i) and the asthma example with Gamma(3, 5), y = 3, x = 2, Gamma(6, 7), mean 0.86, and probability 0.30 above 1.0, then Gamma(33, 25), mean 1.32, and probability 0.93.
Gamma moments and conjugacy in the Bayesian Data Analysis appendix
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, Table A.1, pp. 578-579, which gives the gamma with shape alpha and inverse scale beta, mean alpha/beta and variance alpha/beta squared; and p. 583, which states that the gamma is the conjugate prior for the mean parameter of the Poisson distribution.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0
