]>
nmode's Git Repositories - Rnaught/blob - R/idea.R
53ba98aa5f9181781765ae8edaceba17badee366
1 #' Incidence Decay and Exponential Adjustment (IDEA)
3 #' This function implements a least squares estimation method of R0 due to
4 #' Fisman et al. (PloS One, 2013). See details for implementation notes.
6 #' This method is closely related to that implemented in [id()]. The method is
7 #' based on an incidence decay model. The estimate of R0 is the value which
8 #' minimizes the sum of squares between observed case counts and case counts
9 #' expected under the model.
11 #' This method is based on an approximation of the SIR model, which is most
12 #' valid at the beginning of an epidemic. The method assumes that the mean of
13 #' the serial distribution (sometimes called the serial interval) is known. The
14 #' final estimate can be quite sensitive to this value, so sensitivity testing
15 #' is strongly recommended. Users should be careful about units of time (e.g.,
16 #' are counts observed daily or weekly?) when implementing.
18 #' @param cases Vector of case counts. The vector must be of length at least two
19 #' and only contain positive integers.
20 #' @param mu Mean of the serial distribution. This must be a positive number.
21 #' The value should match the case counts in time units. For example, if case
22 #' counts are weekly and the serial distribution has a mean of seven days,
23 #' then `mu` should be set to `1`. If case counts are daily and the serial
24 #' distribution has a mean of seven days, then `mu` should be set to `7`.
26 #' @return An estimate of the basic reproduction number (R0).
28 #' @references [Fisman et al. (PloS One, 2013)](
29 #' https://doi.org/10.1371/journal.pone.0083622)
31 #' @seealso [id()] for a similar method.
37 #' cases <- c(1, 4, 10, 5, 3, 4, 19, 3, 3, 14, 4)
39 #' # Obtain R0 when the serial distribution has a mean of five days.
40 #' idea(cases, mu = 5 / 7)
42 #' # Obtain R0 when the serial distribution has a mean of three days.
43 #' idea(cases, mu = 3 / 7)
44 idea
<- function(cases
, mu
) {
45 s
<- seq_along(cases
) / mu
51 y1
<- x2
* sum(x3
/ s
) - x1
* sum(x3
)
52 y2
<- x2
* length(cases
) - x1^
2