create_record_df: Creates a 'rec_df' object

Description Usage Arguments Details Value

View source: R/setup_simulation.R

Description

This function creates a rec_df dataframe object, which is used to record all cases that ever get created within a simulation.

Usage

1
2
3
4
5
6
create_record_df(
  state_df,
  sim_status,
  initialize = FALSE,
  infection_source = NULL
)

Arguments

state_df

state_df object for the cases to be generated

sim_status

The sim_status state vector

initialize

A boolean indicating whether these cases are the first cases of the simulation. Defaults to FALSE.

infection_source

A string or vector of case_ids representing the source of each case's infection. Defaults to NULL, however, this parameter cannot be NULL if initialize is FALSE.

Details

The simulation's main rec_df dataframe is created with this function at the beginning of the simulation. When new cases are added (secondary or imported infections), a rec_df dataframe is created for these new cases by generate_secondary_infections and generate_imported_infections. The new rec_df object is merged with the main rec_df within step_simulation.

The columns of this dataframe are: case_id, source, is_traced, is_trace_app_user, is_traced_by_app, is_trace_app_comply, is_symptomatic, d_incub, d_iso_delay, d_infection, contact_rate, n_sec_infects, d_generation_ints, t_inf, t_symp, t_iso, t_inact, cases_inf, s_status, and non_infect_generations. The meaning of these columns will be documented elsewhere. Columns case_id through t_inf as well as column non_infect_generations are constant and are initialized when this function is called, using the provided state_df object. The columns t_symp, t_iso and t_inact are initialized as NA and replaced with the actual simulation time where these events happen. If they do not happen (e.g. an asymptomatic case will not have a t_symp or t_iso), then the value remains as NA. The column cases_inf is meant for a list of case_id of all secondary infections caused by the given case but is not yet implemented. The column s_status is updated by step_simulation at the appropriate time in the simulation.

Note that all time lengths are given in days and values in columns beginning with d_ are a period of days since the relevant reference time while columns beginning with t_ are absolute time, measured in days since the simulation began.

Value

A rec_df dataframe object


bcgov/epi.branch.sim documentation built on Dec. 16, 2020, 5:49 a.m.