Tutorials › Generalized Linear Mixed Models (GLMM) › Random Intercepts in Zero-Inflated GLMMs

Overdispersion and Zero Inflation · Tutorial 547 of 698

Random Intercepts in Zero-Inflated GLMMs

Specify a zero-inflated count model with a group-level random intercept and quantify the within-group dependence it creates.

Advanced 12 min read

What You'll Learn

  • Write the count and zero-inflation components of a zero-inflated GLMM with a group-level random intercept.
  • Distinguish conditional predictions at a given random-intercept value from marginal predictions averaged over groups.
  • Derive the marginal covariance between two counts in the same group.
  • Calculate how random-intercept variance affects the variance and correlation of observed zero-inflated counts.
  • Recognize assumptions, diagnostics, and limitations of a count-component random intercept.

Why Add a Group-Level Intercept?

Repeated counts from the same group may be more alike than counts from different groups. For example, patients in the same clinic may share unmeasured features that affect their event rates. A group-level random intercept represents this shared heterogeneity in the count component of a zero-inflated generalized linear mixed model (GLMM). It allows counts in a group to be conditionally independent given the intercept while still being marginally dependent after that intercept is averaged out.

The key modeling choice is which part of the mixture receives the random intercept. Here it enters the count-rate component only. The probability of a structural zero may depend on covariates, but it has no group-level random effect in the model considered here. The earlier material on Random Effects and Marginal Zero Probabilities provides the general distinction between conditional and marginal probabilities; the focus here is the dependence induced by a shared intercept in the count component.

Model Specification and Assumptions

Definition: Let \(Y_{ig}\) be the count for observation \(i\) in group \(g\). Let \(S_{ig}=1\) indicate that the observation is in the count-generating state, and let \(S_{ig}=0\) indicate a structural zero. Specify \(P(S_{ig}=0)=\pi_{ig}\) and \(P(S_{ig}=1)=q_{ig}=1-\pi_{ig}\), where, for example, \(\operatorname{logit}(\pi_{ig})=\mathbf{z}_{ig}^{\mathsf T}\boldsymbol{\gamma}\). In the count state, \(Y_{ig}\mid S_{ig}=1,b_g\sim\operatorname{Poisson}(\lambda_{ig}(b_g))\), with \(\log\lambda_{ig}(b_g)=\log(e_{ig})+\mathbf{x}_{ig}^{\mathsf T}\boldsymbol{\beta}+b_g\). The offset \(e_{ig}\) is an exposure when one is required. The group intercepts are independent across groups and satisfy \(b_g\sim N(0,\sigma_b^2)\). Thus \(Y_{ig}=0\) when \(S_{ig}=0\); when \(S_{ig}=1\), the count is generated from the Poisson distribution.

The defining assumptions are that the random intercept is shared by observations in its group, the \(b_g\) values are independent draws from the stated normal distribution, and the random intercept is independent of the covariates and zero-state indicators. Conditional on \(b_g\), observations’ zero-state indicators and count outcomes are independent across observations, with the count outcome governed by its own \(\lambda_{ig}(b_g)\). The fixed-effect predictors and offsets must be specified appropriately for the data; in particular, exposure belongs as a log offset when the rate is per unit exposure.

For a fixed group effect \(b_g\), the expected observed count is \(q_{ig}\lambda_{ig}(b_g)\): the count is zero with probability \(\pi_{ig}\), and has Poisson mean \(\lambda_{ig}(b_g)\) with probability \(q_{ig}\). The count intercept therefore shifts the log rate by the same amount for every observation in a group. Increasing \(b_g\) by one multiplies the conditional count rate by \(e\), holding covariates and exposure fixed. It does not directly change \(\pi_{ig}\).

Worked Example: Conditional Rate and Zero Probability

Suppose two hypothetical observations in one group have the same exposure and covariates, giving a count-state rate \(\lambda_{ig}(0)=2.00\) at \(b_g=0\). Let their structural-zero probability be \(\pi_{ig}=0.25\). Calculate the expected observed count and the probability of an observed zero when \(b_g=0\) and when \(b_g=0.40\).

At \(b_g=0\), the count-state rate is \(2.00\), so the expected observed count is \(q_{ig}\lambda_{ig}(0)=0.75(2.00)=1.50\). The probability of an observed zero includes both structural zeros and sampling zeros: \(P(Y_{ig}=0\mid b_g=0)=0.25+0.75e^{-2.00}=0.3515\).

At \(b_g=0.40\), the rate is multiplied by \(e^{0.40}=1.492\), giving \(\lambda_{ig}(0.40)=2.00(1.492)=2.984\). The expected observed count is \(0.75(2.984)=2.238\), and the zero probability is \(0.25+0.75e^{-2.984}=0.2879\). The random intercept changes the count rate and hence the sampling-zero probability, but leaves the structural-zero probability at \(0.25\).

Marginal Means and Within-Group Covariance

A prediction conditional on a particular \(b_g\) describes a group with that random-intercept value. A marginal prediction averages over the distribution of group effects. Put \(a_{ig}=e_{ig}\exp(\mathbf{x}_{ig}^{\mathsf T}\boldsymbol{\beta})\), so that \(\lambda_{ig}(b_g)=a_{ig}e^{b_g}\). Since \(b_g\sim N(0,\sigma_b^2)\), the lognormal moment formula gives \(E(e^{b_g})=e^{\sigma_b^2/2}\). Therefore,

$$ E(Y_{ig})=q_{ig}E\{\lambda_{ig}(b_g)\} =q_{ig}a_{ig}e^{\sigma_b^2/2}. $$

This is generally not the same as the conditional mean at \(b_g=0\), which is \(q_{ig}a_{ig}\). Setting the random effect to zero describes a group at the center of the random-effects distribution; averaging across groups also accounts for the nonlinear exponential link.

For two distinct observations \(i\) and \(j\) in the same group, the shared \(b_g\) induces marginal covariance. Conditional on \(b_g\), the observations are independent, so their conditional covariance is zero. The law of total covariance then gives

$$ \operatorname{Cov}(Y_{ig},Y_{jg}) =E\{\operatorname{Cov}(Y_{ig},Y_{jg}\mid b_g)\} +\operatorname{Cov}\{E(Y_{ig}\mid b_g),E(Y_{jg}\mid b_g)\} =q_{ig}q_{jg}\operatorname{Cov}(\lambda_{ig}(b_g),\lambda_{jg}(b_g)). $$

The first term vanishes by conditional independence. For the second, the two rates share the same \(e^{b_g}\). Using \(E(e^{2b_g})=e^{2\sigma_b^2}\),

$$ \operatorname{Cov}(\lambda_{ig}(b_g),\lambda_{jg}(b_g)) =a_{ig}a_{jg}\left\{e^{2\sigma_b^2}-e^{\sigma_b^2}\right\} =a_{ig}a_{jg}e^{\sigma_b^2}\left(e^{\sigma_b^2}-1\right). $$

Thus, for distinct observations in the same group, \(\operatorname{Cov}(Y_{ig},Y_{jg})=q_{ig}q_{jg}a_{ig}a_{jg}e^{\sigma_b^2}(e^{\sigma_b^2}-1)\). This covariance is nonnegative and is zero if \(\sigma_b^2=0\), provided the model’s conditional independence assumptions hold. Its size depends on the rates and zero probabilities, so a single common correlation is not generally implied when observations have different predictors.

Worked Example: Computing Dependence Between Two Counts

Suppose two hypothetical observations in the same group have \(a_{ig}=2.00\), \(a_{jg}=3.00\), \(q_{ig}=0.80\), and \(q_{jg}=0.70\). Let the random-intercept variance be \(\sigma_b^2=0.25\). Calculate their marginal covariance.

The shared-rate covariance is \(a_{ig}a_{jg}e^{0.25}(e^{0.25}-1)\). Using \(e^{0.25}=1.2840\), this is \(2.00(3.00)(1.2840)(1.2840-1)=2.188\).

The zero-inflated observed-count covariance is therefore \(q_{ig}q_{jg}(2.188)=0.80(0.70)(2.188)=1.225\) counts squared. The positive covariance arises even though the observations are independent conditional on \(b_g\): groups with high intercepts tend to have higher count rates for both observations.

For one observation, the marginal variance also includes both zero inflation and random-intercept variation. Conditional on \(b_g\), a zero-inflated Poisson count has variance \(q_{ig}\lambda_{ig}(b_g)+q_{ig}\pi_{ig}\lambda_{ig}(b_g)^2\). Applying the law of total variance yields

$$ \operatorname{Var}(Y_{ig}) =q_{ig}E(\lambda_{ig})+q_{ig}\pi_{ig}E(\lambda_{ig}^2) +q_{ig}^2\operatorname{Var}(\lambda_{ig}). $$

The final term is the additional variation in the conditional mean caused by differences among groups. The second term reflects the zero-inflated conditional variance contribution involving \(\lambda_{ig}^2\). In particular, these sources should not be conflated: zero inflation and a random intercept can both increase marginal variance, but the random intercept also creates covariance between repeated counts in the same group.

Worked Example: Separating Variance Contributions

Use one hypothetical observation with \(a_{ig}=2.00\), \(q_{ig}=0.80\), \(\pi_{ig}=0.20\), and \(\sigma_b^2=0.25\). Calculate its marginal mean and variance, then compare the variance with a zero-inflated Poisson model that has no random intercept and the same parameters at \(b_g=0\).

The required moments are \(E(\lambda_{ig})=2.00e^{0.125}=2.266\), \(E(\lambda_{ig}^2)=4.00e^{0.50}=6.595\), and \(\operatorname{Var}(\lambda_{ig})=6.595-(2.266)^2=1.459\). The marginal mean is \(0.80(2.266)=1.813\).

The marginal variance is \(0.80(2.266)+0.80(0.20)(6.595)+(0.80)^2(1.459) =1.813+1.055+0.934=3.802\) counts squared. Without a random intercept, the zero-inflated Poisson variance at \(b_g=0\) is \(q_{ig}a_{ig}+q_{ig}\pi_{ig}a_{ig}^2 =0.80(2.00)+0.80(0.20)(2.00)^2=2.240\) counts squared. The larger marginal variance in the random-intercept model reflects averaging over group-specific rates; its marginal mean also differs from the prediction at \(b_g=0\).

Likelihood, Diagnostics, and Alternatives

For a group with observations \(y_{ig}\), the likelihood contribution integrates the conditional likelihood over that group’s random-intercept distribution. In the count component, each observation contributes a zero-inflated probability: for \(y_{ig}=0\), the probability is \(\pi_{ig}+q_{ig}\exp\{-\lambda_{ig}(b_g)\}\); for \(y_{ig}>0\), it is \(q_{ig}\exp\{-\lambda_{ig}(b_g)\}\lambda_{ig}(b_g)^{y_{ig}}/y_{ig}!\). Thus the group likelihood is

$$ L_g=\int \prod_i \left[ \pi_{ig}\mathbb{1}(y_{ig}=0) +q_{ig}\frac{e^{-\lambda_{ig}(b)}\lambda_{ig}(b)^{y_{ig}}}{y_{ig}!} \right] \phi(b;0,\sigma_b^2)\,db, $$

where \(\mathbb{1}(y_{ig}=0)\) equals one for a zero and zero otherwise, and \(\phi\) is the normal density. The product is inside the integral because observations share the same \(b_g\); replacing it with a product of separately integrated probabilities would discard the induced dependence. Estimation typically evaluates this integral numerically.

Useful checks include inspecting observed counts and zero frequencies by group, comparing the fitted model’s group-level patterns with those observed, and checking whether residual patterns remain associated within groups. Very few groups or very little replication within groups may provide weak information about \(\sigma_b^2\). A variance estimate near zero suggests that the data provide little evidence for this source of group heterogeneity, while numerical convergence problems or a highly uncertain variance estimate call for caution. These checks do not establish that the random-effects distribution is correct; they help reveal conspicuous mismatches and weak support.

A zero-inflated model without a random intercept allows structural and sampling zeros but does not represent this shared group heterogeneity. A model with a group-level fixed intercept instead estimates a separate intercept for each observed group and does not describe groups as draws from a population distribution in the same way. The random-intercept model is useful when groups are viewed as sampled from a broader population, but it relies on a distributional assumption and can be difficult to estimate when there are few groups. Other count-distribution choices may be appropriate for different forms of overdispersion; they do not automatically reproduce the within-group dependence implied by a shared intercept.

Common Pitfalls and Practical Limits

  • Calling every zero structural. An observed zero may be a structural zero or a sampling zero from the count distribution. The model assigns probabilities to these routes; the observed value alone does not reveal which route occurred.
  • Assuming the random intercept changes both components. In this specification it changes only the count rate. The zero-inflation probability remains determined by its stated predictor.
  • Interpreting conditional independence as marginal independence. Conditional independence given \(b_g\) does not imply marginal independence. Integrating over the shared group effect gives the positive covariance derived above.
  • Using the zero-random-effect prediction as the population mean. Because of the exponential link, \(E\{\exp(b_g)\}=\exp(\sigma_b^2/2)\), which is greater than one when \(\sigma_b^2>0\). The marginal mean is therefore not generally the prediction at \(b_g=0\).

The model’s assumptions matter as much as its algebra. A normal random-intercept distribution, a Poisson count distribution conditional on the effect, and the stated conditional independence structure may be imperfect approximations. Also, a random intercept captures a shared shift in log rate, not every possible pattern of group heterogeneity. Its estimated association should not be interpreted as evidence that the group effect causes higher counts.

Key takeaway: A count-component random intercept multiplies all count rates in a group by the same group-specific factor. Conditional on that factor, repeated observations can be independent; after averaging over it, they generally have positive covariance. Keep the count-rate effect distinct from the structural-zero probability and distinguish conditional from marginal predictions.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. If \(\sigma_b^2=0\), what does the model imply about the covariance between two distinct observations in the same group, under the stated assumptions?
  2. For a count with \(\pi=0.30\) and \(\lambda(b_g)=2.00\), calculate the conditional probability of an observed zero.
  3. Explain why conditional independence given \(b_g\) does not imply marginal independence.
  4. With \(a=1.50\), \(q=0.80\), and \(\sigma_b^2=0.20\), calculate the marginal mean of one observation.

Solutions. 1. The covariance is zero: the covariance formula contains \(e^{\sigma_b^2}-1\), which is zero when \(\sigma_b^2=0\). 2. The probability is \(\pi+q e^{-\lambda}=0.30+0.70e^{-2.00}=0.3947\). 3. Both conditional means depend on the same random intercept. Averaging over that shared source of variation gives covariance \(q_iq_j\operatorname{Cov}(\lambda_{ig},\lambda_{jg})\), which is generally positive when \(\sigma_b^2>0\). 4. The marginal mean is \(qae^{\sigma_b^2/2}=0.80(1.50)e^{0.10}=1.326\) counts.

Clinical Biostats