sim_generations: Simulate the number of generations between two linked cases...

View source: R/detection.R

sim_generationsR Documentation

Simulate the number of generations between two linked cases based on their serial interval

Description

This is based on Cori et al. 2019 (https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1006554), which works out analytical expectations of the number of unobserved generations between linked cases given a detection probaility.

Usage

sim_generations(
  t_diff,
  si_fun,
  params,
  max_kappa = 100,
  kappa_weights = TRUE,
  known_kappas = NULL,
  sort = TRUE
)

Arguments

t_diff

the observed time differences between linked cases

si_fun

a function for the serial interval with arguments N (the number to draw) and params (a list of parameters for the function), see si_fun_lnorm for an example.

params

a list with parameters for the si_fun function to draw serial intervals

max_kappa

integer, the constrained maximum number of generatios between two linked cases

kappa_weights

boolean, whether to return the simulated generations for each case or the weights (i.e. the proportion of cases separated by 1:max_kappa generations)

known_kappas

vector of known kappas (i.e. if some cases are traced, you know kappa = 1 for these cases)

sort

whether to sort the first column and t_diff to weight towards kappa = 1 to deal with higher sensitivity at higher reporting thresholds

Value

either a vector of the simulated generations or a vector of proportions of 1:max_kappa


mrajeev08/treerabid documentation built on Oct. 15, 2024, 12:14 p.m.