Begin With the Scientific Question
Clustered data do not by themselves dictate whether to use a generalized linear mixed model (GLMM) or generalized estimating equations (GEE). The central decision is what effect the study is meant to describe. A GLMM generally specifies a conditional outcome model given cluster-specific random effects; GEE specifies a marginal mean model for outcomes averaged over the target population of clusters. Those are different estimands, especially for nonlinear links such as the logit.
For a binary outcome \(Y_{ij}\), let \(i\) index individuals and \(j\) index clusters, let \(x_{ij}\) denote covariates, and let \(b_j\) denote a cluster-specific random effect. A random-intercept logistic GLMM can be written
This model assumes the stated conditional response distribution and link, a specified random-effects distribution, and conditional independence of outcomes given the random effects and covariates. The last assumption means the random effects account for the modeled within-cluster dependence; it does not assert that outcomes are unconditionally independent.
A marginal logistic GEE instead specifies \(E(Y_{ij}\mid x_{ij})=\mu_{ij}\) and \(\operatorname{logit}(\mu_{ij})=x_{ij}^{T}\gamma\), together with a working correlation structure for outcomes in the same cluster. Its estimating equations use that working structure for efficiency, while a sandwich variance estimator can provide robust standard errors when the mean model is correct and clusters are independent, subject to having enough independent clusters for the large-sample approximation to be credible.
A Selection Workflow
A useful workshop procedure is to write the scientific question in words before selecting software or a correlation structure. The following steps make explicit what is being estimated and which modeling commitments follow.
Specify whether each response is binary, a count, or another outcome, and identify the individual and cluster. State whether treatment varies between clusters, within clusters, or both.
For example, decide whether the goal is an odds ratio conditional on a cluster propensity or an odds ratio comparing population-averaged outcome probabilities. Also specify the covariates and population to which the contrast refers.
Use a GLMM when cluster-specific effects, latent heterogeneity, or prediction conditional on a cluster effect are central. Use GEE when the primary target is a population-averaged mean contrast and clusters can be treated as independent sampling units.
Verify that the treatment contrast is identifiable from the design, that the mean and link are appropriate, and that the chosen dependence assumptions and inferential method suit the number and structure of clusters.
Report whether the coefficient is conditional or marginal, give its transformed effect measure when useful, and state the outcome, comparison, and units in context.
Worked Example: Clinic-Randomized Binary Outcome
Worked Example: Clinic-Randomized Binary Outcome
Suppose, hypothetically, 40 clinics are randomized to a new care program or usual care. For each patient, the outcome is whether a complication occurred within 30 days. The scientific question is: What is the population-averaged association between offering the program and the probability of a complication in the clinics represented by this trial? Treatment is assigned at clinic level, and the target is an average across clinics, not a comparison at a fixed latent clinic propensity.
A marginal logistic GEE directly targets that question. Suppose the fitted treatment coefficient is \(\hat{\gamma}_1=-0.40\), with robust \(SE=0.18\). The marginal odds ratio is
Thus, under the fitted marginal mean model, the program group has estimated complication odds about 0.670 times the usual-care odds, or about 33.0% lower odds. This is an odds comparison, not a 33.0% reduction in probability or risk. A Wald statistic is \(z=-0.40/0.18=-2.22\), giving a two-sided \(p\)-value of approximately 0.026. The corresponding approximate 95% interval for the log odds ratio is \(-0.40\pm1.96(0.18)=(-0.753,-0.047)\); exponentiating gives an odds-ratio interval of approximately \((0.471,0.954)\). Under the GEE large-sample approximation, the interval is for the population-averaged odds ratio. It excludes 1, but its width still conveys uncertainty about the magnitude.
The design supports a between-clinic treatment comparison, but there are only 40 independent randomized clinics. The analyst should check that the GEE mean model includes important design variables and that the reported variance accounts for clinic clustering. With a modest number of clusters, the ordinary sandwich approximation can be inaccurate; a suitable small-sample correction or design-based analysis may be needed. A GLMM could also be fit, but its treatment coefficient would generally be conditional on the random intercept, not the population-averaged odds ratio asked for here.
Worked Example: A Clinic-Specific Conditional Contrast
Worked Example: Interpreting a GLMM Coefficient
Consider a hypothetical study in which patients within 30 clinics are individually randomized to treatment or control. Investigators specifically want to describe the treatment odds ratio at a fixed clinic propensity, while accounting for baseline differences in clinic complication risk. Assume a random-intercept logistic GLMM with a normally distributed clinic intercept and a common treatment effect across clinics; assume outcomes are conditionally independent given the intercept and covariates.
Suppose the fitted linear predictor is \(\operatorname{logit}(\mu_{ij})=-1.10-0.52x_{ij}+b_j\), where \(x_{ij}=1\) for treatment and \(0\) for control. For any fixed \(b_j\), the conditional treatment odds ratio follows by taking the ratio of the treatment odds to the control odds:
The fitted conditional odds are therefore about 0.595 times as large under treatment, for the same clinic random intercept. For illustration, at \(b_j=0\), the control probability is \(\operatorname{logit}^{-1}(-1.10)\approx0.250\), while the treatment probability is \(\operatorname{logit}^{-1}(-1.62)\approx0.165\). These are predictions for a clinic with random intercept zero, not population-averaged probabilities. The coefficient does not claim that the marginal odds ratio is 0.595: averaging probabilities over a distribution of random intercepts and then calculating odds is generally not the same as calculating conditional odds at \(b_j=0\).
This choice is appropriate only if the conditional estimand is scientifically useful and the random-intercept model is credible. If the scientific target were instead the mean treatment contrast across the population of clinics, GEE would be a direct alternative. If treatment effects plausibly vary across clinics, a common treatment coefficient may be inadequate; the model and estimand need to reflect that possibility rather than treating a random intercept as a substitute for a random treatment slope.
Worked Example: Recurrent Counts and Exposure Time
Worked Example: Population-Averaged Event Rate
Suppose, hypothetically, patients are followed within 50 clinics, and the outcome is a recurrent event count with different person-time at risk. The target question is the population-averaged event rate ratio for a program versus control. A marginal log-rate GEE can model the mean count with the logarithm of person-time as an offset. Assume the conditional mean specification and offset are appropriate, and independent clinics are the sampling units.
Suppose the fitted program coefficient is \(\hat{\gamma}_1=0.12\). For a log-rate model with the same exposure time, the estimated population-averaged rate ratio is
The estimated event rate is about 1.1275 times the control rate, or 12.75% higher. If the fitted control rate is 2.0 events per person-time unit, the treatment rate calculated from the unrounded ratio is \(2.0\exp(0.12)\approx2.255\) events per person-time unit. The units remain events per person-time unit; the ratio itself is unitless.
A GLMM with a cluster random intercept would instead describe rates conditional on that latent cluster effect. It may be preferable if the goal includes cluster-specific prediction or modeling latent rate heterogeneity. The GEE choice here follows the stated population-average rate estimand, not a rule that count outcomes always require GEE.
Justification: Why the Coefficient Depends on the Estimand
The conditional-versus-marginal distinction can be seen directly in the binary random-intercept model. Conditional on \(b_j\), the odds at covariate value \(x\) are \(\exp(x^T\beta+b_j)\). A one-unit increase in a covariate with coefficient \(\beta_k\), holding other covariates and \(b_j\) fixed, multiplies those odds by \(\exp(\beta_k)\), because the common terms cancel in the odds ratio. This is why a GLMM coefficient has a conditional interpretation.
For a marginal model, the probability at \(x\) is instead obtained by averaging the conditional probability over the random-effects distribution: \(E_{b_j}\{\operatorname{logit}^{-1}(x^T\beta+b_j)\}\). The logit of this average is not generally \(x^T\beta\). Consequently, the marginal odds ratio need not equal \(\exp(\beta_k)\). This nonlinearity is the key reason not to compare conditional and marginal coefficients as if they estimated the same quantity. The same general caution applies to other nonlinear links, although the precise relationship depends on the link and random-effects distribution.
Diagnostics, Alternatives, and Limitations
Selection is not complete once a model has been fit. Check the design and the fitted mean model before treating an estimate as scientifically interpretable.
- Check the assignment and overlap. If treatment is constant within each clinic, its effect is identified through between-clinic comparisons. With few clinics or strong clinic-level confounding, neither a random intercept nor robust standard errors create information the design did not supply. If treatment varies within clinics, make clear that the contrast is within-clinic or otherwise state how both sources of variation enter the model.
- Check the mean structure. Inspect whether covariates, time, offsets, and interactions represent the scientific question. In a GLMM, examine whether the random-effects distribution and random-effects structure are plausible; in GEE, assess whether the chosen working correlation is reasonable and whether estimates are stable across sensible alternatives.
- Check dependence and inference. Clusters should be independent for the usual cluster-robust GEE inference. A sandwich standard error protects against some working-correlation misspecification, not against a wrong mean model, dependent clusters, or too few independent clusters. GLMM inference also depends on the likelihood and random-effects assumptions.
- Check data and fit warnings. Sparse outcomes, separation, extreme fitted values, convergence failures, or a variance estimate near a boundary can signal instability or a model that is too elaborate for the available data. Examine cluster-level outcome patterns and influential clusters, not only individual residual summaries.
GEE and GLMM are not simply rival algorithms for the same coefficient. GEE is often a natural choice for a population-average mean effect and can be less dependent on a full random-effects distribution, but it does not provide the same latent cluster-specific model or likelihood-based predictions. A GLMM provides explicit cluster heterogeneity and conditional predictions, but its interpretation depends on the random-effects specification and it may be sensitive to distributional assumptions. A cluster-level analysis is another possible approach when the scientific unit is the cluster or when the number of clusters is small, although it may discard individual-level information and answer a different question. The choice should be reported alongside the target estimand, not justified solely by which model produces a preferred \(p\)-value or the smaller information criterion.
Common Pitfall
A second common mistake is to select GEE merely because the sample is clustered, or GLMM merely because a random intercept can be fit. Neither choice repairs a poor study design, an unmodeled treatment-effect interaction, or a mismatch between the estimand and coefficient. Report the question, target contrast, model scale, and dependence assumptions together.
Check Your Understanding
Answer each question, then compare your reasoning with the brief solutions.
- A trial randomizes clinics and asks for the average change in patient risk across the target clinic population. Which model is a direct starting choice, and what must the report say about the treatment coefficient?
- In a logistic random-intercept GLMM, the treatment coefficient is \(-0.30\). Calculate the conditional odds ratio and state its interpretation.
- Why is a robust GEE standard error not a remedy for a misspecified marginal mean model?
- A study has only eight randomized clinics. Name one concern for ordinary GEE inference and one concern that remains for a GLMM.
- A researcher wants predictions for a new clinic after learning its clinic-specific latent propensity from earlier outcomes. Which model family more directly supports this goal, and what assumptions matter?
Solutions. (1) GEE is a direct starting choice for the population-average target; report that the coefficient is marginal and state its link-scale and transformed interpretation. (2) \(\exp(-0.30)\approx0.741\), so the conditional treatment odds are estimated to be about 0.741 times the control odds at the same random intercept. (3) The sandwich variance addresses uncertainty under some correlation misspecification, but it does not correct a wrong expected outcome model; the estimating equation can target the wrong contrast. (4) With eight independent clusters, the sandwich large-sample approximation may be poor. A GLMM still depends on a credible random-effects and response model and may be unstable with sparse cluster information. (5) A GLMM more directly represents cluster-specific latent effects and conditional predictions; its random-effects distribution, conditional response model, and prediction uncertainty must be considered.