I´vd tried to fit a zero-inflated negative binomial model with zeroinfl (package pscl):

model.zinb <- zeroinfl(formula = y ~ x1 + x2 + x3, data = data, dist = "negbin")          

a = data.frame(count = data$y)
b = data.frame(count = fitted(model.zinb)  
a$colour = "data"       
b$colour = "fitted"        
hist = rbind(a, b)

ggplot(hist, aes(count, fill = colour)) + 
      geom_histogram(alpha = 0.5, aes(y = ..density..), position = 'identity', bins = 31)   

However, when plotting the count data y and the fitted data fitted(model.zinb), there are somehow almost no counts between 0 and 1 in the fitted model (see plot). It looks like the zeroinfl didn´t work. Since I'm a beginner in this field, I'm hoping to get some advice. Thanks!

enter image description here

  • $\begingroup$ What is your expected behavior? How does this deviate from the expected behavior? $\endgroup$
    – Sycorax
    Aug 30, 2021 at 18:43
  • $\begingroup$ I did expect the model to predict more values closer to zero, since my data is zero-inflated (and fitted(model.zinb) predicts almost no values close to zero as it can be seen in the plot). I'm confused. $\endgroup$
    – user333591
    Aug 30, 2021 at 18:52
  • 1
    $\begingroup$ Or maybe I am misunderstanding something. I know that there are structural zeros (from the zero generating process) and sampling zeros (the count generating process). The fitted(model.zinb) command prints the mean response values of the fitted negative binomial distribution and therefore does not contain the structural zeros, right? So maybe this could be the reasons that no zeros are predicted? $\endgroup$
    – user333591
    Aug 30, 2021 at 20:22
  • 2
    $\begingroup$ Yeah, this description seems correct. I think you were expecting something like posterior draws from the model given these predictors, instead of point estimates per observation. $\endgroup$
    – Sycorax
    Aug 30, 2021 at 21:02

1 Answer 1


The fitted() method for zeroinfl objects returns the fitted mean $\hat \mu$ for each observation which can be pretty far from some of the counts $y$ with substantial probability $f_\mathrm{zeroinfl}(y, \hat \mu)$. This is explained and illustrated in the answers to:

Can a model for non-negative data with clumping at zeros (Tweedie GLM, zero-inflated GLM, etc.) predict exact zeros?

Moreover, instead of overlaying the histogram of the observed counts and expected probabilities (rather than means) it's easier to judge deviations in a so-called hanging rootogram. See: Kleiber & Zeileis (2016). The American Statistician, 70(3), 296–303. doi:10.1080/00031305.2016.1173590. An R implementation is available in the countreg package on R-Forge (successor to the pscl implementation) and illustrated in:

Confused on how to interpret ZINB and Hurdle models


  • $\begingroup$ thanks, that makes sense! $\endgroup$
    – user333591
    Aug 31, 2021 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.