glmmTMB truncated models with zero inflation

everyone. I am fitting a glmm model using the R library glmmTMB for predicting a count response variable with excess-zeros and overdispersion (nbinom2> Poisson).

Additionally, I am insterested in exploring the zero-inflation component of my sample data, therefore a zero-inflation vs hurdlequestion arises. Even though both approaches are two-component models with finite mixture, two base assumptions between them arises

• hurdle models are those in which the zero vs non-zero component of the count are mechanistically splitted (i.e. you assume mechanism producing the zero part are different from the non-zero part), which mean assuming all your sample zeros are true or structural zeros. Then, a logit model for the zero vs no-zero plus a count model for counts > 0 are presented together.
• zero-inflatedmodels, on the other hand, while also splitting the zero vs non-zero components, allow the count model to produce zero observations (i.e., true zeros), while the zero-inflation component becomes a point-mass extra-zero generator (i.e., false or excess zeros). Those zero counts would represent false abscenses e.g. a sampling error or a mistake in the measurement (maybe you were not paying enough attention...)

Choosing between the two becomes a crucial analytical design conditioning the interpretation of the results, conditional to the study design and tested hypotheses.

I should note that I am adding random effects in my model, and I believe glmmTMBis the only package that can handle all the aspects at once. If that's not the case, please let me know.

When implementing the hurdle/zi in glmmTMB, the argument ziformula = enables the zero-inflation model, while family = truncated_nbinom2() defines the hurdle model

However, I feel puzzled since attempting to fit a hurdle truncated_nbinom2 model yield the following error message:

'y' contains zeros (or values close to zero). Zeros are compatible with a truncated distribution only when zero-inflation is added


Then my model can be defined as follows:

m0 <- glmmTMB(y ~ var1 + ... + varN + (1 | id),
offset = log(offset),
data = df,
family = truncated_nbinom2(),
ziformula= ~ .)


which is producing a nice model that meets my requirements. In fact, it is the only model that i have been able to affectively fit.

I have seen these kind of models in other examples, and it is obvious glmmTMB has specific implementations of zero-inflation with truncated families, but I have never read in the literature about hurdle + zi models as they are always presented as mutually exclussive, focusing on the criteria for selecting and comparing between them

What am I missing here??

1. Is this approach statistically valid?
2. How is the result interpreted? I guess the zero-inflation component is the same as any other zi model. But my conditional model, as a truncated family, should no be able to account for true zero counts and therefore the count model might be biased

I'd love if someone could shed some light into this issue

P.S: i also found some questions regarding prediction with these kind of models, truncated with zero-inflation here

EDIT

As per request, I include a very silly repex that shows the issue

# generate data with 75% zero
y <- tibble(observed = rep(c(1,0,0,0), 25))

# fit the model w/o zero-inflation, then turn to ~1 to fix and run it
mod <- glmmTMB(observed ~ 1,
family = truncated_nbinom2(),
data = y,
ziformula = ~ 0)

summary(mod)

• Are you sure your code is right? formula + (1 | id) does not look right. I would have expected something like formula = response variable ~ predictor variable + ( 1| id) Commented Nov 28, 2023 at 21:38
• Hi, yeah, actually formula would be the wrapper around the full set of variables, it's just i realized I should stress the random effect that I need to include, as it prevents me from using other packages that can't handle zero-inflated random effects models. I'll be editing the post to make this clear Commented Nov 29, 2023 at 9:19
• Can you make a reproducible example? Commented Nov 29, 2023 at 22:17
• Hi Alex. Not sure I can possibly generate a fair repex, but I have been able to find a dummy one which shows the case. It's a simple binomial variable 1/0 with 75% zeros (compatible with my sample), without worrying for the >1 counts and any other covariables. It shows how fitting a zero_truncated family glmmTMB model it forces you to set a zi formula. Then, back to my theoretical question regarding zi vs hurdle models and what interpretation should i be making from this Commented Nov 30, 2023 at 11:01
• I'm not sure this reprex is addressing the question. Because, aren't you fitting with a zero-inflated formula and still getting the error? what happens when you fit m0 with ziformula = ~1? Commented Nov 30, 2023 at 21:52

I think there is some confusion about what the two zero-inflated models actually are. Your two dot point definitions in the question are good. However, there appears to be some confusion in the interpretation and implementation.

ZIP

A zero-inflated model (let's just say Poisson, for example's sake) is a mixture of a Bernoulli and a Poisson. The probability of zero is the probability that the Bernoulli produces a zero, plus the probability that the Bernoulli doesn't produce a zero but the count process does.

You would implement this in glmmTMB like glmmTMB(formula = y ~ count_predictors, ..., family = poisson(), ziformula = ~ zi_predictors).

ZAP

A zero-altered (or Hurdle) model is a two-part distribution, or you could think of it as a mixture of a Bernoulli and a zero-truncated Poisson. The probability of a zero is just the probability that the Bernoulli produces the zero.

You would implement this in glmmTMB like glmmTMB(formula = y ~ count_predictors, ..., family = truncated_poisson(), ziformula = ~ zi_predictors).

Truncated distribution

Note: truncated_poisson is just a truncated distribution. It does not allow zeroes, which is why you were getting an error.

• Alex, this is exaclty was I was trying to understand, thanks a lot. Now I see the point I was missing: both model summaries for the zero part (either zi o hurdle) is just called "zero-inflation", but the interpretation of the coefficients is not the same exactly. Commented Dec 1, 2023 at 12:24
• Regarding your last comment above, correct me if I'm wrong but my understanding is that: the HURDLE bernouilli models the likelyhood that the observed area is a non-zero vs zero count, with the resulring OR above or below 1 increasing/decreasing that "risk". OR > 1 meaning a certain variable is contributing to the likelyhood of a non-zero count Commented Dec 1, 2023 at 12:30
• the HURDLE bernouilli models the likelyhood that the observed area is a non-zero vs zero count - yep (although I'm not sure what you are referring to re: "area"). with the resulting OR above or below 1 increasing/decreasing that "risk" - I guess so? It depends on your context, what "risk" means. I don't think that above/below 1 necessarily means anything - an Odds Ratio of 1 just means 50% chance of a 0, 50% chance of a non-zero Commented Dec 4, 2023 at 21:13
• And the ZI bernouilli is modelling the likelyhood of the observed zero of coming from the count model (i.e. a 'true' zero) vs coming from the zero inflation ('sample zero' or 'false zero') - sort of. That can be derived later, from comparing P(ZI Bernoulli = 0) and P(ZI Bernoulli != 0) * P(Count = 0). Really, it's just modelling the chance that the zero-inflation variable is zero ("false zero" or whatever you want to call it in the context of your analysis). Commented Dec 4, 2023 at 21:16
• But yes - the interpreation is different, depending on the context :) Commented Dec 4, 2023 at 21:16