Skip to contents

The serial interval is the time between the onset of symptoms in an infector-infectee pair. This function computes the serial interval statistics from a list of transmission trees.

Usage

get_si(
  trees,
  date_suffix = "date",
  stats = list(mean = mean, lwr = function(x) quantile(x, 0.025, na.rm = TRUE), upr =
    function(x) quantile(x, 0.975, na.rm = TRUE))
)

Arguments

trees

A list of data frames, generated by get_trees. It should contain information about the dates of onset.

date_suffix

A string indicating the suffix for date of onset columns. Default is "date", which means the columns should be named from_date and to_date.

stats

A list of functions to compute statistics. Default is:

  • mean: the mean serial interval.

  • lwr: the 2.5th percentile (lower quantile).

  • upr: the 97.5th percentile (upper quantile).

Each function should take a numeric vector as input and return a single numeric value.

Value

A data frame with serial interval statistic

See also

get_trees for generating a list of transmission trees.

Examples

trees <- get_trees(out, date = linelist$onset)
si_stats <- get_si(trees)
str(si_stats)
#> 'data.frame':	9 obs. of  4 variables:
#>  $ x   : num  -2 -1 0 1 2 3 4 5 6
#>  $ mean: num  0.0369 0.0391 0.0391 0.2548 0.672 ...
#>  $ lwr : num  0.037 0.037 0.037 0.222 0.63 ...
#>  $ upr : num  0.037 0.0741 0.0741 0.2963 0.7037 ...