Temporal aggregation of pansim objects

# S3 method for pansim
aggregate(
  x,
  start = NULL,
  period = NULL,
  FUN = mean,
  fixed_vars = TRUE,
  extend = 30,
  ...
)

Arguments

x

a pansim object

start

starting date for temporal aggregation

period

time period for temporal aggregation (e.g. "7 days", see seq.Date)

FUN

temporal aggregation function (applied across all variables) or a list of the form list(FUN1=c('var1','var2'), FUN2=c('var3', 'var4')) (temporal aggregation is done after state aggregation, so variable names specified should be adjusted appropriately)

fixed_vars

treat names in FUN as fixed strings rather than regular expressions?

extend

how far to extend time series for aggregation purposes

...

unused, for generic consistency

Examples

params <- read_params("ICU1.csv")
state <- make_state(params=params)
sdate <- "2020-02-10" ## arbitrary!
res <- run_sim(params,state,start_date=sdate,end_date="2020-06-01")
a1 <- aggregate(res, start="2020-02-12",period="7 days", FUN=sum)
## column-specific aggregation
first <- dplyr::first
agg_funs <- list(mean=c("H","ICU","I"), sum=c("report","death"))
a2 <- aggregate(condense(res), start="2020-02-12",period="7 days", FUN=agg_funs)