ZINB | R Documentation |
Probability mass function and random generation for the zero-inflated negative binomial distribution.
dzinb(x, size, prob, pi, log = FALSE)
pzinb(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE)
qzinb(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE)
rzinb(n, size, prob, pi)
x , q |
vector of quantiles. |
size |
target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer. |
prob |
probability of success in each trial. |
pi |
probability of extra zeros. |
log , log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
p |
vector of probabilities. |
n |
number of observations. If |
Probability density function
f(x) = \left\{\begin{array}{ll}
\pi + (1 - \pi) p^r & x = 0 \\
(1 - \pi) {x+r-1 \choose x} p^r (1-p)^x & x > 0 \\
\end{array}\right.
NegBinomial
x <- rzinb(1e5, 100, 0.6, 0.33)
xx <- -2:200
plot(prop.table(table(x)), type = "h")
lines(xx, dzinb(xx, 100, 0.6, 0.33), col = "red")
xx <- seq(0, 200, by = 0.01)
plot(ecdf(x))
lines(xx, pzinb(xx, 100, 0.6, 0.33), col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.