Skip to content

Commit

Permalink
Check that nbinom params are not both zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Aug 22, 2024
1 parent 37b36fd commit 5c7f794
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/simulate.r
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ chain_sim <- function(n, offspring, stat = c("size", "length"), infinite = Inf,
if (!(exists(roffspring_name)) || !is.function(get(roffspring_name))) {
stop("Function ", roffspring_name, " does not exist.")
}
# If both parameters of the negative binomial are zero, you get NaNs
if (roffspring_name == "rnbinom" && all(c(...) == 0)) {
stop(
"The negative binomial parameters must have at least one ",
"non-zero parameter."
)
}

if (!missing(serial)) {
if (!is.function(serial)) {
Expand Down

0 comments on commit 5c7f794

Please sign in to comment.