R/aggregate_model.R
aggregate_model.Rd
A Function to Apply Multiple Aggregations to Model Output
aggregate_model(
df,
aggregate_to = NULL,
compartments = NULL,
strat = NULL,
hold_out_var = NULL,
id_col = NULL,
groups = NULL,
new_var = "incidence",
total_pop = TRUE,
summary_var = FALSE,
test = FALSE
)
A dataframe of Model Output.
A character vector or list specifying the aggregation operations to perform on the model output. Operations are carried out in the order specified. Implemented options are; disease, demographic, and incidence.
A character vector or list specifying the unique compartments to aggregate. May either be specified once for all aggregation functions or for each function separately.
The number of stratified groups in the model.
A character vector or list specifying the unique compartments that will not be aggregated. May either be specified once for all aggregation functions or for each function separately. If compartments is set then this argument does not need to be used.
A character string containing the name of the new id column.
A character vector with length equal to the level of stratification. Used to name the stratified levels.
A character vector specifying the new variable to add when aggregating incidence.
A logical (defaults to TRUE
) indicating if the total population should be
calculated when summarising the model demographics.
A logical (defaults to FALSE
), specifying whether to add an additional summary variable across
all stratified levels.
Logical defaults to FALSE
. For testing, returns the processed inputs rather than
performing the aggregation.
An aggregated dataframe.
aggregate_model aggregate_model_internal combine_to_age_model combine_strat_model_output summarise_var_by_strat
df <- data.frame(A1 = 1, B1 = 1, A2 = 1, B2 = 1, A3 = 1, B3 = 1)
aggregate_model(df, aggregate_to = "incidence",
compartments = c("A", "B"), strat = 3,
summary_var = TRUE)
#> # A tibble: 1 × 10
#> incidence incidence1 incidence2 incidence3 A1 B1 A2 B2 A3 B3
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 6 2 2 2 1 1 1 1 1 1