| hgeom | R Documentation |
Probability mass function, distribution function, and random generation for the hurdle (zero-altered) geometric distribution.
dhgeom(x, prob, zeroprob = 0.5, log = FALSE)
phgeom(q, prob, zeroprob = 0.5, lower.tail = TRUE, log.p = FALSE)
rhgeom(n, prob, zeroprob = 0.5)
x, q |
integer vector of counts |
prob |
probability of success in each trial, in (0,1) |
zeroprob |
probability of a zero, between 0 and 1 |
log, log.p |
logical; return log-density if TRUE |
lower.tail |
logical; if |
n |
number of random values to return. |
This implementation allows for automatic differentiation with RTMB.
A hurdle distribution models the zeros and the positive counts as two separate
processes: the probability of a zero is a free parameter, and the positive
counts follow the corresponding zero-truncated distribution. Writing
p_0 for zeroprob,
P(X = 0) = p_0, \qquad
P(X = x) = (1 - p_0)\,\frac{P_{\mathrm{Geom}}(x;\,\pi)}{1 - \pi_0},
\quad x = 1, 2, \ldots
where \pi_0 = P_{\mathrm{Geom}}(0;\,\pi) = \pi is the probability of a zero
under the ordinary geometric.
Unlike zero-inflation, which can only add zeros to those the geometric already
produces, zeroprob here is exactly the probability of a zero and may be
larger or smaller than \pi_0. The two coincide with the ordinary
geometric when zeroprob equals \pi_0.
dhgeom gives the probability mass function, phgeom gives the distribution function, and rhgeom generates random deviates.
Mullahy, J. (1986) Specification and testing of some modified count data models. Journal of Econometrics, 33, 341-365.
zigeom, ztgeom, hnbinom, hpois
set.seed(123)
x <- rhgeom(5, prob = 0.3, zeroprob = 0.4)
d <- dhgeom(x, prob = 0.3, zeroprob = 0.4)
p <- phgeom(x, prob = 0.3, zeroprob = 0.4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.