Learn R Programming

VGAM (version 0.7-8)

Zanegbin: Zero-Altered Negative Binomial Distribution

Description

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

Usage

dzanegbin(x, p0, size, prob=NULL, munb=NULL, log = FALSE)
pzanegbin(q, p0, size, prob=NULL, munb=NULL)
qzanegbin(p, p0, size, prob=NULL, munb=NULL)
rzanegbin(n, p0, size, prob=NULL, munb=NULL)

Arguments

x, q
vector of quantiles.
p
vector of probabilities.
n
number of observations. Must be a single positive integer.
size, prob, munb, log
Parameters from the ordinary negative binomial distribution (see dnbinom). Some arguments have been renamed slightly.
p0
Probability of zero, called $p0$. The default value of p0=0 corresponds to the response having a positive negative binomial distribution.

Value

  • dzanegbin gives the density and rzanegbin generates random deviates.

Details

The probability function of $Y$ is 0 with probability p0, else a positive $negative binomial(\mu_{nb}, size)$ distribution.

See Also

zanegbinomial, rposnegbin.

Examples

Run this code
munb = 3
size = 4
p0 = 0.3
x = (-1):7
(i = dzanegbin(x, p0=p0, munb=munb, size=size))
table(rzanegbin(100, p0=p0, munb=munb, size=size))

x = 0:10
barplot(rbind(dzanegbin(x, p0=p0, munb=munb, size=size),
              dnbinom(x, mu=munb, size=size)),
        beside = TRUE, col = c("blue","green"),
        main=paste("ZANB(p0=", p0, ", munb=", munb, ", size=", size, ") (blue) vs",
                        " NB(mu=", munb, ", size=", size, ") (green)", sep=""),
        names.arg = as.character(x))

Run the code above in your browser using DataLab