X-Git-Url: https://git.nmode.ca/Rnaught/blobdiff_plain/e1c16cc937f241da2adc99c38ad7c9f09d204f9b..HEAD:/R/idea.R diff --git a/R/idea.R b/R/idea.R index 53ba98a..dad4220 100644 --- a/R/idea.R +++ b/R/idea.R @@ -26,7 +26,7 @@ #' @return An estimate of the basic reproduction number (R0). #' #' @references [Fisman et al. (PloS One, 2013)]( -#' https://doi.org/10.1371/journal.pone.0083622) +#' https://doi.org/10.1371/journal.pone.0083622) #' #' @seealso [id()] for a similar method. #' @@ -42,6 +42,13 @@ #' # Obtain R0 when the serial distribution has a mean of three days. #' idea(cases, mu = 3 / 7) idea <- function(cases, mu) { + validate_cases(cases, min_length = 2, min_count = 1) + if (!is_real(mu) || mu <= 0) { + stop("The serial interval (`mu`) must be a number greater than 0.", + call. = FALSE + ) + } + s <- seq_along(cases) / mu x1 <- sum(s)