Tutorials › Generalized Linear Mixed Models (GLMM) › Contrasting Marginal Means And Marginal Variances

Marginal Effects and Population-Averaged Estimates · Tutorial 423 of 698

Contrasting Marginal Means And Marginal Variances

Learn to separate the response-scale mean averaged over random effects from the distinct sources that make up marginal outcome variance.

Advanced 11 min read

What You'll Learn

  • Apply the laws of total expectation and total variance to a GLMM at a fixed covariate pattern.
  • Decompose binary-outcome variance into conditional Bernoulli variation and variation in conditional probabilities.
  • Derive the mean and variance of a Poisson-lognormal mixture.
  • Explain why a binary mixture retains a Bernoulli variance at its marginal mean, while a Poisson mixture can be overdispersed.
  • Identify assumptions and diagnostics relevant to response-scale marginal moments.

Why Marginal Means and Variances Need Separate Attention

A GLMM describes an outcome conditional on covariates and random effects. A population-averaged response-scale mean instead averages the conditional mean over the random-effects distribution. That integration can change the mean because the inverse link is nonlinear. It also contributes to the outcome's marginal variance, but the way it contributes depends on the outcome family.

The distinction is especially instructive for binary and count outcomes. A binary mixture has a variance determined entirely by its marginal success probability. A Poisson mixture, by contrast, can have a variance greater than its marginal mean because its conditional rate varies across random effects. In both cases, marginal variance is a property of the outcome distribution, not the uncertainty in an estimated mean.

General Moment Decomposition

Fix a covariate pattern \(x\), and let \(B\) denote the random effect or random-effects vector for a cluster. Assume the GLMM specifies a conditional outcome distribution given \(B\) and \(x\), and that the stated random-effects distribution is the one over which the population average is defined. Write the conditional mean as \(m(B,x)=E(Y\mid B,x)\) and the conditional variance as \(v(B,x)=\operatorname{Var}(Y\mid B,x)\). Assume these moments exist.

Definition: The response-scale marginal mean is \(M(x)=E_B\{m(B,x)\}\). The response-scale marginal variance is \(V(x)=\operatorname{Var}(Y\mid x)\), where the random effects have been integrated out. Thus \(M(x)\) averages conditional means, whereas \(V(x)\) includes both conditional outcome variation and variation in conditional means across random effects.

The governing identities are the laws of total expectation and total variance:

$$ M(x)=E_B\{m(B,x)\}, \qquad V(x)=E_B\{v(B,x)\}+\operatorname{Var}_B\{m(B,x)\}. $$

This decomposition requires no special link function. It follows directly by adding and subtracting the conditional mean in the squared deviation from the marginal mean.

1
Condition on the random effect.
Write \(Y-M(x)=[Y-m(B,x)]+[m(B,x)-M(x)]\).
2
Square and average.
The expected cross-product is zero, since \(E\{Y-m(B,x)\mid B,x\}=0\). Therefore the expected squared deviation is the sum of the expected conditional squared deviation and the squared deviation of the conditional mean.
3
Identify the two terms.
\(E\{[Y-m(B,x)]^2\mid x\}=E_B\{v(B,x)\}\), and \(E\{[m(B,x)-M(x)]^2\mid x\}=\operatorname{Var}_B\{m(B,x)\}\). Their sum is \(V(x)\).

Binary Outcomes: Variation in Probabilities, Not Extra Bernoulli Variance

For a binary outcome, suppose \(Y\mid B,x\sim\operatorname{Bernoulli}\{p(B,x)\}\), where \(p(B,x)=P(Y=1\mid B,x)\). Then \(m(B,x)=p(B,x)\) and \(v(B,x)=p(B,x)\{1-p(B,x)\}\). Consequently,

$$ M(x)=E_B\{p(B,x)\}, $$

and

$$ V(x)=E_B[p(B,x)\{1-p(B,x)\}]+\operatorname{Var}_B\{p(B,x)\}. $$

Expanding the right-hand side gives \(M(x)-M(x)^2\), so \(V(x)=M(x)\{1-M(x)\}\). A single marginal binary outcome is still Bernoulli, with success probability \(M(x)\). The random effects divide this variance into average conditional Bernoulli variation and variation in success probabilities across clusters; they do not create variance beyond that of a Bernoulli variable with the same marginal mean.

Worked Example: A Binary Random-Intercept Model

At a fixed covariate pattern, suppose the conditional model is logistic with \(\operatorname{logit}\{p(B)\}=-1+B\), and \(B\) equals \(-1\) or \(+1\) with probability \(1/2\) each. This is a hypothetical two-point random-intercept distribution. The conditional response is Bernoulli given \(B\).

When \(B=+1\), the linear predictor is \(0\), so \(p(+1)=1/(1+e^0)=0.5000\). When \(B=-1\), it is \(-2\), so \(p(-1)=1/(1+e^2)\approx0.1192\). Therefore,

$$ M=\frac{0.5000+0.1192}{2}=0.3096. $$

At \(B=0\), the conditional probability would be \(1/(1+e)\approx0.2689\), not \(0.3096\). This illustrates why setting a random effect to its mean is not generally equivalent to averaging predictions over its distribution.

The between-random-effect variance of the conditional probability is

$$ \operatorname{Var}_B(p)= \frac{(0.5000-0.3096)^2+(0.1192-0.3096)^2}{2} \approx 0.03625. $$

The average conditional Bernoulli variance is

$$ E_B\{p(1-p)\} =\frac{0.5000(0.5000)+0.1192(0.8808)}{2} \approx 0.1775. $$

Adding the components gives \(V\approx0.1775+0.03625=0.21375\). Directly, the marginal Bernoulli variance is \(M(1-M)=0.3096(0.6904)\approx0.2138\), with the small displayed difference due to rounding. The decomposition is consistent: random effects explain variation in conditional probabilities, while the total variance remains the Bernoulli variance at the marginal mean.

Count Outcomes: Conditional Poisson Variation Plus Rate Heterogeneity

For a Poisson GLMM, suppose \(Y\mid B,x\sim\operatorname{Poisson}\{\lambda(B,x)\}\). Its conditional mean and variance both equal \(\lambda(B,x)\). The general decomposition becomes

$$ M(x)=E_B\{\lambda(B,x)\}, \qquad V(x)=M(x)+\operatorname{Var}_B\{\lambda(B,x)\}. $$

The first variance component is the average conditional Poisson variance. The second is the variance of the conditional rates across random effects. Unless the rates are constant across the random-effects distribution, the marginal count variance exceeds its mean, so the marginal outcome is not Poisson with mean \(M(x)\).

Result: In a Poisson-lognormal random-intercept model with \(\log\{\lambda(B,x)\}=\eta(x)+B\), \(B\sim N(0,\tau^2)\), and a conditional Poisson outcome, the response-scale marginal moments are \(M(x)=\exp\{\eta(x)+\tau^2/2\}\) and \(V(x)=M(x)+M(x)^2\{\exp(\tau^2)-1\}\). These expressions assume the specified normal random-effect distribution and finite moments.

To justify the result, use the normal moment-generating identity \(E\{\exp(tB)\}=\exp(t^2\tau^2/2)\). It gives \(E(\lambda)=\exp\{\eta+\tau^2/2\}=M\), and \(E(\lambda^2)=\exp(2\eta+2\tau^2)\). Thus \(\operatorname{Var}(\lambda)=E(\lambda^2)-M^2=M^2\{\exp(\tau^2)-1\}\). Substitution into the Poisson variance decomposition yields the stated \(V(x)\).

Worked Example: Marginal Moments in a Poisson-Lognormal Model

Suppose a hypothetical count outcome has conditional distribution \(Y\mid B\sim\operatorname{Poisson}(2e^B)\), with \(B\sim N(0,0.25)\). The conditional mean and variance are both \(2e^B\), so the model satisfies the assumptions of the Poisson decomposition.

The marginal mean is

$$ M=2e^{0.25/2}=2e^{0.125}\approx2.2663 \text{ counts}. $$

The between-random-effect variance of the rate is

$$ \operatorname{Var}(\lambda) =M^2(e^{0.25}-1) =(2e^{0.125})^2(e^{0.25}-1) \approx 1.4588 \text{ counts}^2. $$

The average conditional Poisson variance is \(E(\lambda)=2.2663\) counts squared. Hence

$$ V=2.2662969+1.4588\approx3.7251 \text{ counts}^2. $$

The marginal variance exceeds the marginal mean by about \(1.4588\) counts squared, precisely the contribution from rate heterogeneity. This is not a statement about uncertainty in the estimated mean; it describes the distribution of outcomes after random effects are integrated out.

Worked Example: Discrete Rate Heterogeneity at Two Covariate Values

Consider a hypothetical Poisson model \(\log\{\lambda(B,x)\}=\log(2)+x\log(2)+B\), with \(B=-\log(2)\) or \(+\log(2)\), each with probability \(1/2\). Conditional on \(B\) and \(x\), assume a Poisson outcome.

At \(x=0\), the two conditional rates are \(2e^{-\log(2)}=1\) and \(2e^{\log(2)}=4\) counts. Thus \(M(0)=(1+4)/2=2.5\) counts. The rate variance is \(\{(1-2.5)^2+(4-2.5)^2\}/2=2.25\) counts squared. The total variance is \(V(0)=E(\lambda)+\operatorname{Var}(\lambda)=2.5+2.25=4.75\) counts squared.

At \(x=1\), the rates are \(2\) and \(8\) counts. Therefore \(M(1)=(2+8)/2=5\) counts, the rate variance is \(\{(2-5)^2+(8-5)^2\}/2=9\) counts squared, and \(V(1)=5+9=14\) counts squared. The marginal mean doubles across these covariate values, while the marginal variance rises from \(4.75\) to \(14\) counts squared. The calculations show why a mean comparison alone does not describe how dispersed count outcomes are.

Interpretation, Diagnostics, and Limitations

The formulas rely on the conditional outcome family and random-effects distribution being appropriate for the estimand and data. For the binary case, the conditional response must be Bernoulli; for the count results, it must be conditionally Poisson and the stated random effects must have the required moments. A different conditional distribution changes the \(E_B\{v(B,x)\}\) term. A different random-effects distribution can also change both the marginal mean and the variance.

Useful checks include comparing observed cluster-level outcome patterns with model-based predictions, examining whether conditional residual variation remains systematic, and checking whether the fitted model reproduces the degree of within-cluster heterogeneity relevant to the analysis. For counts, persistent variance beyond the fitted Poisson-lognormal model, excess zeros, or influential clusters can signal misspecification; a large variance by itself does not identify which mechanism caused it. For binary outcomes, the marginal variance at a fixed covariate pattern is fixed by the marginal probability, so it is not an independent diagnostic of extra dispersion.

The main alternatives answer different questions. A conditional GLMM prediction at a specified random effect describes a cluster conditional on that effect; an integrated marginal prediction averages over the specified random-effects distribution. A model directly specified for population-averaged responses can target marginal quantities without interpreting the same conditional random-effects structure. These approaches need not yield the same coefficients or variance assumptions. The formulas here concern response-scale moments at a fixed covariate pattern; they do not by themselves define a target covariate population or account for uncertainty in estimated model parameters.

  • Pitfall: treating the random effect's mean as the marginal prediction. A centered random effect has mean zero, but generally \(E_B\{g^{-1}(\eta+B)\}\ne g^{-1}(\eta)\). Integrate the response-scale conditional mean, rather than simply setting \(B=0\).
  • Pitfall: calling every random-effect contribution “extra variance.” For binary data, the between-probability component is part of the decomposition, but the total remains \(M(1-M)\). For Poisson mixtures, rate heterogeneity adds to the mean-scale variance and can produce marginal overdispersion.
  • Pitfall: confusing outcome variance with standard error. \(V(x)\) describes variation among outcomes under the model. It is not the standard error of an estimated marginal mean or contrast.
Key takeaway: First average the conditional mean over random effects to obtain \(M(x)\); then calculate \(V(x)\) as average conditional variance plus variance of the conditional mean. The second component has a different interpretation for binary and Poisson outcomes.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. For a binary GLMM, what are the two terms in the total-variance decomposition, and what does their sum equal?
  2. A conditional Poisson model has marginal mean \(M=3\) counts and rate variance across random effects equal to \(2\) counts squared. What is its marginal variance?
  3. In the discrete-rate example, why is the marginal variance at \(x=0\) greater than the marginal mean?
  4. Why is a prediction at \(B=0\) generally not the same as a marginal prediction in a nonlinear GLMM?

Solutions. (1) The components are \(E_B[p(1-p)]\), the average conditional Bernoulli variance, and \(\operatorname{Var}_B(p)\), the variation in conditional probabilities. Their sum equals \(M(1-M)\), the variance of a marginal Bernoulli outcome. (2) The Poisson decomposition gives \(V=M+\operatorname{Var}_B(\lambda)=3+2=5\) counts squared. (3) The average conditional Poisson variance is \(2.5\) counts squared and the rate variance is \(2.25\) counts squared, so their sum is \(4.75\), greater than the mean \(2.5\) counts. (4) Nonlinearity means averaging \(g^{-1}(\eta+B)\) over \(B\) generally differs from evaluating \(g^{-1}(\eta+B)\) at \(B=0\), even when \(E(B)=0\).

Clinical Biostats