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!