This is the key user-facing function for simulating trials.
Usage
simulate_trials(scenario, ...)
# S3 method for hrqolr_scenario
simulate_trials(
scenario,
n_trials = 100,
n_patients_ground_truth = 1000,
n_example_trajectories_per_arm = 50,
test_fun = welch_t_test,
include_trial_results = FALSE,
verbose = TRUE,
n_digits = 2,
valid_hrqol_range = c(-0.757, 1),
alpha = 0.05,
max_batch_size = NULL,
seed = NULL,
...
)Arguments
- scenario
object of class 'hrqolr_scenario', the output of setup_scenario
- ...
passed on to methods
- n_trials
single integer, the number of trials to simulate in total
- n_patients_ground_truth
single integer, how many patients (per arm) to use when estimating the ground truth
- n_example_trajectories_per_arm
single integer, the number of example trajectories to include in the returned object
- test_fun
function used to compare estimates. The default is
welch_t_test(built intohrqolr). Note that the function should handle the number of arms provided. See Details below.- include_trial_results
single logical, indicates whether trial-level results are kept. Default is
FALSEbecause the resulting object may be very large if many trials are simulated.- verbose
single logical, should the function give progress timestamped updates? Default:
TRUE- n_digits
single integer, the number of decimal places of in the first HRQoL values of patients. More digits will yield greater precision but also cause longer run-times.
- valid_hrqol_range
two-element numeric vector, the lower and upper bounds of valid HRQoL values. The default (
c(-0.757, 1.0)) corresponds to the Danish EQ-5D-5L index values.- alpha
single numerical value in
[0, 1], the desired type 1 error rate used when comparing HRQoL in the arms.- max_batch_size
single integer, the maximum number of patients to process in each batch. The default is to use run one batch (i.e. no upper limit).
- seed
single integer, optional seed for reproducible pseudo-random number generation. Defaults to a deterministic value based on the arguments given (ensuring reproducibility by default).
Value
An object of class hrqolr_results, which is a specialised list with
six elements:
summary_statscontains summary statistics for each armcomparisonscontains comparisons against the ground truth and performance metricsargsis a list with all argumentstrial_resultscontains trial-level results, ifinclude_trial_results = TRUEexample_trajectoriescontains example trajectories isn_example_trajectories_per_armis greater than 0resource_usedocuments approximate run-time, peak memory use and maximum cache size. This information can be helpful for orchestration if several (hundreds or thousands) scenarios are simulated in parallel on e.g. high-performance computing systems
Details
test_fun
hrqolr comes with three built-in test functions:
welch_t_test and bootstrap_estimates work with two-armed trials,
games_howell_test with three-arm trials. If you use case so requires, you
can specify your own test_fun. It must accept five arguments:
valsis a vector all outcome valuesgrpsis a vector with the same length asvalswith grouping indicesarmsis the unique values in thegrpsvectorna_replacementis the value to put in place of NA's (which would be patients for whom no outcome values are available because they have died before follow-up started)alphathe significance level specified when callingsimulate_trials()
--and it must return a list with six elements:
comparatorstring, the name of comparator arm in the comparisontargetstring, the name of target arm in the comparisonestnumeric, the point estimatep_valuenumericci_lonumeric, lower bound of the confidence intervalci_hinumeric, upper bound of the confidence interval