X-Git-Url: https://git.nmode.ca/Rnaught/blobdiff_plain/9c1a5668803e735f034700c55028ffc0146f1e93..5f4889d4df5e94f194ef7f8b839496db04b17f4e:/R/IDEA.R?ds=sidebyside diff --git a/R/IDEA.R b/R/IDEA.R index 7668540..20a9401 100644 --- a/R/IDEA.R +++ b/R/IDEA.R @@ -10,37 +10,31 @@ #' This method is based on an approximation of the SIR model, which is most valid at the beginning of an epidemic. #' The method assumes that the mean of the serial distribution (sometimes called the serial interval) is known. #' The final estimate can be quite sensitive to this value, so sensitivity testing is strongly recommended. -#' Users should be careful about units of time (e.g. are counts observed daily or weekly?) when implementing. +#' Users should be careful about units of time (e.g., are counts observed daily or weekly?) when implementing. #' -#' @param NT Vector of case counts -#' @param mu Mean of the serial distribution (needs to match case counts in time units; for example, if case counts are -#' weekly and the serial distribution has a mean of seven days, then \code{mu} should be set to one, if case -#' counts are daily and the serial distribution has a mean of seven days, then \code{mu} should be set to seven) +#' @param NT Vector of case counts. +#' @param mu Mean of the serial distribution. This needs to match case counts in time units. For example, if case counts +#' are weekly and the serial distribution has a mean of seven days, then \code{mu} should be set to one. If case +#' counts are daily and the serial distribution has a mean of seven days, then \code{mu} should be set to seven. #' -#' @return \code{IDEA} returns a list containing the following components: \code{Rhat} is the estimate of R0 and -#' \code{inputs} is a list of the original input variables \code{NT, mu}. +#' @return \code{IDEA} returns a single value, the estimate of R0. #' #' @examples -#' #' ## ===================================================== ## #' ## Illustrate on weekly data ## #' ## ===================================================== ## #' #' NT <- c(1, 4, 10, 5, 3, 4, 19, 3, 3, 14, 4) #' ## obtain Rhat when serial distribution has mean of five days -#' res1 <- IDEA(NT=NT, mu=5/7) -#' res1$Rhat +#' IDEA(NT=NT, mu=5/7) #' ## obtain Rhat when serial distribution has mean of three days -#' res2 <- IDEA(NT=NT, mu=3/7) -#' res2$Rhat +#' IDEA(NT=NT, mu=3/7) #' #' ## ========================================================= ## #' ## Compute Rhat using only the first five weeks of data ## #' ## ========================================================= ## #' -#' -#' res3 <- IDEA(NT=NT[1:5], mu=5/7) # serial distribution has mean of five days -#' res3$Rhat +#' IDEA(NT=NT[1:5], mu=5/7) # serial distribution has mean of five days #' #' @export IDEA <- function(NT, mu) { @@ -59,6 +53,6 @@ IDEA <- function(NT, mu) { IDEA2 <- TT * sum(y2) - sum(s)^2 IDEA <- exp(IDEA1 / IDEA2) - return(list(Rhat=IDEA, inputs=list(NT=NT, mu=mu))) + return(IDEA) } }