case_risk: Compute infection risks from past cases

Description Usage Arguments Details Author(s) Examples

Description

This function computes the probability of secondary infections per infected cases, based on their dates of onset and isolation, and on the average reproduction number (i.e. number of secondary cases per index case). Only cases isolated within a defined time window are retained for the analysis. NOTE: this function is experimental and developed for the response to Ebola in North Kivu. Do not use it without consulting the authors first.

Usage

1
2
case_risk(onset, isolation, R, time_period, p_delay,
  reference_day = today())

Arguments

onset

a vector of dates of onset

isolation

a vector of dates of isolation / outcome (when patients are assumed to ' no longer seed infections)

R

the average reproduction number, i.e. number of secondary cases per infected case; can be a single value, or a vector with one value per case (recycled if needed)

time_period

the number of days since the isolation for cases to be included in the analysis

p_delay

function giving the cumulative mass function of the delay from symptom onset to secondary infections (in usual distributions, starting with p e.g. pgeom)

reference_day

the day to use as current date, as a Date object; defaults to the current day

Details

If d(.) is the probability mass function of the delay from onset of the index case to secondary infection, and $R$ the average reproduction number, the average risk of secondary infections is computed as:

risk(t) = R * ∑_{t = onset}^{isolation - 1} w(t)

Author(s)

Thibaut Jombart (thibautjombart@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
isolation <- today()  -  rpois(50, 10)
onset <- isolation - rpois(50, 7)
delay <- function(t) pgeom(t, prob = .2)
risks <- case_risk(onset, isolation, R = 1.2,
                   time_period = 14, p_delay = delay)
risks
df <- data.frame(id = factor(1:50), onset, isolation, risks)
if (require(ggplot2)) {
  ggplot(df, aes(y = id, yend = id)) +
    geom_segment(aes(x = onset, xend = isolation, color = risks),
                 size = 4) +
    geom_vline(aes(xintercept = today())) +
    scale_color_gradientn("Risk 2nd cases", colors = c("#80aaff", "gold", "#b3003b")) +
  labs(title = "Risk and infectious period",
       x = "Infectious period (onset -> isolation)")
}

reconhub/epirisk documentation built on May 3, 2019, 8:36 p.m.