Run a specified number of simulations with identical parameters
Source:R/scenario_sim.R
scenario_sim.RdRun a specified number of simulations with identical parameters
Arguments
- n
a positive
integerscalar: number of simulations to run- initial_cases
a non-negative
integerscalar: number of initial or starting cases which are all assumed to be missed by contact tracing (i.e. tracing ascertainment = 0).- offspring
a
listwith class<ringbp_offspring_opts>: the offspring distributionfunctions for the ringbp model, returned byoffspring_opts(). Contains three elements:community,isolated, andasymptomatic- delays
a
listwith class<ringbp_delay_opts>: the delay distributionfunctions for the ringbp model, returned bydelay_opts(). Contains 4 elements:incubation_period,onset_to_isolation,latent_periodandonset_to_self_isolation- event_probs
a
listwith class<ringbp_event_prob_opts>: the event probabilities for the ringbp model, returned byevent_prob_opts(). Contains 5 elements:asymptomatic,presymptomatic_transmission,alpha,symptomatic_tracedandsymptomatic_self_isolate- interventions
a
listwith class<ringbp_intervention_opts>: the intervention settings for the ringbp model, returned byintervention_opts(). Contains 2 elements:quarantineandtest_sensitivity- sim
a
listwith class<ringbp_sim_opts>: the simulation control options for the ringbp model, returned bysim_opts()
Value
A data.table object returning the results for multiple simulations
using the same set of parameters. The table has columns
week: The week in the simulation.
weekly_cases: The number of new cases that week.
cumulative: The cumulative cases.
effective_r0: The effective reproduction rate for the whole simulation
cases_per_gen: A list column with the cases per generation. This is repeated each row.
sim: Index column for which simulation.
Examples
offspring <- offspring_opts(
community = \(n) rnbinom(n = n, mu = 2.5, size = 0.16),
isolated = \(n) rnbinom(n = n, mu = 0, size = 1),
asymptomatic = \(n) rnbinom(n = n, mu = 2.5, size = 0.16)
)
delays <- delay_opts(
incubation_period = \(n) rweibull(n = n, shape = 2.32, scale = 6.49),
onset_to_isolation = \(n) rweibull(n = n, shape = 2.5, scale = 5)
)
event_probs <- event_prob_opts(
asymptomatic = 0,
presymptomatic_transmission = 0.3,
symptomatic_traced = 0
)
interventions <- intervention_opts(quarantine = TRUE)
sim <- sim_opts(
cap_max_days = 365,
cap_cases = 2000
)
res <- scenario_sim(
n = 5,
initial_cases = 5,
offspring = offspring,
delays = delays,
event_probs = event_probs,
interventions = interventions,
sim = sim
)
res
#> sim week weekly_cases cumulative effective_r0
#> <int> <int> <int> <int> <num>
#> 1: 1 0 4 4 2.820762
#> 2: 1 1 17 21 2.820762
#> 3: 1 2 36 57 2.820762
#> 4: 1 3 198 255 2.820762
#> 5: 1 4 488 743 2.820762
#> ---
#> 261: 5 48 0 2860 2.609450
#> 262: 5 49 0 2860 2.609450
#> 263: 5 50 0 2860 2.609450
#> 264: 5 51 0 2860 2.609450
#> 265: 5 52 0 2860 2.609450
#> cases_per_gen
#> <list>
#> 1: 18, 30, 138, 382, 832,1757
#> 2: 18, 30, 138, 382, 832,1757
#> 3: 18, 30, 138, 382, 832,1757
#> 4: 18, 30, 138, 382, 832,1757
#> 5: 18, 30, 138, 382, 832,1757
#> ---
#> 261: 33, 43, 96,136,332,700,...[7]
#> 262: 33, 43, 96,136,332,700,...[7]
#> 263: 33, 43, 96,136,332,700,...[7]
#> 264: 33, 43, 96,136,332,700,...[7]
#> 265: 33, 43, 96,136,332,700,...[7]