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