Zinb {VGAM} | R Documentation |
Density, distribution function, quantile function and random generation
for the zero-inflated negative binomial distribution with parameter phi
.
dzinb(x, phi, size, prob=NULL, munb=NULL, log=FALSE) pzinb(q, phi, size, prob=NULL, munb=NULL) qzinb(p, phi, size, prob=NULL, munb=NULL) rzinb(n, phi, size, prob=NULL, munb=NULL)
x, q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. Must be a single positive integer. |
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.
|
phi |
Probability of zero (ignoring the negative binomial distribution), called
phi.
|
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.
dzinb
gives the density,
pzinb
gives the distribution function,
qzinb
gives the quantile function, and
rzinb
generates random deviates.
The argument phi
is recycled to the required length, and
must have values which lie in the interval [0,1].
Thomas W. Yee
zinegbinomial
,
rnbinom
,
rzipois
.
munb = 3; phi = 0.2; k = 10 x = 0:10 (i = dzinb(x, phi=phi, mu=munb, size=k)) cumsum(i) - pzinb(x, phi=phi, mu=munb, size=k) # Should be 0s table(rzinb(100, phi=phi, mu=munb, size=k)) table(qzinb(runif(1000), phi=phi, mu=munb, size=k)) round(dzinb(x, phi=phi, mu=munb, size=k) * 1000) # Should be similar ## Not run: barplot(rbind(dzinb(x, phi=phi, mu=munb, size=k), dnbinom(x, mu=munb, size=k)), beside = TRUE, col = c("blue","green"), main=paste("ZINB(mu=", munb, ", k=", k, ", phi=", phi, ") (blue) vs negative binomial(mu=", munb, ", k=", k, ") (green)", sep=""), names.arg = as.character(x)) ## End(Not run)