aggregate_model {idmodelr}R Documentation

A Function to Apply Multiple Aggregations to Model Output

Description

A Function to Apply Multiple Aggregations to Model Output

Usage

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
)

Arguments

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 TRUE) indicating if the total population should be calculated when summarising the model demographics.

summary_var

A logical (defaults to FALSE), specifying whether to add an additional summary variable across all stratified levels.

test

Logical defaults to FALSE. For testing, returns the processed inputs rather than performing the aggregation.

Value

An aggregated dataframe.

See Also

aggregate_model aggregate_model_internal combine_to_age_model combine_strat_model_output summarise_var_by_strat

Examples

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)

[Package idmodelr version 0.4.0 Index]