zinegbinUC: Zero-Inflated Negative Binomial Distribution

ZinegbinR Documentation

Zero-Inflated Negative Binomial Distribution

Description

Density, distribution function, quantile function and random generation for the zero-inflated negative binomial distribution with parameter pstr0.

Usage

dzinegbin(x, size, prob = NULL, munb = NULL, pstr0 = 0, log = FALSE)
pzinegbin(q, size, prob = NULL, munb = NULL, pstr0 = 0)
qzinegbin(p, size, prob = NULL, munb = NULL, pstr0 = 0)
rzinegbin(n, size, prob = NULL, munb = NULL, pstr0 = 0)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

Same as in runif.

size, prob, munb, log

Arguments matching dnbinom. The argument munb corresponds to mu in dnbinom and has been renamed to emphasize the fact that it is the mean of the negative binomial component.

pstr0

Probability of structural zero (i.e., ignoring the negative binomial distribution), called \phi.

Details

The probability function of Y is 0 with probability \phi, and a negative binomial distribution with probability 1-\phi. Thus

P(Y=0) =\phi + (1-\phi) P(W=0)

where W is distributed as a negative binomial distribution (see rnbinom.) See negbinomial, a VGAM family function, for the formula of the probability density function and other details of the negative binomial distribution.

Value

dzinegbin gives the density, pzinegbin gives the distribution function, qzinegbin gives the quantile function, and rzinegbin generates random deviates.

Note

The argument pstr0 is recycled to the required length, and must have values which lie in the interval [0,1].

These functions actually allow for zero-deflation. That is, the resulting probability of a zero count is less than the nominal value of the parent distribution. See Zipois for more information.

Author(s)

T. W. Yee

See Also

zinegbinomial, rnbinom, rzipois.

Examples

munb <- 3; pstr0 <- 0.2; size <- k <- 10; x <- 0:10
(ii <- dzinegbin(x, pstr0 = pstr0, mu = munb, size = k))
max(abs(cumsum(ii) - pzinegbin(x, pstr0 = pstr0, mu = munb, size = k)))
table(rzinegbin(100, pstr0 = pstr0, mu = munb, size = k))

table(qzinegbin(runif(1000), pstr0 = pstr0, mu = munb, size = k))
round(dzinegbin(x, pstr0 = pstr0, mu = munb, size = k) * 1000)  # Similar?

## Not run: barplot(rbind(dzinegbin(x, pstr0 = pstr0, mu = munb, size = k),
                dnbinom(x, mu = munb, size = k)), las = 1,
    beside = TRUE, col = c("blue", "green"), ylab = "Probability",
    main = paste("ZINB(mu = ", munb, ", k = ", k, ", pstr0 = ", pstr0,
                 ") (blue) vs NB(mu = ", munb,
                 ", size = ", k, ") (green)", sep = ""),
    names.arg = as.character(x)) 
## End(Not run)

VGAM documentation built on Sept. 18, 2024, 9:09 a.m.