Why Modification and Averaging Must Be Considered Together
A treatment effect can vary across clusters, across measured groups, or both. Even when a GLMM specifies one treatment coefficient, the corresponding effect on the probability scale need not be the same in every cluster: in a logistic model, the baseline risk changes the probability difference associated with a fixed log-odds contrast. Conversely, an explicit treatment interaction says that the treatment coefficient changes with a modifier on the model’s link scale, but it does not by itself give the treatment contrast averaged over a population.
The key distinction is between a conditional effect, defined with cluster random effects held fixed, and a population-averaged contrast, calculated after predicting outcomes under each treatment and averaging over a stated population distribution. These answer different questions. Neither is automatically the uniquely correct treatment effect; the choice depends on the target of the analysis.
Conditional Interaction and Population-Averaged Risk Difference
For a binary outcome, consider a logistic random-intercept and random-slope model with a binary modifier \(Z_{ij}\):
Here \(\operatorname{logit}(p)=\log\{p/(1-p)\}\). The random intercept \(b_{0j}\) represents cluster-specific baseline variation, while \(b_{1j}\) allows the treatment coefficient to vary across clusters. A common assumption is that the random-effects vector has a specified distribution, often a mean-zero multivariate normal distribution, and that outcomes are independent conditional on the random effects and covariates. The chosen random-effects distribution and mean structure must be adequate for the intended inference.
At fixed \(Z_{ij}=z\) and fixed random effects, the conditional treatment log odds ratio is \(\beta_A+\beta_{AZ}z+b_{1j}\). Thus \(\beta_{AZ}\) is modification of the treatment log odds ratio by \(Z\), conditional on cluster effects. If \(b_{1j}=0\), the conditional odds ratio is \(\exp(\beta_A+\beta_{AZ}z)\). This is not generally a risk difference, and it is not automatically a population-average odds ratio.
Let \(p_{ij}(a,z,b_{0j},b_{1j})\) be the predicted probability after setting treatment to \(a\). A conditional risk difference is \(p_{ij}(1,z,b_{0j},b_{1j})-p_{ij}(0,z,b_{0j},b_{1j})\). To obtain an average treatment contrast for a target population, average the two predicted probabilities over that population before subtracting. For a finite target population with weights \(w_k\), where \(w_k\geq 0\) and \(\sum_k w_k=1\), the average risk difference is:
For a model-based target over random effects, the analogous operation is integration with respect to their distribution, and possibly averaging over covariates as well. The target weights matter: equal weight per cluster, weight per individual, and a prespecified external population distribution can lead to different averages.
Worked Example: Different Baseline Risks, One Conditional Log Odds Ratio
Suppose a hypothetical population has two equally common cluster types. Their conditional control log odds are \(-1\) and \(1\), respectively. There is no random treatment slope, and treatment adds \(1.2\) to the log odds in both types. Assume binary outcomes are Bernoulli conditional on cluster type, treatment, and the model; the two types each receive weight \(0.5\). These assumptions define the arithmetic example, not a real study.
For the lower-baseline type, the control and treated risks are:
The conditional risk difference is \(0.5498-0.2689=0.2809\). For the higher-baseline type:
Using the displayed probabilities, the conditional risk difference is \(0.9002-0.7311=0.1691\). The log odds ratio is \(1.2\) in each type, so the conditional odds ratio is \(\exp(1.2)=3.320\) in both. Yet the probability-scale treatment contrasts differ because the inverse-logit transformation is nonlinear and the baseline risks differ.
With equal type weights, the average control risk is \((0.2689+0.7311)/2=0.5000\), and the average treated risk is \((0.5498+0.9002)/2=0.7250\). Therefore the population-averaged risk difference is \(0.7250-0.5000=0.2250\), or about 22.50 percentage points. This is an average probability contrast, not the conditional odds ratio.
Modification by a Measured Cluster or Individual Characteristic
A treatment-by-modifier interaction can be present even when the model has no random treatment slope. In that case, the treatment coefficient differs by the measured modifier, while remaining constant across clusters conditional on the random intercept. The following example calculates both the conditional contrasts and a weighted population contrast.
Worked Example: A Treatment Interaction Across Two Groups
Consider a hypothetical logistic model with no random effects in this calculation, baseline log odds \(-1\), modifier \(Z\in\{0,1\}\), treatment coefficient \(\beta_A=0.4\), modifier coefficient \(\beta_Z=0\), and interaction coefficient \(\beta_{AZ}=0.8\). Thus the log odds are \(-1+0.4A+0.8AZ\). Assume each modifier group has equal weight in the target population, and that the model is correctly specified for these illustrative probabilities.
For \(Z=0\), the control risk is \(\operatorname{expit}(-1)=0.2689\), and the treated risk is \(\operatorname{expit}(-1+0.4)=\operatorname{expit}(-0.6)=0.3543\). The risk difference is \(0.3543-0.2689=0.0854\), or 8.54 percentage points. The conditional log odds ratio is \(0.4\), giving an odds ratio of \(\exp(0.4)=1.492\).
For \(Z=1\), the treated log odds are \(-1+0.4+0.8=0.2\), while control log odds remain \(-1\). The treated risk is \(\operatorname{expit}(0.2)=0.5498\), so the risk difference is \(0.5498-0.2689=0.2809\), or 28.09 percentage points. The conditional log odds ratio is \(0.4+0.8=1.2\), and the corresponding odds ratio is \(\exp(1.2)=3.320\).
The interaction coefficient \(0.8\) is the difference between the two conditional log odds ratios, not the difference between the risk differences. With equal group weights, the average control risk is \(0.2689\), while the average treated risk is \((0.3543+0.5498)/2=0.4521\). The average risk difference is \(0.4521-0.2689=0.1832\), or 18.32 percentage points. A different target population with different proportions in the two groups would generally have a different average.
Why Averaging and Prediction Do Not Commute
The source of the distinction can be seen directly. Write \(\operatorname{expit}(x)=1/(1+\exp(-x))\), and let \(\eta(a,b)\) be the linear predictor under treatment \(a\) and random effect \(b\). For a logistic GLMM, the population risk under treatment \(a\) is \(E_b[\operatorname{expit}\{\eta(a,b)\}]\). In general, this is not \(\operatorname{expit}\{E_b[\eta(a,b)]\}\). Consequently, setting random effects to their mean, often zero, does not generally calculate a population-averaged risk.
A short derivation makes the issue explicit. With a random intercept \(b\) and treatment log odds increment \(\beta_A\), the conditional risk difference at linear predictor \(\eta\) is \(\operatorname{expit}(\eta+\beta_A)-\operatorname{expit}(\eta)\). Its population average is:
The equality follows from linearity of expectation. It does not allow either expectation to be replaced by the inverse-logit evaluated at the mean linear predictor. Since the inverse-logit is nonlinear, heterogeneity in \(b\) can change both averaged risks and their difference. On the odds-ratio scale, an additional distinction arises: a conditional odds ratio generally differs from an odds ratio computed from marginal risks, even without treatment-effect modification. This is the non-collapsibility of the odds ratio, not evidence by itself of confounding or a faulty model.
Worked Example: Averaging Over Random Treatment Slopes
Suppose a hypothetical logistic model has baseline log odds zero, fixed treatment coefficient \(0.5\), and a random treatment slope taking values \(-0.6\) and \(0.6\) with equal probability. There is no random intercept in this simplified calculation. Outcomes are Bernoulli conditional on the slope, and the two slope values define the target distribution. The conditional treatment log odds ratios are \(0.5-0.6=-0.1\) and \(0.5+0.6=1.1\), so their odds ratios are \(\exp(-0.1)=0.9048\) and \(\exp(1.1)=3.004\).
For either slope value, the control risk is \(\operatorname{expit}(0)=0.5000\). The treated risks are \(\operatorname{expit}(-0.1)=0.4750\) and \(\operatorname{expit}(1.1)=0.7503\). Their conditional risk differences are \(0.4750-0.5000=-0.0250\) and \(0.7503-0.5000=0.2503\). Averaging with the specified equal weights gives an average treated risk of \((0.4750+0.7503)/2=0.6127\), an average control risk of \(0.5000\), and an average risk difference of \(0.1127\), or about 11.27 percentage points.
The fixed coefficient \(0.5\) describes the mean of the specified conditional log-odds treatment slopes. It is not the average risk difference. The odds ratio calculated from the averaged risks is \((0.6127/0.3873)/(0.5000/0.5000)\approx1.582\), which is also not the conditional odds ratio \(\exp(0.5)=1.649\). The distinction follows from averaging predicted probabilities and then forming an odds ratio.
Choosing and Reporting the Contrast
A useful analysis begins by naming the population and contrast before interpreting an interaction coefficient. For a target population, specify which covariates and cluster effects are averaged over and how they are weighted. Then calculate the predicted outcome under treatment and control for each target unit or target stratum, average each set of predictions, and form the desired contrast. If the goal is a risk difference, subtract the average risks; if it is a risk ratio, divide them. These calculations need not agree with a coefficient or exponentiated coefficient from the conditional model.
A marginal model such as GEE directly parameterizes a population-average mean relationship, whereas a GLMM specifies a conditional model given random effects and obtains population averages by integrating or standardizing its predictions. They can target related quantities, but their regression coefficients are not interchangeable by default. A GLMM can still be used to estimate an average contrast by standardization, provided its conditional mean and random-effects assumptions are sufficiently credible for that purpose. The introductory material on GLMM and GEE distinguishes their broad conditional and marginal targets; here the key point is how modification and averaging affect the contrast itself.
A treatment interaction is scale-dependent. A zero interaction on the log-odds scale means the conditional log odds ratio does not vary with the modifier; it does not imply equal risk differences across modifier values. Likewise, unequal risk differences do not alone establish interaction on every scale. State the scale and the conditioning set whenever reporting effect modification.
Diagnostics, Alternatives, and Limitations
Check that the interaction coding matches the scientific question, that treatment and modifier combinations have adequate data support, and that predicted probabilities are within the possible range. For a random-slope model, inspect whether the data support the added cluster-specific treatment variation and whether conclusions are sensitive to plausible random-effects distributions. Compare fitted and observed outcome patterns across treatment, modifier, and cluster strata where feasible. Sparse combinations, near separation, or a few influential clusters can make interaction estimates unstable.
The main alternative is to fit a marginal mean model and estimate a population-average treatment relationship directly, commonly using GEE. This avoids specifying a random-effects distribution for the mean interpretation, but still requires a suitable marginal mean model and valid inference for the cluster structure. A GLMM is especially natural when cluster-specific prediction or conditional effects are central; a marginal approach is natural when the population mean is the primary target. Either approach can be misinterpreted if the coefficient scale is mistaken for a different contrast.
Neither averaging nor interaction analysis removes design requirements for causal interpretation. A treatment contrast is causal only under conditions appropriate to the study, such as randomized treatment assignment or defensible control of confounding, along with a well-defined intervention and adequate support. Model-based averages also depend on the target population and model assumptions. An average can conceal meaningful heterogeneity, so reporting only one number may be inadequate when subgroup contrasts are important.
Common Pitfalls
- Reading a conditional coefficient as a population effect. The treatment coefficient in a logistic GLMM is conditional on random effects. It is not generally the marginal risk difference or marginal odds ratio.
- Assuming no interaction means equal risk differences. A constant conditional log odds ratio can coexist with different probability differences when baseline risks vary.
- Calling the interaction coefficient a risk-difference interaction. In a logistic model, \(\beta_{AZ}\) is a difference in conditional log odds ratios across \(Z\), not a difference in risk differences.
- Evaluating at random effects equal to zero and calling it population-average. A zero random effect gives a cluster at the reference random-effect value; population averaging requires averaging predicted probabilities over the specified distribution.
- Leaving the population weights unstated. Equal cluster weights and equal individual weights need not define the same average when cluster sizes differ.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- In a logistic GLMM, the treatment coefficient is constant across clusters but baseline risks differ. Must the risk difference be constant across clusters? Why?
- A treatment-by-binary-modifier coefficient is \(0.7\) in a logistic model. What does this number compare, and what does it not directly represent?
- For two equally weighted groups, control risks are \(0.20\) and \(0.60\), and treated risks are \(0.30\) and \(0.75\). Calculate the average risk difference.
- Why is \(\operatorname{expit}\{E(\eta)\}\) generally not a population-averaged risk when \(\eta\) contains a random effect?
Solutions. (1) No. A constant conditional log odds ratio can produce different risk differences at different baseline risks because the inverse-logit is nonlinear. (2) It is the difference in conditional treatment log odds ratios between modifier groups, holding random effects fixed. It is not itself a risk difference or a population-average contrast. (3) The group-specific risk differences are \(0.30-0.20=0.10\) and \(0.75-0.60=0.15\); their equal-weight average is \((0.10+0.15)/2=0.125\), or 12.5 percentage points. (4) In general, averaging and applying a nonlinear function do not commute: \(E[\operatorname{expit}(\eta)]\ne\operatorname{expit}\{E(\eta)\}\). Average the predicted probabilities over the random-effect distribution to obtain the model-based population risk.