Description Usage Arguments Author(s) See Also Examples
View source: R/simulate_contacts.R
Under development. Do not use. This simulator adds contacts to the cases of
an outbreak
object, using user-defined distributions for numbers and
duration of contacts. It returns an outbreaks
object with cases and
contacts, identifying entries in the linelist as cases or contacts, and links
as exposures or transmissions.
1 | simulate_contacts(x, n_contacts, dist_time_to_contact, dist_duration)
|
x |
an |
n_contacts |
a vector of values to be used as average number of contacts; values will be drawn at random from this vector to determine the expected number of contacts for each new case |
dist_time_to_contact |
the distribution of the delay to new exposures, in days after the onset of symptoms |
dist_duration |
the distribution of duration of the exposure period after the first day, i.e. the time interval between the start and the end of the exposure window |
Thibaut Jombart thibautjombart@gmail.com
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 27 28 29 30 31 | ## first simulate an outbreak
## (see example in ?simulate_outbreak)
incubation <- c(0, 1, 1, 1, 1) # numbers = unscaled PMF
infectious_period <- make_disc_gamma(10, 7) # distcrete object
reporting <- function(x) dpois(x, 5) # PMF function
set.seed(1)
x <- simulate_outbreak(R = runif(100, 1, 3), # random values on [1;3]
dist_incubation= incubation,
dist_infectious_period = infectious_period,
dist_reporting = reporting)
## simulate contacts: inputs
## exposure starts 0-2 days post onset
time_to_contact = c(1, 1, 1)
## geom dist for duration of exposure
duration <- function(x) dgeom(x, prob = .9)
x_with_contacts <- simulate_contacts(
x[1:10, ],
n_contacts = 1:10, # 1 to 10 contacts
dist_time_to_contact = time_to_contact,
dist_duration = duration)
## check output
class(x_with_contacts)
dim(x_with_contacts)
head(x_with_contacts)
plot(x_with_contacts)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.