Skip to contents

Get scenario outcomes

Usage

sce_get_outcomes(x)

Arguments

x

A scenario or comparison object with the scenario outcome data prepared. Check for whether data has been prepared using sce_has_data().

Value

A single data.table holding the output of all replicates of the scenario. If x is a comparison object, the data.table holds the outcomes of each replicate of each scenario specified therein. Scenarios in this case are identified either by their names if any, or by a simple synthetic identifier such as 'scenario_01'.

Examples

# For the `scenario` class
# create a scenario specification
scenario_pandemic_flu <- scenario(
  model_function = "finalsize::final_size",
  parameters = make_parameters_finalsize_UK(),
  replicates = 3 # note extra replicates
)

# run scenario
scenario_pandemic_flu <- run_scenario(scenario_pandemic_flu)

# get outcomes
sce_get_outcomes(scenario_pandemic_flu)
#>    demo_grp   susc_grp susceptibility p_infected replicate
#>      <char>     <char>          <num>      <num>     <int>
#> 1:   [0,20) susc_grp_1              1  0.6544866         1
#> 2:  [20,40) susc_grp_1              1  0.5750030         1
#> 3:      40+ susc_grp_1              1  0.4588871         1
#> 4:   [0,20) susc_grp_1              1  0.6544866         2
#> 5:  [20,40) susc_grp_1              1  0.5750030         2
#> 6:      40+ susc_grp_1              1  0.4588871         2
#> 7:   [0,20) susc_grp_1              1  0.6544866         3
#> 8:  [20,40) susc_grp_1              1  0.5750030         3
#> 9:      40+ susc_grp_1              1  0.4588871         3

# For the `comparison` class
# 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
outbreak_comparison <- comparison(
  pandemic_flu, covid19,
  baseline = "pandemic_flu"
)

outbreak_comparison <- run_scenario(outbreak_comparison)

sce_get_outcomes(outbreak_comparison)
#>    demo_grp   susc_grp susceptibility p_infected replicate scenario_name
#>      <char>     <char>          <num>      <num>     <int>        <char>
#> 1:   [0,20) susc_grp_1              1  0.6544866         1  pandemic_flu
#> 2:  [20,40) susc_grp_1              1  0.5750030         1  pandemic_flu
#> 3:      40+ susc_grp_1              1  0.4588871         1  pandemic_flu
#> 4:   [0,20) susc_grp_1              1  0.9973053         1    scenario_2
#> 5:  [20,40) susc_grp_1              1  0.9941026         1    scenario_2
#> 6:      40+ susc_grp_1              1  0.9785699         1    scenario_2