Tutorials › Generalized Linear Mixed Models (GLMM) › Marginal Contrasts From Integrated Predictions

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

Marginal Contrasts From Integrated Predictions

Calculate and interpret differences or ratios of integrated GLMM predictions at specified covariate settings, including their uncertainty.

Advanced 12 min read

What You'll Learn

  • Define a population-averaged contrast from two covariate settings and a shared random-effects distribution.
  • Calculate integrated predictions and contrast them on the response scale.
  • Distinguish a difference, a ratio, and a conditional contrast.
  • Use the delta method to quantify uncertainty while accounting for covariance between predictions.
  • Identify when numerical integration, model assumptions, or the choice of covariate settings can undermine interpretation.

From Integrated Predictions to Contrasts

A population-averaged effect compares expected outcomes after averaging over the random effects, rather than fixing a cluster effect at a particular value. Often the quantity of interest is not either integrated prediction by itself, but a contrast between predictions at two specified covariate settings. The contrast might be an additive difference, measured in outcome units, or a ratio, which is unitless when both predictions are on the same scale.

The settings define what is being compared. For example, they may differ in a treatment indicator while sharing the same values of other covariates. The random effects are integrated over the same assumed distribution at both settings. This is a comparison of model-based expected outcomes; by itself, it does not establish a causal effect.

Definition: Let \(m(\mathbf{x})\) be the integrated mean at covariate setting \(\mathbf{x}\), obtained by averaging the conditional mean over the random-effects distribution. For two settings \(\mathbf{x}_1\) and \(\mathbf{x}_0\), the population-averaged difference is \(m(\mathbf{x}_1)-m(\mathbf{x}_0)\). If both means are positive, the population-averaged ratio is \(m(\mathbf{x}_1)/m(\mathbf{x}_0)\). The settings, response scale, and random-effects distribution are part of the definition of each contrast.

For a GLMM with conditional mean \(h(\mathbf{x},\mathbf{b})=g^{-1}\{\eta(\mathbf{x},\mathbf{b})\}\), where \(g\) is the link function, the integrated mean under random-effects distribution \(F_{\mathbf{b}}\) is

$$ m(\mathbf{x})=\int h(\mathbf{x},\mathbf{b})\,dF_{\mathbf{b}}(\mathbf{b}). $$

With model parameters estimated by \(\hat{\boldsymbol{\theta}}\), calculate \(\hat{m}(\mathbf{x}_1)\) and \(\hat{m}(\mathbf{x}_0)\) using the fitted model and then take their difference or ratio. Integration generally happens before taking the contrast: the result is not obtained by contrasting linear predictors and then applying the inverse link. Nor does setting \(\mathbf{b}=\mathbf{0}\) generally give an integrated mean.

Worked Examples

Worked Example: An Integrated Difference in a Logistic Random-Intercept Model

Suppose a hypothetical binary-outcome model has conditional probability \(P(Y=1\mid x,b)=\operatorname{logit}^{-1}(-1+0.8x+b)\), with a random intercept \(b\sim N(0,0.36)\). Compare settings \(x=1\) and \(x=0\). For a transparent approximation to the normal integral, use the three-point rule with nodes \(b=0,\pm\sqrt{3}(0.6)\) and weights \(2/3,1/6,1/6\). The approximation is a numerical quadrature calculation, not an exact logistic-normal formula.

The nodes are approximately \(0\) and \(\pm1.0392\). At \(x=0\), the conditional probabilities at these nodes are approximately \(0.2689\), \(0.5098\), and \(0.1150\), respectively. Thus

$$ \hat m(0)\approx \frac{2}{3}(0.2689)+\frac{1}{6}(0.5098)+\frac{1}{6}(0.1150)=0.2834. $$

At \(x=1\), the corresponding linear predictors are \(-0.2\), \(0.8392\), and \(-1.2392\), giving probabilities approximately \(0.4502\), \(0.6983\), and \(0.2246\). Therefore

$$ \hat m(1)\approx \frac{2}{3}(0.4502)+\frac{1}{6}(0.6983)+\frac{1}{6}(0.2246)=0.4539. $$

The estimated population-averaged difference is \(0.4539-0.2834=0.1705\), or about 17.05 percentage points in predicted event probability between these settings under the model. The integration averages conditional probabilities, not linear predictors. The random-intercept distribution and the quadrature accuracy are assumptions and numerical choices that should be checked in an actual analysis.

Worked Example: A Ratio of Integrated Means With a Log Link

Consider a hypothetical positive-outcome model with conditional mean \(E(Y\mid A,b)=\exp(0.4+0.3A+b)\), where \(b\sim N(0,0.25)\). Compare \(A=1\) with \(A=0\). Here the random intercept is Gaussian and the log link permits an exact integration.

For a normal random variable with mean zero and variance \(v\), \(E\{\exp(b)\}=\exp(v/2)\). Consequently,

$$ m(A)=\exp(0.4+0.3A+0.25/2). $$

At \(A=0\), \(\hat m(0)=\exp(0.525)\approx1.690\) outcome units. At \(A=1\), \(\hat m(1)=\exp(0.825)\approx2.282\) outcome units. The difference is approximately \(2.282-1.690=0.592\) outcome units, while the ratio is approximately \(2.282/1.690=1.350\). Equivalently, the ratio is \(\exp(0.3)\approx1.350\), because the shared random-intercept contribution cancels.

This cancellation follows from the particular model: the same random-intercept distribution applies at both settings, and the fixed-effect shift does not depend on \(b\). It should not be assumed in models with random slopes or other structures. The ratio describes the model-based means at the two settings; it does not by itself describe a causal effect.

Uncertainty for an Estimated Contrast

Integrated predictions are estimated quantities, and predictions from the same fitted model are usually correlated. A contrast standard error should therefore use their covariance, not treat them as independent by default. Let \(\hat{\boldsymbol{\theta}}\) collect the estimated model parameters, and let \(\widehat{\operatorname{Var}}(\hat{\boldsymbol{\theta}})\) be their estimated covariance matrix. For a smooth contrast \(C(\boldsymbol{\theta})\), the delta method approximates its variance by the gradient of the contrast with respect to the parameters:

$$ \widehat{\operatorname{Var}}\{C(\hat{\boldsymbol{\theta}})\} \approx \nabla C(\hat{\boldsymbol{\theta}})^{\mathsf T} \widehat{\operatorname{Var}}(\hat{\boldsymbol{\theta}}) \nabla C(\hat{\boldsymbol{\theta}}). $$

In practice, the gradient can be derived analytically or approximated numerically, with each integrated mean recalculated as the parameters change. This calculation must account for uncertainty in the parameters that determine the random-effects distribution as well as in fixed effects. It also depends on the covariance estimate being suitable for the fitted model.

Justification: A first-order Taylor expansion around the true parameter gives \(C(\hat{\boldsymbol{\theta}})\approx C(\boldsymbol{\theta})+\nabla C(\boldsymbol{\theta})^{\mathsf T}(\hat{\boldsymbol{\theta}}-\boldsymbol{\theta})\). Taking the variance of this linear approximation yields the delta-method expression. The approximation is most reliable when the estimator is approximately normal and the contrast is smooth near the fitted parameter values.

If the two integrated means are treated as intermediate estimates, the corresponding formulas show explicitly why their covariance matters. Write \(m_1=m(\mathbf{x}_1)\), \(m_0=m(\mathbf{x}_0)\), and let \(V_1,V_0\) be their estimated variances with covariance \(C_{10}\). Then the estimated variance of a difference is \(V_1+V_0-2C_{10}\). For a ratio \(R=m_1/m_0\), it is often convenient to work with \(\log R=\log m_1-\log m_0\); its delta-method variance is approximately \(V_1/m_1^2+V_0/m_0^2-2C_{10}/(m_1m_0)\). A confidence interval formed on the log scale can be exponentiated to give an interval for the ratio, provided the log-scale approximation is reasonable.

Worked Example: A Delta-Method Interval for a Ratio

Suppose a hypothetical fitted model gives two integrated means \(\hat m_1=0.42\) and \(\hat m_0=0.30\), with estimated variances \(V_1=0.001225\) and \(V_0=0.000900\), and covariance \(C_{10}=0.000600\). These values are assumed to come from the same fitted model, so the nonzero covariance is retained.

The estimated ratio is \(R=0.42/0.30=1.40\). The estimated variance of its log is

$$ \widehat{\operatorname{Var}}(\log R) \approx \frac{0.001225}{0.42^2} +\frac{0.000900}{0.30^2} -\frac{2(0.000600)}{0.42(0.30)} =0.0074206349. $$

Thus the log-scale standard error is \(\sqrt{0.0074206349}\approx0.08614\). Using a normal 95% critical value of 1.96, the log-scale interval is \(\log(1.40)\pm1.96(0.08614)\), or approximately \((0.1676,0.5053)\), with endpoints calculated from unrounded values. Exponentiating those endpoints gives a 95% confidence interval for the ratio of approximately \((1.183,1.658)\).

Under the model and the delta-method approximation, the estimated ratio is 1.40, with a 95% interval from about 1.183 to 1.658. The interval is for the population-averaged ratio defined by these settings and this model; it is not a 95% probability statement about the fixed ratio. Ignoring the positive covariance here would change the standard error and interval.

Choosing and Checking a Contrast

A contrast is interpretable only when its settings and scale are explicit. State which covariates differ, which are held fixed, whether the outcome is a mean or probability, and which random-effects distribution is used for integration. A difference retains the units of the predicted mean; a ratio compares two positive means on a multiplicative scale and has no units. These are distinct summaries and can convey different aspects of the same pair of predictions.

The main alternative is a conditional contrast, calculated at a selected random-effect value such as \(b=0\). That can answer a valid conditional question, but it is not generally a population-averaged contrast. Another distinct operation is averaging predictions over a distribution of covariate values; a contrast at two specified settings does not automatically represent such a population-standardized comparison. The choice should follow the estimand, not convenience.

Before interpreting estimates, check that the GLMM is adequate for the outcome and clustering structure, that the random-effects distribution used for integration is appropriate, and that the same intended distribution is used at both settings. For numerical integration, increase the quadrature accuracy and verify that the predictions and contrast are stable. For inference, inspect whether the covariance estimate is reliable and whether the contrast is far enough from parameter boundaries for a first-order approximation to be plausible. Sparse data, separation, poorly estimated variance components, or a ratio with a denominator near zero can make normal or log-scale intervals unreliable.

Common Pitfalls

  • Contrasting conditional predictions and calling the result marginal. Fixing random effects at zero does not integrate them out. Compute each integrated mean first.
  • Dropping covariance between predictions. When predictions come from one fit, their estimation errors are often dependent. Include the covariance term in the variance calculation.
  • Using the wrong scale or units. A difference is in outcome units; a ratio is dimensionless and requires positive means. Name the scale and units in context.
  • Overinterpreting the comparison. A model-based contrast at specified covariate settings is not automatically causal or representative of an entire target population.
  • Trusting an unstable computation. Check numerical integration and the behavior of uncertainty estimates, especially with sparse data or weakly estimated random-effects variances.
Key takeaway: A population-averaged contrast is formed by integrating the conditional mean over the random-effects distribution at each specified setting and then comparing those integrated means. Its interpretation and uncertainty depend on the settings, scale, model, integration, and covariance between predictions.

Check Your Understanding

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

  1. In one sentence, distinguish a population-averaged difference from a conditional difference at \(b=0\).
  2. If two positive integrated means are 8 and 10 units, give their difference for the second setting minus the first, and their ratio in the same order.
  3. Why is covariance between two predictions relevant when estimating the variance of their difference?
  4. For a ratio estimate of 1.5 with log-scale standard error 0.10, calculate an approximate 95% interval by forming a normal interval on the log scale and exponentiating.

Solutions. (1) A population-averaged difference subtracts means each integrated over the random-effects distribution, whereas the conditional difference compares means at a fixed random-effect value. (2) The difference is \(10-8=2\) outcome units and the ratio is \(10/8=1.25\), with the second setting in the numerator. (3) The variance is \(V_1+V_0-2C_{10}\), so omitting covariance changes the estimated uncertainty unless that covariance is zero. (4) The log estimate is \(\log(1.5)\approx0.4055\); the interval is \(0.4055\pm1.96(0.10)=(0.2095,0.6015)\). Exponentiating gives approximately \((1.233,1.825)\).

Clinical Biostats