knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 8,
  fig.height = 6,
  fig.path = "figs/",
  echo = TRUE
)

Travis-CI Build Status

Coverage Status

CRAN_Status_Badge


Installing the package

To benefit from the latest features and bug fixes, install the development, github version of the package using:

devtools::install_github("reconhub/tracer")

Note that this requires the package devtools installed.


What does it do?

The main features of the package include:



Resources


Vignettes

An overview of tracer is provided below in the worked example below. More detailed tutorials will be distributed as vignettes with the package; to list them, type:

vignette(package = "tracer")



Websites

The following websites are available:



Getting help online

Bug reports and feature requests should be posted on github using the issue system. All other questions should be posted on the RECON forum:
http://www.repidemicsconsortium.org/forum/



A quick overview

The following worked example provides a brief overview of the package's functionalities.

Input parameters

tracer needs the following input parameters:

In practice, w will often need to be discretized from a continuous (typically gamma) distribution, of parameters assumed known. We illustrate this procedure using the distcrete package:

lambda <- 2.5
R <- 1.8

library(distcrete)
SI.info <- distcrete("gamma", 1L, w = 0, 10, 0.65)
SI.info
SI <- SI.info$d
plot(SI, xlim = c(0, 50), type = "h", lwd = 3, main = "Serial Interval",
     xlab = "Days after primary onset")

Tracing score for individual contact

The function contact_score will generate a scoring function, which only depends on the date at which the scoring is computed (t), and the date of the last visit to this contact:

library(tracer)
args(contact_score)

For instance, using the parameters defined above, and 3 exposures to cases with onset on days 3, 12, and 34:

f <- contact_score(c(3, 12, 24), R, lambda, SI)
f

## score on day 10:
f(10)

## score on days 24, 25, 26
f(24:26)

## plotting scores over time
plot(f, xlim = c(0, 60), type = "h", col = pal1(100), 
     main = "Tracing score over time", 
     xlab = "Scoring date", ylab = "p(new symptoms)")

Tracing score for group of contacts

The score of a group of individuals is defined as the expected number of new cases on a given day. The function group_score achieves this computation. It generalises contact_score to a set of contacts, stored as a list. Each component of the list is a vector of dates of onset of the source cases. group_score returns a scoring function which only depends on the date at which the scoring is computed (t), and the dates of the last visit of the contacts.:

args(group_score)

We simulate random exposures data for 30 individuals:

set.seed(1)
x <- replicate(30, sample(0:30, sample(1:5), replace = TRUE))
head(x)

g <- group_score(x, R, lambda, SI)
g(c(10,20,30)) # Exp nb of new cases at t=10,20,30


plot(g, xlim = c(0, 100), type = "h", , col = pal1(80), 
     main = "Expected number of new cases", 
     xlab = "Current time", ylab = "Number of cases")

We can extend this to several groups with different sizes and incidence dynamics:

set.seed(1)
x1 <- replicate(30, sample(0:20, sample(1:6), replace = TRUE)) # early wave
x2 <- replicate(140, sample(15:70, sample(1:3), replace = TRUE)) # large middle wave
x3 <- replicate(140, sample(65:80, sample(1:4), replace = TRUE)) # late wave
list_g <- lapply(list(x1, x2, x3), group_score, R, lambda, SI)

pred_nb_cases <- sapply(list_g, function(g) g(1:120))

barplot(t(pred_nb_cases), col = pal1(3), border = "grey", 
        main = "Predicted new cases per groups", xlab = "Current time", 
        ylab = "Number of new cases (stacked)")
axis(side=1)

Contributors (by alphabetic order):

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Maintainer: Thibaut Jombart (thibautjombart@gmail.com)



reconhub/tracer documentation built on May 27, 2019, 4:02 a.m.