zero_inflate {LaMa} | R Documentation |
Zero-inflated density constructer
Description
Constructs a zero-inflated density function from a given probability density function
Usage
zero_inflate(dist, discrete = NULL)
Arguments
dist |
either a probability density function or a probability mass function |
discrete |
logical; if |
Details
The definition of zero-inflation is different for discrete and continuous distributions.
For discrete distributions with p.m.f. f
and zero-inflation probability p
, we have
\Pr(X = 0) = p + (1 - p) \cdot f(0),
and
\Pr(X = x) = (1 - p) \cdot f(x), \quad x > 0.
For continuous distributions with p.d.f. f
, we have
f_{\text{zinfl}}(x) = p \cdot \delta_0(x) + (1 - p) \cdot f(x),
where \delta_0
is the Dirac delta function at zero.
Value
zero-inflated density function with first argument x
, second argument zeroprob
, and additional arguments ...
that will be passed to dist
.
Examples
dzinorm <- zero_inflate(dnorm)
dzinorm(c(NA, 0, 2), 0.5, mean = 1, sd = 1)
zipois <- zero_inflate(dpois)
zipois(c(NA, 0, 1), 0.5, 1)