twolodzko / extraDistr

Additional univariate and multivariate distributions
51 stars 11 forks source link

zinb gives NAs when size is non-integer #12

Closed gvnmzz closed 6 years ago

gvnmzz commented 6 years ago

rzinb samples NAs when the size parameter is non-integer. In the documentation, it states that, how you expect from rnbinom, the size should be > 0 but need not be integer.

sz <- seq(0.5,5.5,0.5)
rzinb(n = sz, size = sz, prob = 0.5, pi = 0)
## [1] NA  0 NA  0 NA  3 NA  2 NA  6 NA

With the same paramegers, the rnbinom works fine

rnbinom(n = sz, size = sz, prob = 0.5)
## [1] 1 0 1 2 3 6 0 3 8 5 3

It seems that within rng_zinb it throws a warning if the size parameter is non-integer, and automatically returns NA_REAL, while the R::rnbinom function would otherwise work fine also with non-integer size parameter.