sim_contacts | R Documentation |
Simulate contacts for an infectious disease outbreak
sim_contacts(
contact_distribution = function(x) stats::dpois(x = x, lambda = 2),
infectious_period = function(x) stats::rlnorm(n = x, meanlog = 2, sdlog = 0.5),
prob_infection = 0.5,
outbreak_start_date = as.Date("2023-01-01"),
anonymise = FALSE,
outbreak_size = c(10, 10000),
population_age = c(1, 90),
contact_tracing_status_probs = c(under_followup = 0.7, lost_to_followup = 0.2, unknown
= 0.1),
config = create_config()
)
contact_distribution |
A The function can be defined or anonymous. The function must have a single
argument in the form of an An The default is an anonymous function with a Poisson probability mass function
( |
infectious_period |
A The function can be defined or anonymous. The function must return a vector of randomly generated real numbers representing sampled infectious periods. The function must have a single argument, the number of random infectious periods to generate. An The default is an anonymous function with a lognormal distribution random
number generator ( |
prob_infection |
A single |
outbreak_start_date |
A |
anonymise |
A |
outbreak_size |
A |
population_age |
Either a |
contact_tracing_status_probs |
A named |
config |
A list of settings to adjust the randomly sampled delays and
Ct values. See |
A contacts <data.frame>
.
The structure of the output is:
from
character
column with name of case.
to
character
column with name of contacts of case.
age
integer
with age of infectee.
sex
character
column with either "m"
or "f"
for the sex
of the contact.
date_first_contact
<Date>
column for the first contact between
case and contacts.
date_last_contact
<Date>
column for the last contact between
case and contacts.
was_case
logical
boolean column with either TRUE
or FALSE
for if the contact becomes a case.
status
character
column with the status of each contact. By
default it is either "case"
, "under_followup"
"lost_to_followup"
, or
"unknown"
.
Joshua W. Lambert, Carmen Tamayo
# quickly simulate contact tracing data using the function defaults
contacts <- sim_contacts()
head(contacts)
# to simulate more realistic contact tracing data load epiparameters from
# {epiparameter}
library(epiparameter)
contact_distribution <- epiparameter(
disease = "COVID-19",
epi_name = "contact distribution",
prob_distribution = create_prob_distribution(
prob_distribution = "pois",
prob_distribution_params = c(mean = 2)
)
)
infectious_period <- epiparameter(
disease = "COVID-19",
epi_name = "infectious period",
prob_distribution = create_prob_distribution(
prob_distribution = "gamma",
prob_distribution_params = c(shape = 1, scale = 1)
)
)
contacts <- sim_contacts(
contact_distribution = contact_distribution,
infectious_period = infectious_period,
prob_infection = 0.5
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.