View source: R/simulate_susceptibles.R
chain_sim_susc | R Documentation |
Simulate a single chain using a branching process while accounting for depletion of susceptibles.
chain_sim_susc(
offspring = c("pois", "nbinom"),
mn_offspring,
disp_offspring,
serial,
t0 = 0,
tf = Inf,
pop,
initial_immune = 0
)
offspring |
offspring distribution: a character string corresponding to the R distribution function. Currently only "pois" & "nbinom" are supported. Internally truncated distributions are used to avoid infecting more people than susceptibles available. |
mn_offspring |
the average number of secondary cases for each case |
disp_offspring |
the dispersion coefficient (var/mean) of the number of secondary cases. Ignored if offspring == "pois". Must be > 1. |
serial |
the serial interval. A function that takes one parameter
( |
t0 |
start time |
tf |
end time |
pop |
the population |
initial_immune |
the number of initial immunes in the population |
This function has a couple of key differences with chain_sim: it can only simulate one chain at a time, it can only handle implemented offspring distributions ("pois" and "nbinom"), it always tracks and returns a data frame containing the entire tree, the maximal length of chains is limited with pop instead of infinite.
a data frame with columns time
, id
(a unique ID for each
individual element of the chain), ancestor
(the ID of the ancestor
of each element), and generation
.
Flavio Finger
chain_sim_susc("pois", mn_offspring = 0.5, serial = function(x) 3, pop = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.