Description Usage Arguments Examples
Run multiple bootstrapped change_point simulations (in parallel)
1 2 3 4 5 6 7 8 9 10 | run_cp_bootstrap(
sim_data,
sim_version = "visits",
boot_trials = 100,
n_sim_trials = 50,
new_draw_weight = 0,
num_cores = NULL,
sim_duartion_for_regression = FALSE,
no_bootstrapping = FALSE
)
|
sim_data |
A dataset containing the time_map, miss bins and other parameters used for the simulation. This dataset should be created using the 'prep_sim_data()' function |
sim_version |
The simulation version to run. Options include "visits" (default) or "patients" |
boot_trials |
The number of bootstrapped trials to run (default is 100) |
n_sim_trials |
The number of trials to run in simulation of miss visits (default is 50) |
new_draw_weight |
A weighing parameter used to assign preference to drawing previously "missed" patients at each time step. A value of 0 applies strict preference to drawing patients who have been assigned to miss in prior time steps, while a value 0.5 applies equal weight to patients who have and have not been previously selected |
num_cores |
The number of worker cores to use. If not specified will determined the number of cores based on the which ever is the smallest value between number of boot_trials or detected number of cores - 1 |
no_bootstrapping |
Specifies whether you want to run the simulations without bootstrapping the original dataset |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | ### Run simulations with bootstrapping and allow change point to vary with each bootstrap sample ###
#load example final_time_map dataset
load("/Shared/Statepi_Diagnosis/grant_projects/hsv_enceph/scripts/validation/enrolled_ge_365/report_data.RData")
# rename ED column
final_time_map <- final_time_map %>% rename(ed = ED)
# run prep sim function
tmp_sim_data <- prep_sim_data(final_time_map, event_name = "any_ssd", cp_method = "cusum", start_day = 1L, by_days = 1L,
week_period = TRUE)
#run simulations on number of visits
simulation_results <- run_cp_bootstrap(tmp_sim_data,
sim_version = "visits",
boot_trials = 500,
n_sim_trials = 50,
new_draw_weight = NULL,
num_cores = NULL,
sim_duartion_for_regression = FALSE,
no_bootstrapping = FALSE)
### Run simulations with bootstrapping and specify a change point applied to each bootstrap sample ###
# set a change point
cp <- 20L
# run prep sim function
tmp_sim_data <- prep_sim_data(final_time_map, event_name = "any_ssd", cp_method = "cusum", start_day = 1L, by_days = 1L,
week_period = TRUE, specify_cp = cp)
#run simulations on number of visits
simulation_results <- run_cp_bootstrap(tmp_sim_data,
sim_version = "visits",
boot_trials = 500,
n_sim_trials = 50,
new_draw_weight = NULL,
num_cores = NULL,
sim_duartion_for_regression = FALSE,
no_bootstrapping = FALSE)
### Run simulations without bootstrapping and allow function to find the optimal change point for inputted data ###
# run prep sim function
tmp_sim_data <- prep_sim_data(final_time_map, event_name = "any_ssd", cp_method = "cusum", start_day = 1L, by_days = 1L,
week_period = TRUE)
#run simulations on number of visits
simulation_results <- run_cp_bootstrap(tmp_sim_data,
sim_version = "visits",
boot_trials = 0,
n_sim_trials = 25000,
new_draw_weight = NULL,
num_cores = NULL,
sim_duartion_for_regression = FALSE,
no_bootstrapping = TRUE)
### Run simulations without bootstrapping and specify a change point instead of allowing function to find the optimal change point to apply to the data ###
# set a change point
cp <- 20L
# run prep sim function
tmp_sim_data <- prep_sim_data(final_time_map, event_name = "any_ssd", cp_method = "cusum", start_day = 1L, by_days = 1L,
week_period = TRUE, specify_cp = cp)
#run simulations on number of visits
simulation_results <- run_cp_bootstrap(tmp_sim_data,
sim_version = "visits",
boot_trials = 0,
n_sim_trials = 25000,
new_draw_weight = NULL,
num_cores = NULL,
sim_duartion_for_regression = FALSE,
no_bootstrapping = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.