Learn R Programming

VGAM (version 0.8-1)

Zapois: Zero-Altered Poisson Distribution

Description

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

Usage

dzapois(x, lambda, p0 = 0, log = FALSE)
pzapois(q, lambda, p0 = 0)
qzapois(p, lambda, p0 = 0)
rzapois(n, lambda, p0 = 0)

Arguments

x, q
vector of quantiles.
p
vector of probabilities.
n
number of observations. If length(n) > 1 then the length is taken to be the number required.
lambda
Vector of positive means.
p0
Probability of zero, called $p0$. The default value of p0=0 corresponds to the response having a positive Poisson distribution.
log
Logical. Return the logarithm of the answer?

Value

  • dzapois gives the density, pzapois gives the distribution function, qzapois gives the quantile function, and rzapois generates random deviates.

Details

The probability function of $Y$ is 0 with probability p0, else a positive $Poisson(\lambda)$.

See Also

zapoisson.

Examples

Run this code
lambda = 3; p0 = 0.2; x = (-1):7
(ii = dzapois(x, lambda, p0))
max(abs(cumsum(ii) - pzapois(x, lambda, p0)))  # Should be 0
table(rzapois(100, lambda, p0))
table(qzapois(runif(100), lambda, p0))
round(dzapois(0:10, lambda, p0) * 100) # Should be similar

x = 0:10
barplot(rbind(dzapois(x, lambda, p0), dpois(x, lambda)),
        beside = TRUE, col = c("blue","green"),
        main=paste("ZAP(", lambda, ", p0=", p0, ") [blue] vs",
                   " Poisson(", lambda, ") [green] densities", sep=""),
        names.arg = as.character(x), ylab="Probability")

Run the code above in your browser using DataLab