Given infection probabilities and potential infection times, simulates infections for each individual in `demographics`. Infections are only added while an individual is alive and within their observation period.
simulate_infection_histories(
p_inf,
possible_exposure_times = 1:ncol(p_inf),
demographics
)a vector or data frame of attack rates (infection probabilities) for each possible exposure time and population group
the vector of possible infection times
data frame giving `individual`, `birth`, and `population_group` for each individual. `last_sample` and time-varying demographic values can also be supplied.
A list containing an infection-history matrix and a data frame of empirical attack rates for each population group and exposure time.
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)