Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Bayesian random-effects posterior for a pairwise meta-analysis

p(mu, tau | y) ∝ p(mu) * p(tau) * prod_(i=1)^k [N(y_i | mu, s_i^2 + tau^2)]

Maps each trial's effect estimate y_i and standard error s_i, together with priors for the mean effect mu and the between-study standard deviation tau, to a joint posterior distribution for mu and tau. The trial-level true effects are integrated out, so each estimate contributes a normal likelihood with variance s_i^2 + tau^2. The posterior of the mean effect, shrunken trial estimates and the predictive distribution of the effect in a new setting all follow from this joint posterior, and posterior draws can pass directly into a probabilistic cost-effectiveness model. Frequentist pooling of the same data, including the DerSimonian and Laird estimate, Cochran's Q, I-squared and the prediction interval, is covered under aggregate data meta-analysis (HE-FN-ADMA-001).

  • Conditional posterior mean of the mean effect given the between-study variance

    m_mu = sum_(i=1)^k [y_i / (s_i^2 + tau2)] / sum_(i=1)^k [1 / (s_i^2 + tau2)]; sd_mu = sqrt(1 / sum_(i=1)^k [1 / (s_i^2 + tau2)])

    Gives the posterior mean and standard deviation of the mean effect mu when the between-study variance tau2 is held at one value and mu has a flat prior. Each trial is weighted by 1/(s_i^2 + tau2), so the arithmetic is that of random-effects inverse-variance pooling (HE-FM-ADMA-005), read here as a conditional posterior. A full Bayesian analysis averages this result over the posterior for tau, as in the computational function attached to this formula.

  • Shrinkage factor and shrunken trial estimate in a Bayesian meta-analysis

    B_i = s_i^2 / (s_i^2 + tau2); theta_post_i = B_i * mu + (1 - B_i) * y_i

    Gives the posterior mean of one trial's true effect theta_i given the mean effect mu and the between-study variance tau2. The trial estimate y_i is pulled towards mu by the shrinkage factor B_i, the share of the trial's total variance that comes from sampling error. Small trials, with large s_i, are pulled further, and every trial is pulled further when tau2 is small.

  • Median and central 95% range of a log-normal heterogeneity prior

    tau2_med = exp(m_LN); tau2_low = exp(m_LN - 1.96 * s_LN); tau2_high = exp(m_LN + 1.96 * s_LN)

    Summarises a log-normal prior for the between-study variance tau2, the form of the empirical priors published by Turner and colleagues, by its median and central 95% range. LN(m_LN, s_LN^2) means that the logarithm of tau2 is normal with mean m_LN and standard deviation s_LN, so the median and limits follow by exponentiating m_LN and m_LN plus or minus 1.96 s_LN. Square roots of the three values give the same summaries for tau.

  • Predictive draw of a new-setting effect and the resulting treated mortality risk

    theta_new = mu + tau * z; o_0 = p_0 / (1 - p_0); p_1 = o_0 * exp(theta_new) / (1 + o_0 * exp(theta_new))

    Draws the true effect in a new setting at one iteration of a posterior sample and converts it to an annual mortality risk on treatment for a decision model. At each iteration theta_new is drawn from N(mu, tau^2) using that iteration's mu and tau, and the odds ratio exp(theta_new) is applied to the baseline odds o_0. The conversion is the baseline and odds ratio relation of HE-FM-NMA-004, applied here to a predictive draw. The 2.5th and 97.5th percentiles of p_1 across iterations give the 95% predictive range of the treated risk.