create_state_df: Creates a 'state_df' object

Description Usage Arguments Details Value

View source: R/setup_simulation.R

Description

This function creates a state_df dataframe object, which is used to track active cases in the simulation.

Usage

1
2
3
4
5
6
7
8
9
create_state_df(
  n_cases,
  sim_params,
  sim_status,
  initialize = FALSE,
  import = FALSE,
  primary_state_df = NULL,
  primary_case_ids = NULL
)

Arguments

n_cases

The number of cases to initialize in this dataframe

sim_params

The sim_params object containing disease and simulation parameters

sim_status

The sim_status state vector

initialize

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

import

A boolean indicating whether these new cases are imported cases instead of secondary infections. Defaults to FALSE. Imported cases are never app users and are never traced.

primary_state_df

When generating a state_df object for secondary infections, this parameter should be the state_df object for the index/primary cases. This should be NULL when there is no primary case. Defaults to NULL.

primary_case_ids

When generating a state_df object for secondary infections, this parameter should be a list of case_ids for the primary cases. This should be NULL when there is no primary case. Defaults to NULL.

Details

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

The columns of this dataframe are: case_id, status, is_traced, is_trace_app_user, is_trace_app_comply, is_traced_by_app, is_symptomatic, days_infected, incubation_length, isolation_delay, infection_length, contact_rate, n_sec_infects, and generation_intervals. The meaning of these columns will be documented elsewhere. Most of the columns are constant and are initialized in this function via calls to related functions in draw_distributions.R. All time lengths are in days and represent a relative time, not absolute times. The status, n_sec_infects and generation_intervals columns are updated over the course of the simulation as cases progress through infection states. The n_sec_infects counter and corresponding generation_intervals list have its elements removed as the secondary infections are loaded into the simulation. As cases become isolated or inactive and no longer cause infections, they are removed from this dataframe.

A companion dataframe, rec_df, is meant to be a complete record of all cases that occurred in the simulation. This object is created by create_record_df and tracks all times as the absolute amount of time passed since the simulation start.

Value

A state_df dataframe object


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