Learn R Programming

VGAM (version 0.8-4.1)

Zigeom: Zero-Inflated Geometric Distribution

Description

Density, and random generation for the zero-inflated geometric distribution with parameter pszero.

Usage

dzigeom(x, prob, pszero = 0, log = FALSE)
pzigeom(q, prob, pszero = 0)
qzigeom(p, prob, pszero = 0)
rzigeom(n, prob, pszero = 0)

Arguments

x, q
vector of quantiles.
p
vector of probabilities.
prob
see dgeom.
n
number of observations.
pszero
Probability of structural zero (ignoring the geometric distribution), called $\phi$. The default value corresponds to the response having an ordinary geometric distribution.
log
Logical. Return the logarithm of the answer?

Value

  • dzigeom gives the density, pzigeom gives the distribution function, qzigeom gives the quantile function, and rzigeom generates random deviates.

Details

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

See Also

zigeometric, dgeom.

Examples

Run this code
prob = 0.5; pszero = 0.2; x = (-1):20
(ii = dzigeom(x, prob, pszero))
max(abs(cumsum(ii) - pzigeom(x, prob, pszero))) # Should be 0
table(rzigeom(1000, prob, pszero))

x = 0:10
barplot(rbind(dzigeom(x, prob, pszero), dgeom(x, prob)),
        beside = TRUE, col = c("blue","orange"),
        ylab = "P[Y = y]", xlab = "y", las = 1,
        main = paste("zigeometric(", prob, ", pszero = ", pszero,
                     ") (blue) vs",
                     " geometric(", prob, ") (orange)", sep = ""),
        names.arg = as.character(x))

Run the code above in your browser using DataLab