View source: R/distribution_functions.R
zero_inflate | R Documentation |
Constructs a zero-inflated density function from a given probability density function
zero_inflate(dist, discrete = NULL)
dist |
either a probability density function or a probability mass function |
discrete |
logical; if |
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.
zero-inflated density function with first argument x
, second argument zeroprob
, and additional arguments ...
that will be passed to dist
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.