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 )
df | A dataframe of Model Output. |
---|---|
aggregate_to | 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. |
compartments | 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. |
strat | The number of stratified groups in the model. |
hold_out_var | 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. |
id_col | A character string containing the name of the new id column. |
groups | A character vector with length equal to the level of stratification. Used to name the stratified levels. |
new_var | A character vector specifying the new variable to add when aggregating incidence. |
total_pop | A logical (defaults to |
summary_var | A logical (defaults to |
test, | Logical defaults to |
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 x 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