#### Only run examples if ggplot2 is installed ####
if (requireNamespace("ggplot2", quietly = TRUE)){
# Setup a trial specification
binom_trial <- setup_trial_binom(arms = c("A", "B", "C", "D"),
control = "A",
true_ys = c(0.20, 0.18, 0.22, 0.24),
data_looks = 1:20 * 100)
# Run a single simulation with a fixed random seed
res <- run_trial(binom_trial, seed = 12345)
# Plot total allocations to each arm according to overall total allocations
plot_history(res, x_value = "total n", y_value = "n")
}
if (requireNamespace("ggplot2", quietly = TRUE)){
# Run multiple simulation with a fixed random base seed
# Notice that sparse = FALSE is required
res_mult <- run_trials(binom_trial, n_rep = 15, base_seed = 12345, sparse = FALSE)
# Plot allocation probabilities at each look
plot_history(res_mult, x_value = "look", y_value = "prob")
# Other y_value options are available but not shown in these examples
}
Run the code above in your browser using DataLab