I am running a hurdle model using the glmmTMB function. My dependent variable is continuous and >= 0.
I was looking for a function that would allow me to model the binary response in a logistic regression (i.e the zero inflated model) and the non-zero response in a Gamma (log) regression (i.e the conditional model). However, the glmmTMB function does not allow to use the gamma family.
I have two questions:
-
is there a function that allows to run a GLMM with gamma family? I
tried to write my own code to have these two models but I am not
sure about how to predict and calculate CIs. -
Is it appropriate to use a truncated negative binomial family for the conditional (non-zero values) model? I ran the model:
hpm_nb <- glmmTMB(percapita_dia ~ Tipo_residuo + (1|Trip_ID), zi=~Tipo_residuo, all, family=truncated_nbinom2)
The diagnostics plots look good and model predictions are reasonable.
Is it still wrong to have a truncated negative binomial family?
Best Answer
I'm not sure why you say that
glmmTMB
can't handle zero-inflated Gamma responses: the glmmTMB news file says (for version 1.0.0, release 2020-02-03):I'd say it's not crazy to use a truncated negative binomial, but I'd be worried as it doesn't make statistical sense (technically, the likelihood of any non-integer value is 0 ...) (If you really had count data, a zero-inflated NB rather than a hurdle would be a reasonable option ...)
Given the distribution/density functions for each distribution, parameterized in terms of the mean $\mu$ and a shape/dispersion parameter ($k$ for NB, $a$ for Gamma):
$$ \textrm{NB}: \qquad \frac{(k/(k+\mu))^k}{\Gamma(k)} \cdot \frac{\Gamma(k+x)}{x!} \cdot (\mu/(k+\mu))^x $$
$$ \textrm{Gamma}: \qquad \frac{1}{(\mu/a)^a \Gamma(a)} \cdot x^{a-1} \cdot e^{-(x/(\mu/a))} $$
I think you may? be able to show that NB converges approximately to Gamma for large $x$ (but someone better/more dedicated than I am will need to do the math ...)
An empirical demonstration (not "proof"!)
This definitely doesn't work for small mean (try it with mean=4 rather than 100 ...)