Functions & Formulae

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

Bayesian interim decision function for an adaptive trial

p(theta | y) = p(y | theta) * p(theta) / p(y); stop if Pr(d > a | y) > c

Maps a prior distribution for the treatment effect, the data observed so far and pre-specified thresholds to the quantities that interim rules consult: the posterior probability that the effect exceeds a minimum value, which summarises the evidence now, and the predictive probability that the final analysis will succeed, which averages over the results still to come. Response-adaptive rules use the same posterior to set the chance of allocation to each arm. The notation follows the Bayesian Adaptive Design article.

  • Normal prior to posterior update of a treatment effect at an interim analysis

    v_1 = 1 / (1 / v_0 + 1 / s^2); m_1 = v_1 * (m_0 / v_0 + y / s^2); z_1 = (m_1 - a) / sqrt(v_1)

    Combines a normal prior for the treatment effect with a normally distributed interim estimate of known standard error. The posterior precision is the prior precision plus the data precision, and the posterior mean is the precision-weighted average of the prior mean and the estimate. Dividing the posterior mean minus the minimum effect a by the posterior standard deviation gives z_1, and the posterior probability that the effect exceeds a is Phi(z_1), the standard normal distribution function, which a success criterion of the form Pr(d > a | y) > c compares with c.

  • Predictive probability of final success for a normal two-stage Bayesian design

    v_1 = 1 / (1 / v_0 + 1 / s_1^2); m_1 = v_1 * (m_0 / v_0 + y_1 / s_1^2); v_f = 1 / (1 / v_0 + 1 / s_1^2 + 1 / s_2^2); y2_crit = s_2^2 * (z_c / sqrt(v_f) - m_0 / v_0 - y_1 / s_1^2); z_pp = (y2_crit - m_1) / sqrt(v_1 + s_2^2)

    Projects an interim look forward to the final analysis. Final success is a final posterior probability of a positive effect above Phi(z_c), so the final posterior mean must exceed z_c final standard deviations. Solving for the second-stage estimate gives y2_crit, and given the interim posterior that estimate is predicted to be normal with mean m_1 and variance v_1 plus s_2 squared. The predictive probability of success is 1 minus Phi(z_pp). Unlike the posterior probability it asks how likely the trial is to succeed, not how strong the evidence is now.

  • Thall and Wathen response-adaptive allocation probability

    pi_E = P^c / (P^c + (1 - P)^c)

    Sets the probability that the next patient is allocated to the experimental arm from the current posterior probability that the experimental arm has the higher success rate. The tuning constant c controls how hard allocation follows the posterior: c of 0 gives equal randomisation, c of 1 gives Thompson sampling, and one half, or a value rising with the number enrolled such as i / (2n), has been suggested to reduce the variability of allocation.

  • Lee and Liu predictive probability for a single-arm trial with a binary response

    PP = sum_(i=0)^m [w_i * (B_i > theta_T)]

    With x responses in n patients so far, a beta(a_0, b_0) prior and a maximum of N_max patients, the number of responses Y among the m = N_max minus n patients still to come is beta-binomial(m, a_0 + x, b_0 + n minus x), with weight w_i for Y = i. For each i, B_i is the final posterior probability that the response rate exceeds p_0, from a beta(a_0 + x + i, b_0 + N_max minus x minus i) distribution. The predictive probability sums the weights of the future results for which B_i exceeds theta_T; the trial stops for futility if it falls below theta_L and for efficacy if it exceeds theta_U.