Filter for comparable scenarios
Arguments
- x
A 'comparison' object comprised of 'scenario' objects, each of which must have data prepared.
- match_variables
A character string of scenario parameter names that is used to check whether the two scenarios have identical parameters.
- comparison_variables
A character string of column names expected in the scenarios' outcome data. This is used to check whether the scenarios both have the required columns in their data.
Value
A 'comparison' object retaining only those 'scenario' objects in the data list that are comparable with the baseline scenario.
Examples
pandemic_flu <- scenario(
name = "pandemic_flu",
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(r0 = 1.5),
extra_info = list(country = "UK", pathogen = "flu")
)
covid19 <- scenario(
name = "covid19",
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(r0 = 5.0),
extra_info = list(country = "UK", pathogen = "SARS-CoV-2")
)
# run scenarios to generate data
pandemic_flu <- run_scenario(pandemic_flu)
covid19 <- run_scenario(covid19)
# check whether scenarios are comparable
outbreak_comparison <- comparison(
pandemic_flu, covid19,
baseline = "pandemic_flu"
)
# filter on pathogen
sce_filter_comparable(
outbreak_comparison,
match_variables = "pathogen",
comparison_variables = "p_infected"
)
#> Scenario comparison object
#> Number of scenarios: 1
#> Baseline scenario: "pandemic_flu"
#> All scenario data are prepared, use `sce_get_outcomes()` to get data
#> Scenario matching variables:
#> "pathogen"
#> Scenario comparison variables:
#> "p_infected"
#> Model functions found:
#> finalsize::final_size