View source: R/simulate_data.R
simulate_infection_histories | R Documentation |
Given a vector of infection probabilities and potential infection times, simulates infections for each element of ages (ie. each element is an individual age. Only adds infections for alive individuals)
simulate_infection_histories(
p_inf,
possible_exposure_times = 1:ncol(p_inf),
demographics
)
p_inf |
a vector of attack rates (infection probabilities) for each year |
possible_exposure_times |
the vector of possible infection times |
demographics |
data frame giving the population group, birth and last_sample time for each individual. Optionally can set these values for all "time" |
a list with a matrix of infection histories for each individual in ages and the true attack rate for each epoch
Other simulation_functions:
simulate_attack_rates()
,
simulate_data()
possible_exposure_times <- seq_len(25)
p_inf <- simulate_attack_rates(possible_exposure_times,n_groups=2)
n_indiv <- 100
demographics <- data.frame(individual = 1:n_indiv,birth=sample(1:5,n_indiv,replace=TRUE),population_group=c(rep(1,n_indiv/2),rep(2,n_indiv/2)))
inf_hist <- simulate_infection_histories(p_inf, possible_exposure_times, demographics)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.