Skip to contents

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

Usage

dzigeom(x, prob, zeroprob = 0, log = FALSE)

pzigeom(q, prob, zeroprob = 0, lower.tail = TRUE, log.p = FALSE)

rzigeom(n, prob, zeroprob = 0)

Arguments

x, q

integer vector of counts

prob

probability of success in each trial, in (0,1]

zeroprob

zero-inflation probability between 0 and 1

log, log.p

logical; return log-density if TRUE

lower.tail

logical; if TRUE, probabilities are \(P[X \le x]\), otherwise, \(P[X > x]\).

n

number of random values to return.

Value

dzigeom gives the probability mass function, pzigeom gives the distribution function, and rzigeom generates random deviates.

Details

This implementation allows for automatic differentiation with RTMB.

$$P(X=k;\,\pi,p_0) = p_0\,\mathbf{1}[k=0] + (1-p_0)\,P_{\mathrm{Geom}}(k;\,\pi),$$ where \(p_0\) is zeroprob. The zeros are a mixture of structural zeros and zeros generated by the geometric itself, so zeroprob is not the probability of observing a zero; see hgeom for the hurdle version, where it is.

See also

Examples

set.seed(123)
x <- rzigeom(5, prob = 0.3, zeroprob = 0.4)
d <- dzigeom(x, prob = 0.3, zeroprob = 0.4)
p <- pzigeom(x, prob = 0.3, zeroprob = 0.4)