| Zibinom {VGAM} | R Documentation |
Density, distribution function, quantile function and random generation
for the zero-inflated binomial distribution with parameter phi.
dzibinom(x, size, prob, log = FALSE, phi = 0) pzibinom(q, size, prob, lower.tail = TRUE, log.p = FALSE, phi = 0) qzibinom(p, size, prob, lower.tail = TRUE, log.p = FALSE, phi = 0) rzibinom(n, size, prob, phi = 0)
x, q |
vector of quantiles. |
p |
vector of probabilities. |
size |
number of trials. It is the N symbol in the formula
given in zibinomial. |
prob |
probability of success on each trial. |
n |
number of observations. Must be a single positive integer. |
log, log.p, lower.tail |
Arguments that are passed on to
pbinom. |
phi |
Probability of zero (ignoring the binomial distribution), called
phi. The default value of phi=0 corresponds
to the response having an ordinary binomial distribution.
|
The probability function of Y is 0 with probability phi, and Binomial(size, prob) with probability 1-phi. Thus
P(Y=0) = phi + (1-phi) * P(W=0)
where W is distributed Binomial(size, prob).
dzibinom gives the density,
pzibinom gives the distribution function,
qzibinom gives the quantile function, and
rzibinom 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
prob = 0.2
size = 10
phi = 0.5
(i = dzibinom(0:size, size, prob, phi=phi))
cumsum(i) - pzibinom(0:size, size, prob, phi=phi) # Should be 0s
table(rzibinom(100, size, prob, phi=phi))
table(qzibinom(runif(100), size, prob, phi=phi))
round(dzibinom(0:10, size, prob, phi=phi) * 100) # Should be similar
## Not run:
x = 0:size
plot(x, dzibinom(x, size, prob, phi=phi), type="h", ylab="Probability",
main=paste("ZIB(", size, ", ", prob, ", phi=", phi, ") (blue) vs",
" Binomial(", size, ", ", prob, ") (red and shifted slightly)", sep=""),
lwd=2, col="blue", las=1)
lines(x+0.05, dbinom(x, size, prob), type="h", lwd=2, col="red")
## End(Not run)