zip  R Documentation 
These functions are used to evaluate the zeroinflated Poisson distribution's probability mass function (PMF), cumulative distribution function (CDF), and quantile function (inverse CDF), as well as generate random realizations from the ZIP distribution.
dzip(x, lambda, psi, log = FALSE, recycle = FALSE)
rzip(n, lambda, psi, recycle = FALSE)
pzip(q, lambda, psi, lower.tail = TRUE, log.p = FALSE, recycle = FALSE)
qzip(p, lambda, psi, lower.tail = TRUE, log.p = FALSE, recycle = FALSE)
x , q 
Vector of quantiles at which to evaluate the PMF and CDF, respectively. Should be nonnegative integers. 
lambda 
Vector of means for the count portion of the zeroinflated Poisson distribution. Should be nonnegative. NOTE: This is not the mean of the zeroinflated Poisson distribution; it is the mean of the Poisson component of the mixture distribution. See 'Details.' 
psi 
Vector of zeroinflation probabilities. 
log , log.p 
Logical indicating whether probabilities should be returned
on log scale (for 
recycle 
Logical indicating whether to permit arbitrary recycling of arguments with unequal length. See 'Details' and 'Examples.' 
n 
Number of realizations from the distribution to generate 
lower.tail 
Logical indicating whether probabilities should be

p 
Vector of probabilities at which to evaluate the quantile function. 
The zero inflated Poisson distribution is a mixture of a Poisson and a degenerate pointmass at 0. It has the form
\psi + (1\psi)(\lambda^x e^\lambda)/x!
, with mean
(1\psi)\lambda
. Thus, the parameter lambda
above is the mean of
the Poisson distribution that forms part of the zeroinflated
distribution, not the mean of the ZIP distribution.
recycle
– If FALSE
(default), all arguments must have identical
length, there can be two unique lengths for the arguments, provided that
one of those lengths is 1. For example, lambda = c(1,2,3)
and psi=.5
is acceptable because there are two unique lengths, and one of them is
length 1. However, lambda=c(1,2,3)
and psi=c(.5,.2)
would fail, as
there are two distinct lengths, none of which is 1. If TRUE,
no
additional checks (beyond those in base R's functions) are made to ensure
that the argument vectors have the same length.
dzip
returns the mass function evaluated at x
,
pzip
returns the CDF evaluated at q
, qzip
returns the quantile
function evaluated at p
, and rzip
returns random variates with the
specified parameters.
John Niehaus
Lambert, Diane. "Zeroinflated Poisson regression, with an application to defects in manufacturing." Technometrics 34.1 (1992): 114.
# Unequal lengths, but one of them is length 1, others are same length (3).
# No error.
x = c(1,2,3)
lambda = c(3,4,5)
psi = .1
dzip(x, lambda, psi)
# unequal lengths, at least one of them is not length 1,
# error
## Not run:
x = c(1,2,3)
lambda = c(3,4)
psi = .1
dzip(x, lambda, psi)
## End(Not run)
# unequal lengths, at least one of them is not length 1.
# but set recycle = T to permit arbitrary recycling.
x = c(1,2,3)
lambda = c(3,4)
psi = .1
dzip(x, lambda, psi, recycle=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.