estimate_R_Bayes: Estimate effective reproduction number in a Bayesian...

Description Usage Arguments Details Value References Examples

View source: R/estimate_R_Bayes.R

Description

estimate_R_Bayes estimates the effective reproduction number (R_e) using the method of Cori et al, but in a Bayesian framework allowing (a) uncertainty in the serial interval distribution, (b) imputation of missing symptom onset dates, (c) extrapolation of infection dates, and (d) adjusting for delays between diagnosis, symptom onset and infection ("nowcasting")

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
estimate_R_Bayes(
  donset,
  ddiag,
  local,
  t_from,
  SI_mean,
  SI_std,
  t_window = 7,
  t_breaks = NULL,
  maxDate = NULL,
  weights = NULL,
  withInfectTimes = TRUE,
  delayAdjust = TRUE,
  incub_mean = 5.1,
  incub_std = 3,
  date0 = as.Date("2020-1-31"),
  burn = 500,
  iter = 5000
)

Arguments

donset

A vector of symptom onset dates (of class Date).

ddiag

A vector of diagnosis dates (of class Date), of equal length to donset; alternatively NULL if working only with symptom onset dates, see 'Details' section.

local

A logical vector, of equal length to donset indicating whether the case is local or imported.

t_from

Date (of class Date) from which to start estimating effective reproduction numbers (instantaneous or period-specific); see 'Details' section.

SI_mean

Mean for the serial interval distribution, either a single value or two values defining a range; see 'Details' section.

SI_std

Standard Deviation for the serial interval distribution, either a single value or two values defining a range; see 'Details' section.

t_window

Window length for estimating a rolling instantaneous effective reproduction number, see 'Details' section.

t_breaks

Dates defining specific time windows for estimating the effective reproduction number, or NULL for a rolling instantaneous reproduction number, see 'Details' section.

maxDate

Maximum date for which to estimate the effective reproduction number; if NULL, the maximum diagnosis date or symptom onset date is used.

weights

An optional vector of weights for the cases. If NULL (the default), all cases are given equal weights of 1.

withInfectTimes

Extrapolate infection times and use those for estimating the effective reproduction number. If TRUE (the default), a Gamma distribution with mean incub_mean and standard deviation incub_std will be used to impute the infection times.

delayAdjust

Adjust for delays in case ascertainment, using the distribution of times from symptom onset to diagnosis; see 'Details' section

incub_mean

Mean incubation period, used for extrapolating infection times from symptom onset dates.

incub_std

Standard deviation of the incubation period distribution, used for extrapolating infection times from symptom onset dates.

date0

"Date zero" from which to start counting when converting the provided Date vectors to integers for MCMC fitting. Also, imputation of symptom onset and infection dates will start after this date.

burn

Number of burn-in MCMC iterations

iter

Number of sampling MCMC iterations

Details

estimate_R_Bayes() allows flexibility in how to estimate the effective reproduction number R_e, using different function arguments.

At the most basic, a vector of symptom onset dates must be provided (argument donset) and on this basis the R_e will be estimated, if withInfectTimes = FALSE. If withInfectTimes = TRUE (the default), the R_e is estimated on the basis of the infection times imputed using a Gamma distribution with mean incub_mean and standard deviation incub_std.

If a vector of diagnosis dates is also provided (argument ddiag), then donset can have missing values, and these will be imputed using the distribution of the time between symptom onset and diagnosis (assumed to be Gamma, with parameters estimated from the data). In addition, if diagnosis dates are provided, it is possible to use this distribution (of the time between symptom onset and diagnosis) to "nowcast" the epidemic, if the argument delayAdjust is set to TRUE: the number of cases with symptom onset at each time is divided by the probability of ascertainment by date maxDate.

If argument t_breaks is NULL (the default), the function estimates the instantaneous effective reproduction number, using rolling weekly windows between dates t_start and maxDate. The size of the window is adjusted by the argument t_window. Alternatively, t_breaks can contain a vector of dates that define (together with t_breaks and maxDate) specific periods for which the effective reproduction number will be estimated.

Arguments SI_mean and SI_std can receive either one or two values. If one value is provided, the parameter is assumed fixed. If two values are provided, these define a range from which the parameter is randomly sampled (using a uniform distribution). This allows to incorporate uncertainty in estimating the serial interval distribution parameters.

Value

An object of class 'bayEStim'. This is a list containing the following elements:

$model

The fitted model; an object of class rjags

$mcmcSamples

An object of class coda containing the MCMC samples for the various model parameters.

$config

A list of all configuration parameters used in the model.

Objects of class 'bayEStim' can be summarized and plotted, see the respective methods for details.

References

Examples

1
# We'll eventually put some examples here

thlytras/bayEStim documentation built on Aug. 8, 2020, 9:32 p.m.