Tutorials › Generalized Linear Mixed Models (GLMM) › Moments of the Zero-Inflated Negative Binomial

Overdispersion and Zero Inflation · Tutorial 551 of 698

Moments of the Zero-Inflated Negative Binomial

Learn to calculate and interpret the mean, variance, and zero probability of a zero-inflated negative binomial count from its mixture components.

Advanced 10 min read

What You'll Learn

  • Define the zero-inflated negative binomial as a mixture of structural zeros and negative binomial counts.
  • Derive its mean and variance from the mixture indicator and the negative binomial moments.
  • Calculate the overall probability of zero, including zeros from both components.
  • Check numerical results against limiting cases and conditional calculations.
  • Recognize when random effects require averaging conditional moments rather than plugging in average parameters.

Why Derive the Moments?

A zero-inflated negative binomial model combines two sources of variation: a component that produces zeros with probability \(\pi\), and a negative binomial count component that can itself produce zeros. Its parameters therefore do not directly equal the overall mean or the overall probability of a zero. Deriving these quantities from the mixture makes predictions interpretable and helps check calculations.

Throughout this tutorial, the results are for one observation at fixed covariates and fixed model parameters. The negative binomial parameterization is the NB2 form: its conditional mean is \(\mu\), and its variance is \(\mu+\alpha\mu^2\). The inflation probability is \(\pi\), with \(0\leq \pi\leq 1\), and the dispersion parameter is \(\alpha>0\). Counts are nonnegative integers, \(\mu>0\), and the mixture indicator and negative binomial count are independent.

Definition: Let \(B\) indicate membership in the count component, with \(P(B=1)=1-\pi\) and \(P(B=0)=\pi\). Let \(N\) have a negative binomial distribution with mean \(\mu\) and variance \(\mu+\alpha\mu^2\), independently of \(B\). The zero-inflated count is \(Y=BN\). Thus \(Y=0\) whenever \(B=0\), while \(Y=N\) when \(B=1\). The zero at \(B=0\) is a structural zero in the mixture; the negative binomial component can also generate a zero.

In this parameterization, the negative binomial size is \(r=1/\alpha\). Its probability mass function is

$$ P(N=y)= \frac{\Gamma(y+r)}{\Gamma(r)y!} \left(\frac{r}{r+\mu}\right)^r \left(\frac{\mu}{r+\mu}\right)^y, \qquad y=0,1,2,\ldots . $$

In particular, setting \(y=0\) gives the negative binomial zero probability

$$ q_0=P(N=0) =\left(\frac{r}{r+\mu}\right)^r =(1+\alpha\mu)^{-1/\alpha}. $$

Deriving the Mean and Variance

The mixture indicator provides a direct derivation. Since \(Y=BN\) and \(B\) is independent of \(N\), the mean is the probability of entering the count component multiplied by its mean:

$$ E(Y)=E(BN)=E(B)E(N)=(1-\pi)\mu. $$

For the variance, first calculate the second moment. Because \(B\) is either zero or one, \(B^2=B\), so \(Y^2=B N^2\). The negative binomial second moment is \(E(N^2)=\operatorname{Var}(N)+[E(N)]^2=\mu+\alpha\mu^2+\mu^2\). Therefore,

$$ E(Y^2)=(1-\pi)\{\mu+(\alpha+1)\mu^2\}. $$

Subtracting the square of the mean yields the variance:

$$ \begin{aligned} \operatorname{Var}(Y) &=E(Y^2)-[E(Y)]^2\\ &=(1-\pi)\{\mu+(\alpha+1)\mu^2\}-(1-\pi)^2\mu^2\\ &=(1-\pi)\mu+\{(1-\pi)(\alpha+1)-(1-\pi)^2\}\mu^2\\ &=(1-\pi)\mu+(1-\pi)(\alpha+\pi)\mu^2. \end{aligned} $$

Equivalently, the law of total variance conditions on whether the observation enters the count component. Given \(B=0\), its count is zero; given \(B=1\), its mean and variance are \(\mu\) and \(\mu+\alpha\mu^2\). The component means differ, adding the term \(\pi(1-\pi)\mu^2\) to the within-component variance.

$$ \operatorname{Var}(Y) =(1-\pi)(\mu+\alpha\mu^2)+\pi(1-\pi)\mu^2 =(1-\pi)\mu\{1+(\alpha+\pi)\mu\}. $$
Theorem: For the zero-inflated negative binomial mixture defined above, $$ E(Y)=(1-\pi)\mu,\qquad \operatorname{Var}(Y)=(1-\pi)\mu\{1+(\alpha+\pi)\mu\}, $$ and $$ P(Y=0)=\pi+(1-\pi)(1+\alpha\mu)^{-1/\alpha}. $$ The mean \(\mu\) and zero probability \(q_0\) belong to the negative binomial component; the overall mean and zero probability belong to the mixture.

The zero probability follows by adding the disjoint routes to \(Y=0\): the observation can be in the structural-zero component, or it can enter the count component and the negative binomial count can equal zero. Thus

$$ P(Y=0)=P(B=0)+P(B=1)P(N=0) =\pi+(1-\pi)q_0. $$

For \(y>0\), the mixture has \(P(Y=y)=(1-\pi)P(N=y)\). The probabilities sum to one: the zero probability plus all positive-count probabilities is \(\pi+(1-\pi)\{q_0+(1-q_0)\}=1\).

Worked Example: Computing All Three Moments

Hypothetical setting. Suppose a count model has structural-zero probability \(\pi=0.20\), negative binomial mean \(\mu=3\) counts per observation, and dispersion \(\alpha=0.50\). The parameter restrictions hold: \(0\leq\pi\leq1\), \(\mu>0\), and \(\alpha>0\).

The overall mean is

$$ E(Y)=(1-0.20)(3)=0.80(3)=2.40 $$

counts per observation. For the negative binomial component, the variance is \(3+0.50(3^2)=7.50\) counts squared. The mixture variance is

$$ \begin{aligned} \operatorname{Var}(Y) &=(1-0.20)(3)\{1+(0.50+0.20)(3)\}\\ &=2.40(1+2.10)=2.40(3.10)=7.44 \end{aligned} $$

counts squared. This also follows by adding within- and between-component variance: \(0.80(7.50)+0.20(0.80)(3^2)=6.00+1.44=7.44\).

The negative binomial zero probability is \((1+0.50(3))^{-1/0.50}=2.5^{-2}=0.1600\). Therefore,

$$ P(Y=0)=0.20+0.80(0.1600)=0.3280. $$

The overall chance of a zero is 32.8%, not 20%: the latter is only the probability of belonging to the structural-zero component.

Examples and Useful Checks

Worked Example: Separating the Two Sources of Zeros

Hypothetical setting. Let \(\pi=0.35\), \(\mu=2\) counts per observation, and \(\alpha=0.25\). These values satisfy the mixture and negative binomial parameter restrictions.

Here the negative binomial size is \(r=1/0.25=4\). Its zero probability is

$$ q_0=(1+0.25(2))^{-4}=1.5^{-4}=0.1975. $$

The probability of a zero from the structural component is \(0.35\). The probability of a zero from the count component is \((1-0.35)(0.1975)=0.1284\). These are disjoint events, so the overall zero probability is \(0.35+0.1284=0.4784\), or 47.84%.

The overall mean is \((1-0.35)(2)=1.30\) counts per observation. The negative binomial variance is \(2+0.25(2^2)=3\), so

$$ \operatorname{Var}(Y) =0.65(3)+0.35(0.65)(2^2) =1.95+0.91=2.86 $$

counts squared. The second term is the additional variation from the difference between the zero component's mean of zero and the count component's mean of two.

Worked Example: Checking the Poisson Limit

Hypothetical setting. Compare a zero-inflated negative binomial with \(\pi=0.25\), \(\mu=2\), and \(\alpha=0.50\) to the limiting case in which the count component is Poisson with mean 2. In both cases, the mixture restrictions hold.

For the negative binomial case, the overall mean is \(0.75(2)=1.50\). The variance is

$$ 0.75(2)\{1+(0.50+0.25)(2)\} =1.50(2.50)=3.75 $$

counts squared. The overall zero probability is \(0.25+0.75(1+0.50(2))^{-2}=0.25+0.75(0.25)=0.4375\).

As \(\alpha\) tends to zero, the negative binomial count component tends to a Poisson distribution with variance \(\mu\) and zero probability \(e^{-\mu}\). Keeping \(\pi=0.25\) and \(\mu=2\), the limiting mixture has variance \(0.75(2)+0.25(0.75)(2^2)=1.50+0.75=2.25\) counts squared. Its zero probability is \(0.25+0.75e^{-2}=0.3515\). The mean remains 1.50 counts per observation in both cases. This limiting check confirms that the formulas reduce to the zero-inflated Poisson moments when the count-component overdispersion vanishes.

Interpretation, Diagnostics, and Limitations

The mixture variance has two parts: \((1-\pi)(\mu+\alpha\mu^2)\), the average within-component variance, and \(\pi(1-\pi)\mu^2\), the variance caused by mixing a zero-mean component with a component having mean \(\mu\). Both \(\alpha\) and \(\pi\) contribute to variation beyond the mean, but in different ways. The overall mean is \((1-\pi)\mu\), so interpreting \(\mu\) as the average count across all observations overstates that average whenever \(\pi>0\).

The formula also gives quick checks. When \(\pi=0\), it reduces to the ordinary negative binomial moments. When \(\pi=1\), every observation is zero, and both the mean and variance are zero. For \(0<\pi<1\), the overall zero probability is at least \(\pi\), because the count component may add further zeros. The variance is no smaller than the mean under the stated parameter restrictions:

$$ \operatorname{Var}(Y)-E(Y) =(1-\pi)(\alpha+\pi)\mu^2\geq 0. $$

These checks can expose a calculation or implementation error; they are not, by themselves, evidence that a zero-inflated model is appropriate for a particular data set. A useful model check compares the observed zero frequency with the model-implied zero probability, using fitted parameters and accounting for covariates. A mismatch can signal that the assumed mixture or count distribution does not describe the data well. Agreement in the zero frequency alone does not establish that the mixture is correct.

A frequent mistake is to report \(\pi\) as the model's predicted proportion of zero counts. That reasoning ignores zeros from the negative binomial component. The correction is to calculate \(\pi+(1-\pi)q_0\). Another mistake is to use the negative binomial mean \(\mu\) as the population mean of the mixture; the correct overall mean is \((1-\pi)\mu\).

These moment formulas are conditional on fixed parameters. If the model also has random effects, first use the formulas conditional on those effects. For example, with random effect \(b\), the marginal mean is \(E_b[(1-\pi_b)\mu_b]\), the marginal variance is \(E_b[\operatorname{Var}(Y\mid b)]+\operatorname{Var}(E[Y\mid b])\), and the marginal zero probability is \(E_b[\pi_b+(1-\pi_b)q_{0b}]\). In general, substituting average parameter values into the fixed-parameter formulas does not produce these marginal quantities.

The ordinary negative binomial is the nested case \(\pi=0\); the zero-inflated Poisson is the limiting case \(\alpha=0\). Those comparisons identify useful reference points, but the formulas alone do not determine which model should be used. Moment matching also cannot generally determine whether observed zeros arise from the structural component or the count component: different parameter combinations can yield similar overall moments. In addition, the variance and zero probability depend nonlinearly on \(\mu\), \(\alpha\), and \(\pi\), so uncertainty in fitted parameters matters when reporting predicted moments.

1
Specify the component parameters.
State \(\pi\), the negative binomial mean \(\mu\), and dispersion \(\alpha\), and check their allowed ranges.
2
Calculate the count-component quantities.
Use \(\operatorname{Var}(N)=\mu+\alpha\mu^2\) and \(q_0=(1+\alpha\mu)^{-1/\alpha}\).
3
Combine the mixture components.
Calculate \((1-\pi)\mu\), \((1-\pi)\mu\{1+(\alpha+\pi)\mu\}\), and \(\pi+(1-\pi)q_0\).
4
Check interpretation and limiting cases.
Distinguish the component mean and zero probability from the overall quantities, and verify special cases such as \(\pi=0\).

Check Your Understanding

Use the mixture definitions and formulas above. The answers are included for checking your calculations.

  1. For \(\pi=0.10\), \(\mu=4\), and \(\alpha=1\), calculate the overall mean, variance, and zero probability.
  2. Explain why the overall zero probability is not generally equal to \(\pi\).
  3. Show that setting \(\pi=0\) recovers the negative binomial mean and variance.
  4. If a random effect changes \(\pi\) and \(\mu\) across observations, should the fixed-parameter formula generally be evaluated at their averages to obtain the marginal mean?

Solutions. (1) The mean is \(0.90(4)=3.60\) counts per observation. The variance is \(0.90(4)\{1+(1+0.10)(4)\}=3.60(5.40)=19.44\) counts squared. The negative binomial zero probability is \((1+1(4))^{-1}=0.20\), so the overall zero probability is \(0.10+0.90(0.20)=0.280\). (2) The count component can also produce zeros, giving \(P(Y=0)=\pi+(1-\pi)q_0\); this exceeds \(\pi\) whenever \(q_0>0\) and \(\pi<1\). (3) With \(\pi=0\), the mean is \(\mu\) and the variance is \(\mu\{1+\alpha\mu\}=\mu+\alpha\mu^2\). (4) No. The marginal mean is the expectation of the conditional mean, \(E_b[(1-\pi_b)\mu_b]\), which generally is not equal to \((1-E_b[\pi_b])E_b[\mu_b]\).

Clinical Biostats