Run a scenario analyis

scenario_analysis(
  scenarios = NULL,
  sampled_and_set_parameters = NULL,
  delay_sample_func = NULL,
  show_progress = FALSE,
  kept_times
)

Arguments

scenarios

Dataframe of potential scenarios

sampled_and_set_parameters

Dataframe of sampled and fixed parameter values

delay_sample_func

Function to generate sample reporting delays

show_progress

Logical, defaults to FALSE. Show progress be shown.

kept_times

Numeric, a vector of timepoints to keep information on. Defaults to all time points

Value

A nested dataframe of scenarios combined with model simulations

Examples

## Code scenario_analysis
#> function (scenarios = NULL, sampled_and_set_parameters = NULL, #> delay_sample_func = NULL, show_progress = FALSE, kept_times) #> { #> scenario <- NULL #> data <- NULL #> serial_fn <- NULL #> scenario_sims <- scenarios %>% dplyr::group_by(scenario) %>% #> tidyr::nest() %>% dplyr::ungroup() %>% dplyr::sample_frac(size = 1, #> replace = FALSE) %>% dplyr::mutate(sims = furrr::future_map(data, #> function(data) { #> sampled_R0 <- stats::runif(nrow(sampled_and_set_parameters), #> data$lower_R0, data$upper_R0) #> sims <- purrr::map(1:nrow(sampled_and_set_parameters), #> function(.x) { #> sim <- tibble::tibble(size = list(WuhanSeedingVsTransmission::run_sim(n = data$event_size, #> n_length = data$event_duration, mean_si = data$serial_mean, #> sd_si = data$serial_sd, serial_fn = data$serial_fn[[1]], #> R0 = sampled_R0[.x], k = sampled_and_set_parameters$k[.x], #> tf = sampled_and_set_parameters$outbreak_length[.x] + #> data$event_duration, kept_times = kept_times + #> data$event_duration, max_potential_cases = sampled_and_set_parameters$upper_case_bound + #> 1, delay_sample = delay_sample_func)), #> sample = .x, R0 = sampled_R0[.x]) #> sim <- tidyr::unnest(sim, "size") #> return(sim) #> }) #> sims <- dplyr::bind_rows(sims) #> }, .progress = show_progress)) #> scenario_sims <- tidyr::unnest(scenario_sims, "data") #> scenario_sims <- dplyr::select(scenario_sims, -serial_fn) #> scenario_sims <- tidyr::unnest(scenario_sims, "sims") #> return(scenario_sims) #> } #> <bytecode: 0x55a6aca6af08> #> <environment: namespace:WuhanSeedingVsTransmission>