Density function, distribution function, quantile function and random
generation for the Zero-Modified Negative Binomial distribution with
parameters size
and prob
, and arbitrary probability at
zero p0
.
dzmnbinom(x, size, prob, p0, log = FALSE)
pzmnbinom(q, size, prob, p0, lower.tail = TRUE, log.p = FALSE)
qzmnbinom(p, size, prob, p0, lower.tail = TRUE, log.p = FALSE)
rzmnbinom(n, size, prob, p0)
dzmnbinom
gives the (log) probability mass function,
pzmnbinom
gives the (log) distribution function,
qzmnbinom
gives the quantile function, and
rzmnbinom
generates random deviates.
Invalid size
, prob
or p0
will result in return
value NaN
, with a warning.
The length of the result is determined by n
for
rzmnbinom
, and is the maximum of the lengths of the
numerical arguments for the other functions.
vector of (strictly positive integer) quantiles.
vector of quantiles.
vector of probabilities.
number of observations. If length(n) > 1
, the length is
taken to be the number required.
target for number of successful trials, or dispersion parameter. Must be positive, need not be integer.
parameter. 0 < prob <= 1
.
probability mass at zero. 0 <= p0 <= 1
.
logical; if TRUE
, probabilities
logical; if TRUE
(default), probabilities are
Vincent Goulet vincent.goulet@act.ulaval.ca
The zero-modified negative binomial distribution with size
prob
p0
The mean is
In the terminology of Klugman et al. (2012), the zero-modified
negative binomial is a member of the
The special case p0 == 0
is the zero-truncated negative
binomial.
The limiting case size == 0
is the zero-modified logarithmic
distribution with parameters 1 - prob
and p0
.
Unlike the standard negative binomial functions, parametrization
through the mean mu
is not supported to avoid ambiguity as
to whether mu
is the mean of the underlying negative binomial
or the mean of the zero-modified distribution.
If an element of x
is not integer, the result of
dzmnbinom
is zero, with a warning.
The quantile is defined as the smallest value
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
dnbinom
for the negative binomial distribution.
dztnbinom
for the zero-truncated negative binomial
distribution.
dzmgeom
for the zero-modified geometric and
dzmlogarithmic
for the zero-modified logarithmic, which
are special cases of the zero-modified negative binomial.
## Example 6.3 of Klugman et al. (2012)
p <- 1/(1 + 0.5)
dzmnbinom(1:5, size = 2.5, prob = p, p0 = 0.6)
(1-0.6) * dnbinom(1:5, 2.5, p)/pnbinom(0, 2.5, p, lower = FALSE) # same
## simple relation between survival functions
pzmnbinom(0:5, 2.5, p, p0 = 0.2, lower = FALSE)
(1-0.2) * pnbinom(0:5, 2.5, p, lower = FALSE) /
pnbinom(0, 2.5, p, lower = FALSE) # same
qzmnbinom(pzmnbinom(0:10, 2.5, 0.3, p0 = 0.1), 2.5, 0.3, p0 = 0.1)
Run the code above in your browser using DataLab