Learn R Programming

VGAM (version 0.8-3)

Zipois: Zero-Inflated Poisson Distribution

Description

Density, distribution function, quantile function and random generation for the zero-inflated Poisson distribution with parameter phi.

Usage

dzipois(x, lambda, phi = 0, log = FALSE)
pzipois(q, lambda, phi = 0)
qzipois(p, lambda, phi = 0)
rzipois(n, lambda, phi = 0)

Arguments

x, q
vector of quantiles.
p
vector of probabilities.
n
number of observations. Must be a single positive integer.
lambda
Vector of positive means.
phi
Probability of zero (ignoring the Poisson distribution), called $\phi$. The default value of $\phi = 0$ corresponds to the response having an ordinary Poisson distribution.
log
Logical. Return the logarithm of the answer?

Value

  • dzipois gives the density, pzipois gives the distribution function, qzipois gives the quantile function, and rzipois generates random deviates.

Details

The probability function of $Y$ is 0 with probability $\phi$, and $Poisson(\lambda)$ with probability $1-\phi$. Thus $$P(Y=0) =\phi + (1-\phi) P(W=0)$$ where $W$ is distributed $Poisson(\lambda)$.

See Also

zipoisson, dpois, rzinegbin.

Examples

Run this code
lambda = 3; phi = 0.2; x = (-1):7
(ii = dzipois(x, lambda, phi))
max(abs(cumsum(ii) - pzipois(x, lambda, phi))) # Should be 0
table(rzipois(100, lambda, phi))

table(qzipois(runif(100), lambda, phi))
round(dzipois(0:10, lambda, phi) * 100) # Should be similar

x = 0:10
barplot(rbind(dzipois(x, lambda, phi), dpois(x, lambda)),
        beside = TRUE, col = c("blue","green"),
        main = paste("ZIP(", lambda, ", phi = ", phi, ") (blue) vs",
                     " Poisson(", lambda, ") (green)", sep = ""),
        names.arg = as.character(x))

Run the code above in your browser using DataLab