Skip to contents

Simulates a serological survey using user-specified inputs. The user can specify multiple inputs controlling population demography, simulation time period, observation times for each individual, force of exposure, and various model functions describing the link between infections and observed biomarker quantities. See README for full details.

Usage

runserosim(
  simulation_settings,
  demography = NULL,
  observation_times = NULL,
  foe_pars,
  biomarker_map,
  model_pars,
  exposure_model,
  immunity_model,
  antibody_model,
  observation_model,
  draw_parameters,
  exposure_histories_fixed = NULL,
  VERBOSE = NULL,
  attempt_precomputation = TRUE,
  ...
)

Arguments

simulation_settings

A list of parameters governing the simulation time step settings. Should contain integer entries for t_start and t_end

demography

A tibble of demographic information for each individual in the simulation. At a minimum this tibble requires 1 column (i) where all individuals in the simulation are listed by row. This is used to calculate the sample population size. Additional variables can be added by the user, e.g., birth and removal times, see generate_pop_demography If not specified, the model will assume that birth time is the initial time point and removal time is the final time point across all individuals

observation_times

A tibble for observation times with three variables: 1) i: individual; 2) t: the timepoint of an observation; 3) b: the biomarker being measured. Defaults to NULL, in which case all latent biomarker states are returned

foe_pars

Any object class (usually a 3D array, but may be a list or other object) providing the force of exposure for each exposure ID, group and time, or parameters of the model generating the FOEs

biomarker_map

A tibble specifying the relationship between exposure IDs and biomarker IDs with two variables: 1) exposure_id: the numeric exposure ID; 2) biomarker_id: the numeric biomarker ID

model_pars

A tibble of parameters needed for the antibody kinetics model, immunity model, observation model and the draw_parameters function

exposure_model

A function calculating the probability of exposure given the foe_pars array

immunity_model

A function determining the probability of an exposure leading to successful infection or vaccination for a given individual

antibody_model

A function determining the latent biomarker kinetics as a function of exposure history and within-host kinetics parameters (model_pars)

observation_model

A function generating observed biomarkers as a function of latent biomarkers and observation model parameters (model_pars)

draw_parameters

A function to simulate parameters for the antibody model, immunity model and observation model from model_pars

exposure_histories_fixed

(optional) Defaults to NULL. Otherwise a 3D array indicating the exposure history (1 = exposed, 0 = not exposed) for each individual (dimension 1) at each time (dimension 2) for each exposure ID (dimension 3). Here, users can input pre-specified information if exposure histories are known for an individual

VERBOSE

(optional) Defaults to NULL. An integer specifying the frequency at which simulation progress updates are printed

attempt_precomputation

If TRUE, attempts to perform as much pre-computation as possible for the exposure model to speed up the main simulation code. If FALSE, skips this step, which is advised when the simulation is expected to be very fast anyway

...

Any additional arguments needed

Value

a list containing the following elements: force of exposure, exposure probabilities, exposure histories, antibody states, observed antibody states, and kinetics parameters

Examples

## See package README.