ZIP function

Zero-inflated Poisson distribution

Zero-inflated Poisson distribution

Probability mass function and random generation for the zero-inflated Poisson distribution.

dzip(x, lambda, pi, log = FALSE) pzip(q, lambda, pi, lower.tail = TRUE, log.p = FALSE) qzip(p, lambda, pi, lower.tail = TRUE, log.p = FALSE) rzip(n, lambda, pi)

Arguments

  • x, q: vector of quantiles.

  • lambda: vector of (non-negative) means.

  • pi: probability of extra zeros.

  • log, log.p: logical; if TRUE, probabilities p are given as log(p).

  • lower.tail: logical; if TRUE (default), probabilities are P[Xx]P[X \le x]

    otherwise, P[X>x]P[X > x].

  • p: vector of probabilities.

  • n: number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability density function

f(x)={π+(1π)eλx=0(1π)λxeλx!x>0f(x)=[ifx=0:]π+(1π)exp(λ)[else:](1π)dpois(x,lambda) f(x) = \left\{\begin{array}{ll}\pi + (1 - \pi) e^{-\lambda} & x = 0 \\(1 - \pi) \frac{\lambda^{x} e^{-\lambda}} {x!} & x > 0 \\\end{array}\right.f(x) = [if x = 0:] \pi + (1-\pi) * exp(-\lambda) [else:] (1-\pi) * dpois(x, lambda)

Examples

x <- rzip(1e5, 6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzip(xx, 6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzip(xx, 6, 0.33), col = "red")

See Also

Poisson

  • Maintainer: Tymoteusz Wolodzko
  • License: GPL-2
  • Last published: 2023-11-30