Zero-inflated and reparameterised gamma distribution
zigamma2.RdDensity, distribution function, and random generation for the zero-inflated gamma distribution reparameterised in terms of mean and standard deviation.
Usage
dzigamma2(x, mean = 1, sd = 1, zeroprob = 0, log = FALSE)
pzigamma2(q, mean = 1, sd = 1, zeroprob = 0, lower.tail = TRUE, log.p = FALSE)
rzigamma2(n, mean = 1, sd = 1, zeroprob = 0)Arguments
- x, q
vector of quantiles
- mean
mean parameter, must be positive.
- sd
standard deviation parameter, must be positive.
- zeroprob
zero-inflation probability between 0 and 1.
- log, log.p
logical; if
TRUE, probabilities/ densities \(p\) are returned as \(\log(p)\).- lower.tail
logical; if
TRUE(default), probabilities are \(P[X \le x]\), otherwise \(P[X > x]\).- n
number of random values to return
Value
dzigamma2 gives the density, pzigamma2 gives the distribution function, and rzigamma2 generates random deviates.
Details
This implementation allows for automatic differentiation with RTMB.
Uses the same density as zigamma with \(\text{shape} = \mu^2/s^2\) and \(\text{scale} = s^2/\mu\):
$$f(x;\,\mu,s,p_0) = p_0\,\mathbf{1}[x=0] + (1-p_0)\,f_{\mathrm{Gamma}}(x;\,\mu^2/s^2,\,s^2/\mu)\,\mathbf{1}[x>0].$$
Because the continuous part places no mass at zero, zeroprob is exactly
\(P(X = 0)\), and zero-inflation coincides with a hurdle model here. The two
constructions only differ for discrete distributions, where the base distribution
can generate zeros of its own. GAMLSS therefore calls distributions of this type
zero-adjusted rather than zero-inflated, as in its ZAGA family.