Understanding Deeply · 10
Two stories behind a zero.
Zero-inflated negative binomial, one idea at a time.
A long model name hides a simple possibility: some people cannot have an event, while others could—but happen to have none. Use invented library visits to explore the two sources of zeros, extra variation and the arithmetic behind the overall result.
One zero, two possible stories
Imagine counting how often 100 fictional people visit an invented library in one month. Some are away for the entire month and cannot visit. Others could visit, but are busy, forget, or simply do not go. Both kinds of people can have a recorded count of zero.
The zero-inflated negative binomial model, or ZINB, represents this with two components. One produces only zeros. The other produces ordinary counts: zero, one, two and so on. In the playground you can reveal the hidden source of a zero because we invented it. An actual researcher usually sees only the recorded count.
Start with the count part
Among people who could visit, an average of four visits does not mean everyone visits four times. Some visit less and some more. A Poisson model links that average to a particular amount of variation: its variance equals its mean.
The negative binomial model allows extra spread. In the NB2 version used here, variance = μ + αμ². With mean μ = 4 and extra-variation parameter α = 1, the variance is 20. Move α while keeping μ fixed: the count distribution can have more zeros and a longer upper tail without changing its mean. “Negative” is part of the distribution’s name; it never produces negative visit counts.
The NB2 definition gives the parameterization used in the calculations. At α = 0, the page uses the Poisson limit.
Now add the people who cannot visit
In the starting recipe, 40% of people are in the always-zero state for this month. We call that probability π. The other 60% belong to the negative binomial count component, with mean four visits. That component already gives a 20% chance of zero visits.
Out of 100 people, the recipe therefore expects 40 zeros from the first component and 12 from the second: 60 × 20% = 12. Total expected zeros are 52, not 40. The formula is P(Y = 0) = π + (1 − π)PNB(Y = 0). The description of zero-inflated mixture models makes this two-source construction explicit.
“Always zero” applies within the model and observation window. It does not mean a person can never visit in their lifetime. The library story gives the state a concrete meaning; a fitted model does not by itself prove that an equally literal subgroup exists.
Which average are we talking about?
The playground displays three answers. The mean in the count component is four, including people in that component who recorded zero. The overall mean is 0.60 × 4 = 2.4 visits per person. Among people observed to visit at least once, the mean is five, because that calculation excludes every zero.
These averages answer different questions. A count-component coefficient concerns the first mean. Reporting it as an effect on the overall mean can be misleading when the zero component also changes. Removing zero observations would change the analysis population and require a model appropriate to the truncated outcome.
Two regression parts can pull in opposite directions
In the third stage, compare fictional settings A and B. A begins with π = 0.40 and μ = 4. Give B a count-component mean ratio of 1.5, so μ becomes 6. Also give B six times the odds of the always-zero state. Its zero-state probability becomes 0.80; an odds ratio of six does not mean six times the probability.
A’s overall mean is 0.60 × 4 = 2.4. B’s is 0.20 × 6 = 1.2. The count component has a 50% higher mean, yet the overall mean is half as large. The interactive table shows the calculation as you change either part.
With a log link, the count coefficient is commonly exponentiated to describe a count-component mean ratio. With a logit link for the always-zero probability, its exponentiated coefficient describes a latent-state odds ratio. Neither alone gives the combined population result. These are hypothetical predictions here, not estimated treatment effects.
Lots of zeros do not automatically require ZINB
Choose “Many zeros, no extra-zero group.” Everyone now belongs to one negative binomial process, but zeros are still common. A small mean and substantial variation can generate that pattern without a separate zero component.
The comparison stage puts Poisson, negative binomial, zero-inflated Poisson and ZINB distributions at the same overall mean. You can also give the plain negative binomial the same overall variance as ZINB. Their shapes can still differ. These are supplied probability distributions, not fitted models or a contest that automatically declares a winner.
Zeileis, Kleiber and Jackman’s count-model paper provides the broader framework. For real analyses, check the full predicted distribution, estimation stability and uncertainty, alongside the scientific reason for a separate zero process. A model’s flexibility is not proof that its mechanism is true.
A hurdle model asks a related question
A hurdle model first separates zero from any positive count. After that hurdle is crossed, its count distribution starts at one. ZINB’s count component can still produce zero. The hurdle model definition makes this distinction precise.
Open the expandable comparison to see that, at the current fixed settings, a suitably parameterized hurdle model can reproduce exactly the same observed distribution as ZINB. A histogram alone cannot reveal which story generated a particular zero.
Keep a missing observation separate from a real zero
No recorded visits could also mean incomplete records or no observation time. That is a data-quality problem to investigate, not an automatic reason to classify someone as a structural zero. Define the event and observation window first; see the missing-data playground for that distinction.
All people, visits and coefficients on this page are invented. Use the guided tour for the intuition and the mathematical bridge for the current calculations. A real analysis needs a defensible design, fitted parameters, uncertainty estimates and checks appropriate to its data.
Start with “Guide me through it,” then try your own settings. Expand the mathematical bridge to trace the results back to their denominators and assumptions.
Explore all Understanding Deeply lessons