View source: R/extract_results.R
extract_results | R Documentation |
This function extracts relevant information from multiple simulations of the
same trial specification in a tidy data.frame
(1 simulation per row).
See also the check_performance()
and summary()
functions, that uses the
output from this function to further summarise simulation results.
extract_results(
object,
select_strategy = "control if available",
select_last_arm = FALSE,
select_preferences = NULL,
te_comp = NULL,
raw_ests = FALSE,
final_ests = NULL,
cores = NULL
)
object |
|
select_strategy |
single character string. If a trial was not stopped
due to superiority (or had only 1 arm remaining, if
|
select_last_arm |
single logical, defaults to |
select_preferences |
character vector specifying a number of arms used
for selection if one of the |
te_comp |
character string, treatment-effect comparator. Can be either
|
raw_ests |
single logical. If |
final_ests |
single logical. If |
cores |
|
A data.frame
containing the following columns:
sim
: the simulation number (from 1
to the total number of
simulations).
final_n
: the final sample size in each simulation.
sum_ys
: the sum of the total counts in all arms, e.g., the total
number of events in trials with a binary outcome
(setup_trial_binom()
) or the sum of the arm totals in trials with a
continuous outcome (setup_trial_norm()
). Always uses all outcome data
from all randomised patients regardless of whether or not all patients
had outcome data available at the time of trial stopping (corresponding
to sum_ys_all
in results from run_trial()
).
ratio_ys
: calculated as sum_ys/final_n
(as described above).
final_status
: the final trial status for each simulation, either
"superiority"
, "equivalence"
, "futility"
, or "max"
, as
described in run_trial()
.
superior_arm
: the final superior arm in simulations stopped for
superiority. Will be NA
in simulations not stopped for superiority.
selected_arm
: the final selected arm (as described above). Will
correspond to the superior_arm
in simulations stopped for superiority
and be NA
if no arm is selected. See select_strategy
above.
err
: the squared error of the estimate in the selected arm,
calculated as estimated effect - true effect
for the selected
arm.
sq_err:
the squared error of the estimate in the selected arm,
calculated as err^2
for the selected arm, with err
defined above.
err_te
: the error of the treatment effect comparing the selected
arm to the comparator arm (as specified in te_comp
). Calculated as:
(estimated effect in the selected arm - estimated effect in the comparator arm) -
(true effect in the selected arm - true effect in the comparator arm)
Will be NA
for simulations without a selected arm, with no
comparator specified (see te_comp
above), and when the selected arm
is the comparator arm.
sq_err_te
: the squared error of the treatment effect comparing
the selected arm to the comparator arm (as specified in te_comp
),
calculated as err_te^2
, with err_te
defined above.
check_performance()
, summary()
, plot_convergence()
,
plot_metrics_ecdf()
, check_remaining_arms()
.
# 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)
# Extract results and Select the control arm if available
# in simulations not ending with superiority
extract_results(res, select_strategy = "control")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.