Bayesian decision-making for clinical trials in R.
BayesianTrial provides posterior and predictive probability calculations and simulation-based operating characteristics for single-arm phase II trials with binary efficacy endpoints. The current implementation supports two-stage designs with posterior-probability-based stopping rules.
Install the package from GitHub using pak:
install.packages("pak")
pak::pak("Jiangyan-Zhao/BayesianTrial")posterior_predictive_singlearm_binary() calculates
posterior summaries and predictive probabilities of meeting final
posterior success criteria.oc_singlearm_binary() estimates overall trial success,
early efficacy stopping, and early futility stopping through Monte Carlo
simulation.Consider a hypothetical trial with a historical response rate of 20%, an interim analysis after 20 patients, and a maximum sample size of 40. Nine patients respond at interim. We use the default Beta(0.2, 0.8) prior.
library(BayesianTrial)
prob <- posterior_predictive_singlearm_binary(
x_obs = 9, n_current = 20, N_total = 40,
type = "both"
)
prob$p_null
prob$ppos_nullp_null is the current posterior probability that the
response rate exceeds 0.20. ppos_null is the predictive
probability of meeting the final success criterion if the planned sample
size is completed. The default type = "posterior" returns
posterior summaries; use type = "predictive" for predictive
probabilities or type = "both" for both.
oc <- oc_singlearm_binary(
theta_true = 0.20, n_current = 20, N_total = 40
)
ocThe overall success probability (power_null_post)
estimates the type I error rate when theta_true = 0.20 and
statistical power when theta_true = 0.40. Early stopping
probabilities are also returned.
For more details, see the single-arm binary endpoint vignette.
Future versions may extend to other trial designs and endpoint types.
GPL (>= 3).