Introduction
Longitudinal clinical studies rarely produce independent observations. A patient may contribute measurements at baseline, Week 4, Week 8, Week 12, and several later visits. Patients treated at the same clinical center may also be correlated, and subjects within the same cluster may share common characteristics.
The statistical challenge is therefore not simply to estimate a treatment effect. We must also account for the dependence among repeated observations.
Two of the most important frameworks for doing this are generalized estimating equations (GEE) and mixed-effects models.
The First Question: What Is the Scientific Target?
Before choosing a model, ask what the treatment effect is supposed to mean. This is often more important than the choice of software procedure.
Suppose \(Y_{ij}\) is the outcome for patient \(i\) at visit \(j\). A treatment indicator \(A_i\) may be used to compare two randomized groups. The investigator might ask:
- What is the average treatment effect across the population?
- How does treatment affect an individual patient's expected trajectory?
- How much do patients differ from one another?
- How much correlation exists among repeated measurements?
These questions naturally lead toward different modeling frameworks.
What Is GEE?
Generalized estimating equations extend generalized linear models to correlated observations. Instead of explicitly modeling a subject-specific latent random effect, GEE specifies a model for the marginal mean and a working correlation structure for observations within a cluster.
Let:
$$ \mu_{ij}=E(Y_{ij}\mid X_{ij}) $$and let \(g(\cdot)\) denote the link function. The marginal mean model is:
$$ g(\mu_{ij})=X_{ij}^{T}\beta $$The parameter vector \(\beta\) describes the relationship between covariates and the population-level mean response.
The GEE estimating equation can be written schematically as:
$$ \sum_i D_i^T V_i^{-1}(Y_i-\mu_i)=0 $$where \(D_i\) contains derivatives of the mean with respect to the model parameters and \(V_i\) represents the working covariance matrix.
What Is a Mixed-Effects Model?
A mixed-effects model combines fixed effects, which describe systematic population-level relationships, with random effects, which represent subject- or cluster-specific deviations.
For a continuous outcome, a basic linear mixed model can be written:
$$ Y_{ij}=X_{ij}^{T}\beta+Z_{ij}^{T}b_i+\epsilon_{ij} $$where:
- \(\beta\) contains the fixed-effect parameters.
- \(b_i\) contains subject-specific random effects.
- \(Z_{ij}\) relates the random effects to observation \(j\).
- \(\epsilon_{ij}\) represents residual error.
A common random-intercept model is:
$$ Y_{ij}=\beta_0+\beta_1A_i+\beta_2t_{ij}+b_{0i}+\epsilon_{ij} $$where \(b_{0i}\) allows each patient to have their own baseline deviation from the population intercept.
A random-slope model can additionally allow patients to have different trajectories:
$$ Y_{ij}=\beta_0+\beta_1A_i+\beta_2t_{ij} +b_{0i}+b_{1i}t_{ij}+\epsilon_{ij} $$Population-Averaged vs. Subject-Specific Effects
This is the single most important conceptual distinction between GEE and mixed models.
| Question | GEE | Mixed Model |
|---|---|---|
| Primary interpretation | Population-averaged | Subject-specific |
| Models subject heterogeneity explicitly? | No | Yes |
| Random effects | No | Yes |
| Working correlation | Yes | Implied by covariance structure |
| Individual trajectories | Not directly modeled | Can be modeled directly |
| Robust sandwich variance | Commonly used | Not the defining feature |
The distinction becomes especially important for nonlinear links such as logit and log links. For a continuous identity-link model, the population and subject-specific interpretations can sometimes appear numerically similar, but this should not obscure the conceptual distinction.
A Simple Clinical Example
Suppose a randomized clinical trial compares an active treatment with placebo. Depression severity is measured at baseline and Weeks 2, 4, 8, and 12.
The investigator wants to estimate the treatment difference in mean depression score over follow-up.
There are several reasonable approaches.
The GEE Working Correlation
GEE requires a working correlation structure describing how observations within a subject or cluster are related.
Common choices include:
| Structure | Assumption | Typical Use |
|---|---|---|
| Independent | Within-subject correlations treated as zero for working purposes | Large clusters or weak dependence |
| Exchangeable | All pairs within a subject have the same correlation | Repeated measurements with roughly constant correlation |
| AR(1) | Correlation decreases with increasing time separation | Regularly spaced longitudinal visits |
| Unstructured | Each pair can have a different correlation | Small number of visits with sufficient data |
For an exchangeable structure, the working correlation matrix has the form:
$$ R(\alpha)= \begin{pmatrix} 1 & \alpha & \alpha & \cdots \\ \alpha & 1 & \alpha & \cdots \\ \alpha & \alpha & 1 & \cdots \\ \vdots & \vdots & \vdots & \ddots \end{pmatrix} $$For an AR(1) structure:
$$ R_{jk}=\alpha^{|j-k|} $$Thus observations closer together in time are assumed to be more strongly correlated.
Covariance Structures in Mixed Models
Mixed models take a different approach. The covariance among repeated measurements is generated by the random-effects structure and residual covariance specification.
For example, a random-intercept model creates correlation because two observations from the same patient share the same \(b_{0i}\).
If:
$$ Y_{ij}=\beta_0+\beta_1t_{ij}+b_{0i}+\epsilon_{ij} $$with:
$$ b_{0i}\sim N(0,\sigma_b^2) \qquad\text{and}\qquad \epsilon_{ij}\sim N(0,\sigma^2) $$then two observations from the same patient have covariance:
$$ \operatorname{Cov}(Y_{ij},Y_{ik})=\sigma_b^2 $$and therefore correlation:
$$ \operatorname{Corr}(Y_{ij},Y_{ik}) = \frac{\sigma_b^2} {\sigma_b^2+\sigma^2} $$A random slope produces a more complicated covariance pattern that depends on the timing of the observations.
GEE Does Not Have Random Intercepts
This distinction is worth emphasizing because the two approaches are sometimes described as interchangeable ways of "accounting for repeated measures."
They are not identical models.
A mixed model might explicitly state:
$$ Y_{ij}=\beta_0+b_{0i}+\beta_1t_{ij}+\epsilon_{ij} $$where the patient-specific random intercept \(b_{0i}\) is an unobserved quantity representing subject heterogeneity.
GEE instead specifies a marginal mean and a working correlation among observations.
When GEE Is Often a Good Choice
GEE is often attractive when the primary scientific objective is a population-level treatment effect.
Typical situations include:
- The estimand is explicitly population-averaged.
- The observations are clustered or longitudinal.
- Subject-specific random effects are not of primary interest.
- The number of clusters is reasonably large.
- The analysis focuses on marginal means or risks.
- Robust inference under a potentially imperfect working correlation is valuable.
For example, suppose a public-health study asks whether an intervention reduces the average probability of hospitalization across a population of patients. A marginal treatment effect may be exactly the desired estimand.
When Mixed Models Are Often a Better Choice
Mixed models are often preferable when individual trajectories or between-subject heterogeneity are central to the scientific question.
- Patients have meaningful subject-specific trajectories.
- Random intercepts or slopes are scientifically important.
- Cluster-level heterogeneity needs to be estimated.
- Individual-level predictions are required.
- The outcome is continuous and approximately Gaussian.
- Irregular measurement times need to be modeled naturally.
- The covariance structure can be represented through random effects.
For example, in a growth study, investigators may want to know not only whether the treatment changes the average trajectory but also how much patients differ in their baseline values and rates of change.
Longitudinal Clinical Trials: A Practical Comparison
| Clinical Situation | Often Prefer | Reason |
|---|---|---|
| Average population treatment effect | GEE | Direct marginal interpretation |
| Patient-specific trajectories | Mixed model | Random effects describe subject heterogeneity |
| Random intercept and slope | Mixed model | Explicit trajectory modeling |
| Binary repeated outcome with marginal risk interpretation | GEE | Natural population-averaged framework |
| Continuous repeated outcome with incomplete observations | Mixed model often attractive | Likelihood-based estimation can use incomplete longitudinal records under appropriate assumptions |
| Many independent clusters | GEE often attractive | Robust population inference |
| Very few clusters | Neither automatically solves the problem | Small-cluster inference requires special attention |
The Importance of the Number of Clusters
A frequently overlooked issue with GEE is that the asymptotic justification for the sandwich variance estimator depends on having a sufficiently large number of independent clusters.
If a study has hundreds of patients, each contributing repeated observations, GEE may have strong large-sample support.
But consider a cluster-randomized trial with only 12 clinics. There may be many patient observations, but only 12 independent clusters. The effective number of independent units for the robust variance calculation is much smaller.
Missing Data: GEE vs. Mixed Models
Missing longitudinal observations are common in clinical research. Patients may discontinue treatment, miss visits, withdraw consent, or become lost to follow-up.
The handling of missing data can therefore influence the choice of model.
Mixed Models
Likelihood-based mixed models can use incomplete longitudinal records without requiring every patient to have observations at every scheduled visit. Under a correctly specified model and assumptions such as missing at random (MAR), likelihood-based estimation can remain valid.
GEE
Standard GEE is also capable of handling incomplete repeated observations, but the validity of inference depends on the missingness mechanism and the estimating approach used. Standard complete-case-style GEE is not universally robust to informative dropout.
MAR Does Not Mean "Missing Data Are Ignorable"
A common misunderstanding is that MAR means missing observations are irrelevant.
Instead, MAR is a conditional assumption about the probability of missingness. For example, after conditioning on observed treatment history and observed outcomes, the probability of a missing future measurement may no longer depend on the unobserved value itself.
The credibility of that assumption is a scientific issue, not merely a software setting.
Continuous Outcomes
For a continuous approximately Gaussian outcome, a linear mixed model is often a natural starting point.
For example:
$$ Y_{ij} = \beta_0 +\beta_1A_i +\beta_2t_{ij} +\beta_3(A_i t_{ij}) +b_{0i} +b_{1i}t_{ij} +\epsilon_{ij} $$Here:
- \(\beta_1\) describes a treatment difference at the reference time.
- \(\beta_2\) describes the average time trend in the reference group.
- \(\beta_3\) describes the difference in trajectories between treatment groups.
- \(b_{0i}\) allows patient-specific baseline deviations.
- \(b_{1i}\) allows patient-specific trajectory deviations.
A GEE version could instead specify a marginal mean:
$$ E(Y_{ij}\mid X_{ij}) = \beta_0 +\beta_1A_i +\beta_2t_{ij} +\beta_3(A_i t_{ij}) $$and then use a working correlation for repeated measurements within a patient.
Binary Outcomes
For a repeated binary endpoint, the distinction becomes especially important because odds ratios from marginal and subject-specific logistic models can differ substantially.
A GEE logistic model might be:
$$ \operatorname{logit}\{\Pr(Y_{ij}=1)\} = \beta_0+\beta_1A_i+\beta_2t_{ij} $$Then:
$$ \exp(\beta_1) $$is interpreted as a population-averaged odds ratio, subject to the exact model specification and covariate interpretation.
A mixed-effects logistic model could be:
$$ \operatorname{logit}\{\Pr(Y_{ij}=1\mid b_i)\} = \beta_0+\beta_1A_i+\beta_2t_{ij}+b_i $$where \(\exp(\beta_1)\) has a conditional, subject-specific interpretation.
Why the Two Odds Ratios Differ
Suppose patients differ in an unobserved propensity to experience the event. A mixed model conditions on the random effect, whereas GEE averages over the population distribution of that heterogeneity.
Because the logistic transformation is nonlinear, averaging and transforming do not generally commute.
Conceptually:
$$ \operatorname{logit}\{E(Y\mid X)\} \neq E\{\operatorname{logit}(Y\mid X,b)\} $$in general.
This is one reason why simply fitting both models and comparing coefficients without identifying the estimand can lead to confusion.
Random Intercept vs. Exchangeable GEE
A random-intercept mixed model and an exchangeable GEE may sometimes produce similar-looking results for a continuous outcome, but they are not the same model.
A random-intercept model implies a particular covariance pattern:
$$ \operatorname{Cov}(Y_{ij},Y_{ik})=\sigma_b^2 $$for observations from the same subject, assuming independent residual errors.
An exchangeable GEE specifies that all within-subject correlations are equal to a common working parameter \(\alpha\).
The resemblance is therefore useful for intuition, but the inferential framework remains different.
Random Slopes Change the Story
Suppose patients improve at different rates. A random-intercept model alone assumes patients differ in baseline level but share the same population slope, apart from residual noise.
A random-slope model allows:
$$ b_{1i}\neq0 $$and therefore permits patients to have different rates of change.
This is one of the clearest situations in which a mixed model has a scientifically meaningful advantage over a simple marginal correlation structure.
GEE With Different Outcome Distributions
GEE is not limited to continuous outcomes. It can be used with different distributions and link functions, including:
- Gaussian outcomes with identity links
- Binary outcomes with logit links
- Count outcomes with log links
- Other generalized estimating-equation settings supported by the software and analysis design
Likewise, mixed-effects models can be generalized beyond Gaussian outcomes. Generalized linear mixed models (GLMMs) introduce random effects into non-Gaussian models.
Therefore, the decision is not simply "GEE for binary data and mixed models for continuous data." The scientific estimand and dependence structure remain central.
GEE vs. GLMM
| Feature | GEE | GLMM |
|---|---|---|
| Primary estimand | Population-averaged | Subject-specific |
| Random effects | No | Yes |
| Correlation | Working correlation | Generated by random effects and residual structure |
| Individual predictions | Limited | Natural application |
| Robust sandwich inference | Central feature | Not the defining framework |
| Interpretation of nonlinear effects | Marginal | Conditional |
R Example: GEE
The geepack package provides a common R
implementation of GEE.
library(geepack) gee_fit <- geeglm( outcome ~ treatment * visit + baseline, id = patient_id, data = dat, family = gaussian, corstr = "ar1" ) summary(gee_fit)
For a binary endpoint:
gee_bin <- geeglm( response ~ treatment * visit + baseline, id = patient_id, data = dat, family = binomial(link = "logit"), corstr = "exchangeable" ) summary(gee_bin)
The treatment coefficient should be interpreted according to the marginal mean model.
R Example: Linear Mixed Model
The lme4 package is widely used for mixed models.
A random-intercept model can be fitted as:
library(lme4)
lmm_fit <- lmer(
outcome ~ treatment * visit + baseline +
(1 | patient_id),
data = dat
)
summary(lmm_fit)
A random-intercept and random-slope model is:
lmm_rs <- lmer(
outcome ~ treatment * visit + baseline +
(1 + visit | patient_id),
data = dat
)
summary(lmm_rs)
The second model explicitly allows both baseline levels and trajectories to vary among patients.
R Example: Generalized Linear Mixed Model
For a binary longitudinal outcome:
glmm_fit <- glmer(
response ~ treatment * visit + baseline +
(1 | patient_id),
data = dat,
family = binomial(link = "logit")
)
summary(glmm_fit)
The treatment effect is conditional on the random effect and therefore has a subject-specific interpretation.
SAS Example: GEE
In SAS, GEE analyses are commonly implemented with
PROC GENMOD using a repeated statement.
proc genmod data=dat;
class patient_id treatment visit;
model outcome =
treatment
visit
treatment*visit
baseline
/ dist=normal link=identity;
repeated subject=patient_id
/ type=ar(1)
corrw;
run;
For a binary outcome:
proc genmod data=dat;
class patient_id treatment visit;
model response =
treatment
visit
treatment*visit
baseline
/ dist=binomial link=logit;
repeated subject=patient_id
/ type=exch
corrw;
run;
SAS Example: Mixed Model
For a continuous outcome, PROC MIXED is a standard
choice:
proc mixed data=dat method=reml;
class patient_id treatment visit;
model outcome =
treatment
visit
treatment*visit
baseline
/ solution;
random intercept
/ subject=patient_id;
repeated visit
/ subject=patient_id
type=ar(1);
run;
A random-slope model can be specified as:
proc mixed data=dat method=reml;
class patient_id treatment visit;
model outcome =
treatment
visit
treatment*visit
baseline
/ solution;
random intercept visit
/ subject=patient_id
type=un;
run;
A Worked Clinical Trial Example
Consider a randomized trial with 200 patients. Each patient has a continuous outcome measured at baseline, Week 4, Week 8, and Week 12.
The scientific objective is to determine whether the active treatment changes the average trajectory compared with placebo.
| Design Feature | Planning Value |
|---|---|
| Total patients | 200 |
| Treatment groups | Active vs. placebo |
| Outcome | Continuous |
| Post-baseline visits | Weeks 4, 8, 12 |
| Primary scientific target | Average treatment effect over time |
| Repeated observations | Within patient |
Both GEE and a mixed model may be defensible. The question is which one most naturally matches the estimand and assumptions.
GEE Analysis of the Example
Suppose the marginal model is:
$$ E(Y_{ij}) = \beta_0 +\beta_1A_i +\beta_2t_{ij} +\beta_3A_it_{ij} +\beta_4B_i $$where \(B_i\) is baseline severity.
The treatment-by-time interaction \(\beta_3\) describes the difference in average longitudinal change between treatment groups.
If the primary question is:
"What is the average difference in outcome trajectories between the two treatment groups?"
then GEE is a very natural choice.
Mixed-Model Analysis of the Same Example
Now suppose the investigator believes that patients differ substantially in their baseline levels and rates of change.
A mixed model might be:
$$ Y_{ij} = \beta_0 +\beta_1A_i +\beta_2t_{ij} +\beta_3A_it_{ij} +\beta_4B_i +b_{0i} +b_{1i}t_{ij} +\epsilon_{ij} $$Now the model explicitly represents two sources of patient heterogeneity:
- \(b_{0i}\): patient-specific baseline deviation.
- \(b_{1i}\): patient-specific deviation in rate of change.
The treatment-by-time coefficient still describes the fixed treatment effect under the model, but the framework also provides a model for individual trajectories.
Which Model Would You Choose?
For the worked trial, the answer depends on the scientific objective.
| Primary Objective | Preferred Framework |
|---|---|
| Estimate population-average treatment effect | GEE |
| Estimate individual trajectories | Mixed model |
| Estimate between-patient heterogeneity | Mixed model |
| Focus on marginal means | GEE |
| Need subject-specific predictions | Mixed model |
| Need a random intercept/slope structure | Mixed model |
What About Covariance Structure Selection?
Covariance selection is another area where the frameworks differ.
In GEE, candidate working correlations might include:
- Independent
- Exchangeable
- AR(1)
- Unstructured
In a mixed model, covariance can arise through:
- Random intercepts
- Random slopes
- Random intercept plus random slope
- Residual covariance structures
- Combinations of random effects and residual covariance
Therefore, "choose AR(1)" does not mean exactly the same thing in GEE and mixed-model analysis.
What If the Working Correlation Is Wrong?
One of the attractions of GEE is that the regression estimates can remain consistent when the working correlation is misspecified, provided the mean model and regularity conditions are appropriate and robust variance estimation is used.
However, an inefficient or poorly chosen working correlation can affect precision.
For example, if the true correlation declines with time separation but the working structure assumes exchangeability, the treatment estimate may still be useful, but efficiency may not be optimal.
What If the Random-Effects Structure Is Wrong?
Mixed models are different because the random-effects structure contributes directly to the implied covariance model and likelihood.
If the model assumes only a random intercept when patients actually have substantially different slopes, the model may fail to represent important heterogeneity.
Likewise, an unnecessarily complicated random-effects structure may produce convergence problems or unstable variance estimates.
This makes covariance and random-effects specification an important modeling decision rather than a purely technical afterthought.
Model Selection Should Follow the Scientific Question
A common mistake is to fit several models and choose the one with the best AIC without first deciding what effect is scientifically meaningful.
A better sequence is:
Common Mistakes
- Thinking GEE and mixed models are interchangeable. They can address the same broad repeated-measures problem but target different types of effects.
- Choosing GEE because the data are longitudinal. Longitudinal structure alone does not determine the appropriate framework.
- Choosing mixed models because they are "more sophisticated." A more complicated model is not automatically more appropriate.
- Calling every repeated-measures analysis a subject-specific analysis. GEE is fundamentally marginal.
- Interpreting a GEE odds ratio as a conditional odds ratio. The estimands differ for nonlinear models.
- Ignoring the number of independent clusters. Robust GEE inference can be unreliable when the number of clusters is small.
- Assuming mixed models automatically solve missing-data problems. Validity still depends on assumptions about the missingness mechanism and model specification.
- Using an unnecessarily complicated random-effects structure. Random slopes and covariance parameters require adequate information.
- Choosing covariance structure solely from a data-driven search. Clinical and scientific plausibility should be considered alongside statistical criteria.
- Failing to prespecify the primary estimand. The treatment effect cannot be interpreted correctly without knowing what population or conditional quantity it represents.
GEE vs. Mixed Models: Decision Framework
Reporting GEE Results
A clinical report using GEE should make the marginal nature of the analysis clear.
At minimum, report:
- The marginal mean model.
- The outcome distribution and link function.
- The clustering variable.
- The working correlation structure.
- The variance estimator.
- The treatment effect and confidence interval.
- The interpretation of the effect as population-averaged.
- The handling of missing observations.
Reporting Mixed-Model Results
A mixed-model analysis should similarly document:
- The fixed-effects model.
- The random-effects structure.
- The residual covariance structure.
- The estimation method, such as REML or ML when appropriate.
- The treatment effect and confidence interval.
- The interpretation of fixed effects.
- Convergence and model diagnostics.
- The handling of missing observations.
Can You Use Both?
Yes.
In some analyses, fitting both a marginal model and a mixed model can be useful as a sensitivity or supplementary analysis, provided the two models are interpreted according to their respective estimands.
For example, a clinical trial might use a mixed model as the primary analysis because subject-level trajectories are scientifically important, while a GEE analysis provides a complementary population-averaged perspective.
A Compact Comparison
| Question | GEE | Mixed Model |
|---|---|---|
| What is modeled? | Marginal mean | Conditional mean with random effects |
| Main estimand | Population-averaged | Subject-specific |
| Random effects? | No | Yes |
| Working correlation? | Yes | Not in the same sense |
| Individual trajectories? | No explicit random trajectories | Yes |
| Population interpretation? | Natural | Requires marginalization for a population-level interpretation |
| Nonlinear effects | Marginal | Conditional |
| Robust variance | Central component | Not fundamental |
| Small number of clusters | Potential concern | Different issues arise, but not automatically solved |
| Subject-level prediction | Limited | Strong use case |
The Most Important Practical Rule
Do not begin by asking:
"Should I use GEE or a mixed model?"
Begin with:
"What treatment effect am I trying to estimate?"
If the desired answer is the average treatment effect across the population, GEE may provide the most direct framework.
If the desired answer involves individual trajectories, subject-specific effects, or between-subject heterogeneity, a mixed model may be more natural.
Then consider the outcome distribution, covariance assumptions, number of clusters, missing-data mechanism, and inferential method.
Practical Workflow for Clinical Researchers
Bottom Line
References
Liang, K.-Y. & Zeger, S.L. (1986). Longitudinal data analysis using generalized linear models. Biometrika, 73(1), 13–22.
Zeger, S.L., Liang, K.-Y. & Albert, P.S. (1988). Models for longitudinal data: a generalized estimating equation
approach. Biometrics, 44(4), 1049–1060.
Diggle, P., Heagerty, P., Liang, K.-Y. & Zeger, S. (2002). Analysis of Longitudinal Data.
Oxford University Press.
Fitzmaurice, G.M., Laird, N.M. & Ware, J.H. (2011). Applied Longitudinal Analysis.
Wiley.
McCulloch, C.E., Searle, S.R. & Neuhaus, J.M. (2008). Generalized, Linear, and Mixed Models.
Wiley.
Hedeker, D. & Gibbons, R.D. (2006). Longitudinal Data Analysis.
Wiley.