Skip to contents

This function generates binned serosurvey data based on an age-and-time-varying FOI model, optionally including seroreversion. This function allows construction of serosurveys with binned age groups, and it generates uncertainty in the distribution of a sample size within an age bin through multinomial sampling.

Usage

simulate_serosurvey_age_and_time_model(
  foi,
  survey_features,
  seroreversion_rate = 0
)

Arguments

foi

A dataframe containing the force of infection (FOI) values for different ages. It should have two columns: 'year', 'age' and 'foi'.

survey_features

A dataframe containing information about the binned age groups and sample sizes for each. It should contain columns: 'age_min', 'age_max', 'sample_size'.

seroreversion_rate

A non-negative value determining the rate of seroreversion (per year). Default is 0.

Value

A dataframe with simulated serosurvey data, including age group information, overall sample sizes, the number of seropositive individuals, and other survey features.

Examples

# specify FOIs for each year
foi_df <- data.frame(
  year = seq(1990, 2009, 1),
  age = seq(1, 20, 1)
) %>%
mutate(foi = rnorm(20 * 20, 0.1, 0.01))
#> Error in data.frame(year = seq(1990, 2009, 1), age = seq(1, 20, 1)) %>%     mutate(foi = rnorm(20 * 20, 0.1, 0.01)): could not find function "%>%"
survey_features <- data.frame(
  age_min = c(1, 3, 15),
  age_max = c(2, 14, 20),
  sample_size = c(1000, 2000, 1500))
serosurvey <- simulate_serosurvey_age_and_time_model(
foi_df, survey_features)
#> Error in eval(expr, envir, enclos): object 'foi_df' not found