parameter_sweep: Sweep across parameters

Description Usage Arguments Value Author(s) Examples

View source: R/parameter_sweep.R

Description

Explore scenarios using gridding with sampling for parameters not in the grid. Parameters that are included in the grid are currently hard coded. Use the future package to control parallisation outside of the function.

Usage

1
2
3
4
5
6
parameter_sweep(
  scenarios = NULL,
  samples = 1,
  sim_fn = NULL,
  show_progress = TRUE
)

Arguments

scenarios

A dataframe containing all gridded scenarios - see the examples for the required structure. Defaults to NULL.

samples

Numeric, defaults to 1. The number of samples to take.

sim_fn

Function, defaults to NULL. The vectorised model simulation function - see the examples for usage.

show_progress

Logical, defaults to TRUE. Show the progress of the parameter sweep.

Value

A nested tibble containing the parameters for each scenario and a nested list of output from wuhan_sim.

Author(s)

Sam Abbott

Examples

 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
## Not run: 
library(ringbp)
library(tibble)

scenarios <- tidyr::expand_grid(
## Put parameters that are grouped by disease into this data.frame
delay_group = list(tibble::tibble(
 delay = c("SARS","Wuhan"),
 delay_shape = c(1.651524,2.305172),
 delay_scale = c(4.287786,9.483875)
)),
k_group = list(tibble::tibble(
 theta = c("<1%","15%","30%"),
 k = c(1,0.88,0.47)
)),
index_R0 = c(1.5,2.5,3.5),
control_effectiveness = seq(0,1,0.2),
num.initial.clusters = c(5,20,40)) %>%
 tidyr::unnest("k_group") %>%
 tidyr::unnest("delay_group") %>%
 dplyr::mutate(scenario = 1:dplyr::n())

## Parameterise fixed paramters
sim_with_params <- purrr::partial(ringbp::scenario_sim,
                                 num.initial.cases=1,
                                 cap_max_days = 365,
                                 cap_cases = 5000,
                                 r0isolated = 0,
                                 disp.iso=1,
                                 disp.com = 0.16,
                                 mu_ip = 5.8, # incubation period mean
                                 sd_ip = 2.6, # incubation period sd
                                 mu_si = 7.5, # serial interval mean
                                 sd_si = 3.4) # serial interval sd


## Default is to run sequntially on a single core
future::plan("sequential")
## Set up multicore if using see ?future::plan for details
## Use the workers argument to control the number of cores used.
future::plan("multiprocess")


## Run paramter sweep
sweep_results <- ringbp::parameter_sweep(scenarios, sim_fn = sim_with_params, samples = 1)


sweep_results

## End(Not run)

covid19risk/impact-sim documentation built on April 16, 2021, 2:15 a.m.