Summarises simulation results from the run_trials() function. Uses
extract_results() and check_performance(), which may be used directly to
extract key trial results without summarising or to calculate performance
metrics (with uncertainty measures if desired) and return them in a tidy
data.frame.
Usage
# S3 method for trial_results
summary(
object,
select_strategy = "control if available",
select_last_arm = FALSE,
select_preferences = NULL,
te_comp = NULL,
raw_ests = FALSE,
final_ests = NULL,
restrict = NULL,
cores = NULL,
...
)Arguments
- object
trial_resultsobject, output from therun_trials()function.- select_strategy
single character string. If a trial was not stopped due to superiority (or had only 1 arm remaining, if
select_last_armis set toTRUEin trial designs with a commoncontrolarm; see below), this parameter specifies which arm will be considered selected when calculating trial design performance metrics, as described below; this corresponds to the consequence of an inconclusive trial, i.e., which arm would then be used in practice.
The following options are available and must be written exactly as below (case sensitive, cannot be abbreviated):"control if available"(default): selects the firstcontrolarm for trials with a commoncontrolarm if this arm is active at end-of-trial, otherwise no arm will be selected. For trial designs without a commoncontrol, no arm will be selected."none": selects no arm in trials not ending with superiority."control": similar to"control if available", but will throw an error if used for trial designs without a commoncontrolarm."final control": selects the finalcontrolarm regardless of whether the trial was stopped for practical equivalence, futility, or at the maximum sample size; this strategy can only be specified for trial designs with a commoncontrolarm."control or best": selects the firstcontrolarm if still active at end-of-trial, otherwise selects the best remaining arm (defined as the remaining arm with the highest probability of being the best in the last adaptive analysis conducted). Only works for trial designs with a commoncontrolarm."best": selects the best remaining arm (as described under"control or best")."list or best": selects the first remaining arm from a specified list (specified usingselect_preferences, technically a character vector). If none of these arms are are active at end-of-trial, the best remaining arm will be selected (as described above)."list": as specified above, but if no arms on the provided list remain active at end-of-trial, no arm is selected.
- select_last_arm
single logical, defaults to
FALSE. IfTRUE, the only remaining active arm (the lastcontrol) will be selected in trials with a commoncontrolarm ending withequivalenceorfutility, before considering the options specified inselect_strategy. Must beFALSEfor trial designs without a commoncontrolarm.- select_preferences
character vector specifying a number of arms used for selection if one of the
"list or best"or"list"options are specified forselect_strategy. Can only contain validarmsavailable in the trial.- te_comp
character string, treatment-effect comparator. Can be either
NULL(the default) in which case the firstcontrolarm is used for trial designs with a common control arm, or a string naming a single trialarm. Will be used when calculatingerr_teandsq_err_te(the error and the squared error of the treatment effect comparing the selected arm to the comparator arm, as described below).- raw_ests
single logical. If
FALSE(default), the posterior estimates (post_estsorpost_ests_all, seesetup_trial()andrun_trial()) will be used to calculateerrandsq_err(the error and the squared error of the estimated compared to the specified effect in the selected arm) anderr_teandsq_err_te(the error and the squared error of the treatment effect comparing the selected arm to the comparator arm, as described forte_compand below). IfTRUE, the raw estimates (raw_estsorraw_ests_all, seesetup_trial()andrun_trial()) will be used instead of the posterior estimates.- final_ests
single logical. If
TRUE(recommended) the final estimates calculated using outcome data from all patients randomised when trials are stopped are used (post_ests_allorraw_ests_all, seesetup_trial()andrun_trial()); ifFALSE, the estimates calculated for each arm when an arm is stopped (or at the last adaptive analysis if not before) using data from patients having reach followed up at this time point and not all patients randomised are used (post_estsorraw_ests, seesetup_trial()andrun_trial()). IfNULL(the default), this argument will be set toFALSEif outcome data are available immediate after randomisation for all patients (for backwards compatibility, as final posterior estimates may vary slightly in this situation, even if using the same data); otherwise it will be said toTRUE. Seesetup_trial()for more details on how these estimates are calculated.- restrict
single character string or
NULL. IfNULL(default), results are summarised for all simulations; if"superior", results are summarised for simulations ending with superiority only; if"selected", results are summarised for simulations ending with a selected arm only (according to the specified arm selection strategy for simulations not ending with superiority). Some summary measures (e.g.,prob_conclusive) have substantially different interpretations if restricted, but are calculated nonetheless.- cores
NULLor single integer. IfNULL, a default value set bysetup_cluster()will be used to control whether extractions of simulation results are done in parallel on a default cluster or sequentially in the main process; if a value has not been specified bysetup_cluster(),coreswill then be set to the value stored in the global"mc.cores"option (if previously set byoptions(mc.cores = <number of cores>), and1if that option has not been specified.
Ifcores = 1, computations will be run sequentially in the primary process, and ifcores > 1, a new parallel cluster will be setup using theparallellibrary and removed once the function completes. Seesetup_cluster()for details.- ...
additional arguments, not used.
Value
A "trial_results_summary" object containing the following values:
n_rep: the number of simulations.n_summarised: as described incheck_performance().highest_is_best: as specified insetup_trial().elapsed_time: the total simulation time.size_mean,size_sd,size_median,size_p25,size_p75,size_p0,size_p100,sum_ys_mean,sum_ys_sd,sum_ys_median,sum_ys_p25,sum_ys_p75,sum_ys_p0,sum_ys_p100,ratio_ys_mean,ratio_ys_sd,ratio_ys_median,ratio_ys_p25,ratio_ys_p75,ratio_ys_p0,ratio_ys_p100,prob_conclusive,prob_superior,prob_equivalence,prob_futility,prob_max,prob_select_*(with*being either "arm_<name>for allarmnames ornone),rmse,rmse_te,mae,mae_te, andidp: performance metrics as described incheck_performance(). Note that allsum_ys_andratio_ys_measures use outcome data from all randomised patients, regardless of whether they had outcome data available at the last analysis or not, as described inextract_results().select_strategy,select_last_arm,select_preferences,te_comp,raw_ests,final_ests,restrict: as specified above.control: the control arm specified bysetup_trial(),setup_trial_binom()orsetup_trial_norm();NULLif no control.equivalence_assessed,futility_assessed: single logicals, specifies whether the trial design specification includes assessments of equivalence and/or futility.base_seed: as specified inrun_trials().cri_width,n_draws,robust,description,add_info: as specified insetup_trial(),setup_trial_binom()orsetup_trial_norm().
Examples
# 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 10 simulations with a specified random base seed
res <- run_trials(binom_trial, n_rep = 10, base_seed = 12345)
# Summarise simulations - select the control arm if available in trials not
# ending with a superiority decision
res_sum <- summary(res, select_strategy = "control")
# Print summary
print(res_sum, digits = 1)
#> Multiple simulation results: generic binomially distributed outcome trial
#> * Undesirable outcome
#> * Number of simulations: 10
#> * Number of simulations summarised: 10 (all trials)
#> * Common control arm: A
#> * Selection strategy: first control if available (otherwise no selection)
#> * Treatment effect compared to: no comparison
#>
#> Performance metrics (using posterior estimates from last adaptive analysis):
#> * Sample sizes: mean 1840.0 (SD: 506.0) | median 2000.0 (IQR: 2000.0 to 2000.0) [range: 400.0 to 2000.0]
#> * Total summarised outcomes: mean 369.9 (SD: 105.4) | median 390.0 (IQR: 376.5 to 408.5) [range: 84.0 to 466.0]
#> * Total summarised outcome rates: mean 0.202 (SD: 0.016) | median 0.196 (IQR: 0.194 to 0.209) [range: 0.180 to 0.233]
#> * Conclusive: 10.0%
#> * Superiority: 10.0%
#> * Equivalence: 0.0% [not assessed]
#> * Futility: 0.0% [not assessed]
#> * Inconclusive at max sample size: 90.0%
#> * Selection probabilities: A: 80.0% | B: 10.0% | C: 0.0% | D: 0.0% | None: 10.0%
#> * RMSE / MAE: 0.02061 / 0.01915
#> * RMSE / MAE treatment effect: 0.18206 / 0.18206
#> * Ideal design percentage: 70.4%
#>
#> Simulation details:
#> * Simulation time: 0.695 secs
#> * Base random seed: 12345
#> * Credible interval width: 95%
#> * Number of posterior draws: 5000
#> * Estimation method: posterior medians with MAD-SDs