Run an epidemic model scenario using the function stored in
model_function
with the arguments in parameters
. Runs as many replicates
of the function as specified in replicates
. The simulation output data are
stored under data
.
Value
The original object with the data
field populated with
simulation output. This object must be assigned.
Returns a scenario
object when called on a scenario
object as expected,
with the data
field populated with epidemic simulation model outputs.
Returns a comparison
object with the data
fields of the scenario
objects contained in it populated.
Examples
# For a `scenario` object
# prepare a scenario
scenario_pandemic_flu <- scenario(
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(), # using helper function
replicates = 1L
)
# print to check that data are not prepared
scenario_pandemic_flu
#> Epidemic scenario object
#> Scenario name: No name specified (NA)
#> Model function: finalsize::final_size
#> Extra information on:
#> Scenario replicates: 1
#> Scenario outcomes are not prepared
# generate scenario data
scenario_pandemic_flu <- run_scenario(scenario_pandemic_flu)
# print to check that data are prepared
scenario_pandemic_flu
#> Epidemic scenario object
#> Scenario name: No name specified (NA)
#> Model function: finalsize::final_size
#> Extra information on:
#> Scenario replicates: 1
#> Scenario outcomes are prepared
# For a `comparison` object
# prepare two scenarios of the final size of an epidemic
pandemic_flu <- scenario(
name = "pandemic_flu",
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(r0 = 1.5),
replicates = 1L
)
covid19 <- scenario(
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(r0 = 5.0),
replicates = 1L
)
# create a comparison object
x <- comparison(
pandemic_flu, covid19,
baseline = "pandemic_flu"
)
x <- run_scenario(x)
x
#> Scenario comparison object
#> Number of scenarios: 2
#> Baseline scenario: "pandemic_flu"
#> All scenario data are prepared, use `sce_get_outcomes()` to get data
#> Scenario matching variables:
#> No matching variables specified yet.
#> Scenario comparison variables:
#> No comparison variables specified yet.
#> Model functions found:
#> finalsize::final_size