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 |
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.
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, ...)
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, ...)
x |
The daily incidence to be used for inferring the reproduction
number. Input can be an |
... |
Further arguments to be passed to the methods. |
disease |
A character string indicating the name of the disease
studied. If provided, then |
si |
A |
si_mean |
The mean of the serial interval distribution. Ignored if
|
si_sd |
The standard deviation of the serial interval
distribution. Ignored if |
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. |
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'.
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
Thibaut Jombart [email protected]
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) }
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) }
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.
## S3 method for class 'earlyR' plot(x, type = c("R", "lambdas"), scale = "ml", ...) ## S3 method for class 'earlyR' points(x, scale = 1, ...)
## S3 method for class 'earlyR' plot(x, type = c("R", "lambdas"), scale = "ml", ...) ## S3 method for class 'earlyR' points(x, scale = 1, ...)
x |
A |
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()'. |
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")
Thibaut Jombart [email protected]
This method prints the content of earlyR
objects.
## S3 method for class 'earlyR' print(x, ...)
## S3 method for class 'earlyR' print(x, ...)
x |
A |
... |
further parameters to be passed to other methods (currently not used) |
Thibaut Jombart ([email protected])
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.
sample_R(x, n = 100)
sample_R(x, n = 100)
x |
An |
n |
The number of R values to sample. |
Thibaut Jombart [email protected]
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") }
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") }