simulate_infection_histories: Simulate infection histories

View source: R/simulate_data.R

simulate_infection_historiesR Documentation

Simulate infection histories

Description

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)

Usage

simulate_infection_histories(
  p_inf,
  possible_exposure_times = 1:ncol(p_inf),
  demographics
)

Arguments

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"

Value

a list with a matrix of infection histories for each individual in ages and the true attack rate for each epoch

See Also

Other simulation_functions: simulate_attack_rates(), simulate_data()

Examples

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)

seroanalytics/serosolver documentation built on Aug. 18, 2024, 12:46 p.m.