simulate: CDI Agent-Based Simulation Function

Description Usage Arguments Value Examples

View source: R/Base_Functions.R

Description

Take in the list of all agents and the contact matrix, call the C++ function "propogate" that spreads the infection, and return statistics about how much the infection spreads and to whom it spreads

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
simulate(
  ml_data,
  mod,
  timestep = 24L,
  agents,
  contact_matrix,
  initial_set,
  plot_now = FALSE,
  num,
  secondary_infections,
  hcw_to_pat_infections,
  pat_to_hcw_infections,
  pat_to_pat_infections,
  hcw_to_hcw_infections,
  secondary_patient_infected,
  secondary_hcw_infected,
  R0,
  attack_curve,
  pat_to_hcw,
  hcw_to_pat,
  hcw_to_hcw,
  iters,
  discharged,
  total_pat,
  transmission_dir
)

Arguments

ml_data

The data to be used in the machine learning algorithm to calculate risk of CDI

mod

The machine-learning model to be used to calculate risk of CDI

timestep

Number of iterations for the simulation to loop through

agents

List of all agents in the simulation

contact_matrix

Matrix of contacts between all individual agents

initial_set

Initial set of infected agents

plot_now

TRUE if you want to watch attack rate over time; FALSE if you don't

num

Variable that keeps track of number of timesteps completed

secondary_infections

Variable keeps track of number of secondary infections

hcw_to_pat_infections

Variable keeps track of number of healthcare worker to patient transmissions

pat_to_hcw_infections

Variable keeps track of number of patient to healthcare worker transmissions

pat_to_pat_infections

Variable keeps track of number of patient to patient transmissions

hcw_to_hcw_infections

Variable keeps track of number of healthcare worker to healthcare worker transmissions

secondary_patient_infected

Variable keeps track of number of secondary infections spread to patients

secondary_hcw_infected

Variable keeps track of number of secondary infections spread to healthcare workers

R0

Variable to store the basic reproduction number of the model

attack_curve

Variable to store the attack curve, currently just the total number of secondary infections, in the model

pat_to_hcw

Variable to store number of transmissions from patients to healthcare workers as a vector for later use

hcw_to_pat

Variable to store number of transmissions from healthcare workers to patients as a vector for later use

hcw_to_hcw

Variable to store number of transmissions from healthcare workers to other healthcare workers as a list for later use

iters

Variable to store iteration number as a list for later use

discharged

Variable to store the number of discharged patients

total_pat

Variable to store the total number of patients, initial plus discharged

transmission_dir

Variable containing directory name where the C++ transmission function is stored

Value

Long list containing updated agents and simulation statistics

Examples

1
sim_results <- simulate(ml_data, mod, timestep = 24L, agents, contact_matrix, initial_set, plot_now = FALSE, num, secondary_infections, hcw_to_pat_infections, pat_to_hcw_infections, pat_to_pat_infections, hcw_to_hcw_infections, secondary_patient_infected, secondary_hcw_infected, R0, attack_curve, pat_to_hcw, hcw_to_pat, hcw_to_hcw, iters, discharged, total_pat, transmission_dir)

PippintheFoolhardy/SimFunctions documentation built on Dec. 18, 2021, 7:43 a.m.