Package 'earlyR'

Title: Estimation of Transmissibility in the Early Stages of a Disease Outbreak
Description: Implements a simple, likelihood-based estimation of the reproduction number (R0) using a branching process with a Poisson likelihood. This model requires knowledge of the serial interval distribution, and dates of symptom onsets. Infectiousness is determined by weighting R0 by the probability mass function of the serial interval on the corresponding day. It is a simplified version of the model introduced by Cori et al. (2013) <doi:10.1093/aje/kwt133>.
Authors: Thibaut Jombart [aut, cre], Anne Cori [aut], Pierre Nouvellet [aut], Janetta Skarp [aut], Zhian N. Kamvar [ctb], Tim Taylor [ctb]
Maintainer: Thibaut Jombart <[email protected]>
License: MIT + file LICENSE
Version: 0.0.5
Built: 2024-11-10 05:46:28 UTC
Source: https://github.com/reconhub/earlyR

Help Index


Estimate the Reproduction Number

Description

This function estimates the (most of the time, 'basic') reproduction number (R) using i) the known distribution of the Serial Interval (delay between primary to secondary onset) and ii) incidence data.

Usage

get_R(x, ...)

## Default S3 method:
get_R(x, ...)

## S3 method for class 'integer'
get_R(
  x,
  disease = NULL,
  si = NULL,
  si_mean = NULL,
  si_sd = NULL,
  max_R = 10,
  days = 30,
  ...
)

## S3 method for class 'numeric'
get_R(x, ...)

## S3 method for class 'incidence'
get_R(x, ...)

Arguments

x

The daily incidence to be used for inferring the reproduction number. Input can be an incidence object, as output by the package incidence, or a vector of numbers indicating daily number of cases. Note that 'zero' incidence should be reported as well (see details).

...

Further arguments to be passed to the methods.

disease

A character string indicating the name of the disease studied. If provided, then si_mean and si_sd will be filled in automatically using value from the literature. Accepted values are: "ebola".

si

A distcrete object (see package distcrete) containing the discretized distribution of the serial interval.

si_mean

The mean of the serial interval distribution. Ignored if si is provided.

si_sd

The standard deviation of the serial interval distribution. Ignored if si is provided.

max_R

The maximum value the reproduction number can take.

days

The number of days after the last incidence date for which the force of infection should be computed. This does not change the estimation of the reproduction number, but will affect projections.

Details

The estimation of R relies on all available incidence data. As such, all zero incidence after the first case should be included in x. When using inidence from the 'incidence' package, make sure you use the argument last_date to indicate where the epicurve stops, otherwise the curve is stopped after the last case. Use as.data.frame to double-check that the epicurve includes the last 'zeros'.

Value

A list with the earlyR class, containing the following components:

  • $incidence: the input incidence, in its original format

  • $R_grid: the grid of R values for which the likelihood has been computed.

  • $R_like: the values of likelihood corresponding to the $R_grid

  • $R_ml: the maximum likelihood estimate of R

  • $dates: the dates for which infectiousness has been computed

  • $lambdas: the corresponding values of force of infection

  • $si: the serial interval, stored as a distcrete object

Author(s)

Thibaut Jombart [email protected]

Examples

if (require(incidence)) {

## example: onsets on days 1, 5, 6 and 12; estimation on day 24
 x <- incidence(c(1, 5, 6, 12), last_date = 24)
 x
 as.data.frame(x)
 plot(x)
 res <- get_R(x, disease = "ebola")
 res
 plot(res)

}

Plot earlyR objects

Description

These functions are designed for plotting earlyR objects, output by the function get_R. It can plot either the likelihood of R values, or the force of infection over time (see argument type). For points, the latter is used.

Usage

## S3 method for class 'earlyR'
plot(x, type = c("R", "lambdas"), scale = "ml", ...)

## S3 method for class 'earlyR'
points(x, scale = 1, ...)

Arguments

x

A earlyR object.

type

The type of graphic to be generated, matching either "R" or "lamdbas"; "R" will plot the likelihood of R values; "lambdas" will plot the force of infection over time; see 'scale' argument to interprete the force of infection.

scale

A numeric value indicating the total number of new cases expected over the time period of the lambdas, or a recognised 'character' string; lambdas will be scaled to correspond to the number of expected cases every day; defaults to 'ml', which tells function to use the maximum likelihood estimate of *R* multiplied by the number of infectious cases

...

Further arguments to be passed to other methods; for the plot of *R*, '...' is passed to 'ggplot2::geom_line()'; for the plot of *lambdas*, '...' is passed to 'ggplot2::geom_bar()'.

Value

A 'ggplot2' object.

if (require(incidence))

## example: onsets on days 1, 5, 6 and 12; estimation on day 24 onset <- c(1, 5, 6, 12) x <- incidence(onset, last_date = 24) x

res <- get_R(x, disease = "ebola") res plot(res) plot(res, "lambdas")

Author(s)

Thibaut Jombart [email protected]


Print method for earlyR objects

Description

This method prints the content of earlyR objects.

Usage

## S3 method for class 'earlyR'
print(x, ...)

Arguments

x

A earlyR object.

...

further parameters to be passed to other methods (currently not used)

Author(s)

Thibaut Jombart ([email protected])


Get a sample of plausible Reproduction Numbers

Description

This function derives a sample of plausible R values from an earlyR object (as returned by get_R). The probability of each returned values of R are directly proportional to their likelihood.

Usage

sample_R(x, n = 100)

Arguments

x

An earlyR object.

n

The number of R values to sample.

Author(s)

Thibaut Jombart [email protected]

Examples

if (require(incidence)) {
 x <- incidence(c(1, 5, 5, 12, 45, 65))
 plot(x)
 res <- get_R(x, disease = "ebola")
 res
 plot(res)

 sample_R(res, 10)
 hist(sample_R(res, 1000), col = "grey", border = "white")
}