aboutsummaryrefslogtreecommitdiff
path: root/R/idea.R
diff options
context:
space:
mode:
authorNaeem Model <me@nmode.ca>2024-11-02 18:13:28 +0000
committerNaeem Model <me@nmode.ca>2024-11-02 18:13:28 +0000
commit94b4dcd37e662eb1e525dc241817c8dd5d4681fc (patch)
treef5ef5b90bf2307dd28ae946413350e34a159b7fa /R/idea.R
parent9fd931aeeba4ab7bdede1a625f64e7024c2b55aa (diff)
Add input validation to estimators
Diffstat (limited to 'R/idea.R')
-rw-r--r--R/idea.R7
1 files changed, 7 insertions, 0 deletions
diff --git a/R/idea.R b/R/idea.R
index 14ba838..dad4220 100644
--- a/R/idea.R
+++ b/R/idea.R
@@ -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)