← Methods repository
CONCEPTADVANCEDPYTHON · R · SAS4 citations

Longitudinal Outcomes Modeling

A family of regression methods for repeatedly-measured (panel) outcomes on the same patients over time, whose central choice is whether the target estimand is subject-specific (conditional, from a mixed model) or population-averaged (marginal, from GEE), with MMRM as the regulatory-favored special case for continuous endpoints.

Inferential Statisticslongitudinal-outcomes-modelingrepeated-measuresmixed-effects-modelsgeemmrmmarginal-vs-conditionalpanel-datamissing-data-mar
On this page
Methods reference only. Use primary source citations and local policy before applying this in a study protocol, regulatory submission, payer dossier, or clinical decision.
Child concepts

Explore this method family

In plain language

Longitudinal outcomes modeling analyzes outcomes that are measured on the same patient at multiple points in time — for example, a blood sugar value recorded at every clinic visit for a year. Because measurements from the same person tend to move together (a patient who runs high in January is likely to run high in June), you cannot treat each visit row as if it came from a different person; doing so underestimates uncertainty and can produce false-positive findings. These methods explicitly account for that within-person similarity, letting you estimate how a patient's outcome trajectory changes over time and whether treatment alters that trajectory. The main decision you face is whether you want a result about a specific patient's own trend (a subject-specific model) or about the average trend in the whole population (a population-averaged model).

When to use it
Non-trivial or informative dropout, an individual-trajectory question, or a continuous confirmatory endpoint (where MMRM is the special case).
Irregular visit timing, or when the unstructured covariance is too rich to estimate with the available patients/visits.
The estimand concerns the value of a continuous/scalar outcome over time, not whether or when an event happens.
Watch out for
Assumes a correctly-specified random-effect distribution; the conditional vs marginal gap under non-linear links confuses non-statistical audiences; more sensitive to misspecification.
Imposes a trajectory shape and a structured covariance, which MMRM deliberately avoids; less defensible as a confirmatory primary analysis.
Wrong family for event occurrence; mishandles immortal time, censoring, and competing risks that survival/recurrent-event methods are designed for.

Longitudinal outcomes modeling

addresses the analytic problem created when each patient contributes multiple measurements of the same outcome over time — monthly HbA1c, quarterly total cost, repeated PHQ-9 or pain scores, serial eGFR. Those measurements are correlated within a patient, so ordinary regression that treats every (person, time) row as independent reports standard errors that are too small and tests that are anti-conservative.

This entry is the family-level decision concept: it does not re-derive any single model but tells you how to choose among a linear mixed-effects model (LMM), a generalized estimating equation (GEE), a mixed-model repeated measures (MMRM) analysis, and a generalized linear mixed model (GLMM) for a binary or count longitudinal outcome — and, just as importantly, when a longitudinal model is the wrong tool and a time-to-event or count-rate model belongs instead.

The detailed mechanics of each member live in the sibling concepts (`mixed-effects-models-longitudinal-rwe`, `gee-population-average-models-rwe`, `mmrm-repeated-measures-rwe`); the value added here is the estimand-first selection logic.

Core estimand distinction

. The single most consequential — and most frequently botched — choice is conditional vs marginal. A mixed model with a random patient intercept (or slope) estimates a subject-specific (conditional) effect: the expected change in a given patient's outcome holding that patient's random effect fixed ("how much does this patient's HbA1c fall on drug A vs what it would have been on drug B"). A GEE estimates a population-averaged (marginal) effect: the contrast in the population mean outcome between exposure groups, averaging over the random-effect distribution.

For an identity-link Gaussian outcome the two coefficients coincide, so the LMM-vs-GEE debate is mostly about robustness and missing-data assumptions. For a non-linear link (logistic, log) they do not coincide: the marginal log-odds is attenuated toward the null relative to the subject-specific log-odds by a factor governed by the random-effect variance, so a GLMM and a GEE on the same binary panel return numerically different — and differently interpretable — estimates.

Hubbard et al. (2010) make this the explicit deciding question: report a marginal effect when the audience is a population/policy contrast (utilization, budget impact, a coverage decision) and a subject-specific effect when the clinical question is about an individual patient's trajectory.

MMRM is a particular LMM for a continuous endpoint that uses only fixed effects for time (categorical visit) with an unstructured within-patient covariance and no random subject effect, giving a marginal-mean estimate at each visit that is valid under missing-at-random (MAR) — which is why the PhRMA working group and FDA reviewers treat it as the default primary analysis for continuous longitudinal trial-like endpoints (Mallinckrodt et al., 2008).

Interpreting the output

Longitudinal modeling produces different outputs depending on which family member you choose, and the estimand determines which number is reported.

If a linear mixed model (LMM) with random intercepts was fit to serial HbA1c data, a fixed-effect treatment coefficient of −0.90 means: for a given patient, the drug arm reduces HbA1c by 0.90 points more than the comparator on average over follow-up, holding that patient's own random intercept (and slope, if modeled) fixed. This is a subject-specific (conditional) estimate — appropriate when the clinical question is about an individual patient's trajectory.

If a GEE was fit to the same data with a log link for binary or count outcomes, the exponentiated coefficient is a population-average (marginal) rate ratio or odds ratio — the contrast between group means averaging over the patient distribution. For a Gaussian identity-link outcome the conditional (LMM) and marginal (GEE) coefficients coincide; for non-linear links (logit, log) the conditional coefficient is larger in magnitude. Pre-specifying which estimand you target — and which model delivers it — is mandatory before seeing results.

If MMRM was fit for a continuous endpoint at scheduled visits, the primary output is the arm-by-visit interaction contrast at the target visit (e.g., mean difference in eGFR change from baseline at Month 12 = 6.4 mL/min, 95% CI 4.1 to 8.7), a marginal estimate valid under missing-at-random. Route to the appropriate sibling entry (`mixed-effects-models-longitudinal-rwe`, `gee-population-average-models-rwe`, `mmrm-repeated-measures-rwe`) for method-specific output interpretation.

Pros, cons, and trade-offs

.

  • Mixed model (LMM/GLMM) vs GEE: The mixed model gives a likelihood, valid inference under MAR (missingness can depend on observed prior outcomes), subject-specific interpretation, and direct modeling of the correlation structure via random effects; it can borrow strength to predict individual trajectories. Cost: it assumes the random-effect distribution is correctly specified, the conditional/marginal gap confuses non-statistical audiences for non-linear links, and it is more sensitive to misspecification. GEE is semiparametric, needs only the mean model correct (the working correlation can be wrong) with sandwich/robust SEs, and yields the population-averaged effect directly. Cost: GEE is only valid under missing-completely-at-random (MCAR) unless you add inverse-probability-of-observation weights, it discards partially-observed cycles less gracefully, and the sandwich variance is unreliable with few clusters (<~40 patients). Prefer the mixed model / MMRM when dropout is non-trivial (the norm in RWE); prefer GEE for a clean marginal effect with many patients and near-MCAR missingness.
  • MMRM vs a random-slope LMM with parametric time: MMRM (categorical visit, unstructured covariance) makes the fewest assumptions about the shape of the time trend and the form of the covariance, which is why it is regulatory-preferred; it needs roughly balanced, pre-specified visit windows and enough patients to estimate the full covariance. A random-slope LMM with continuous time is more parsimonious and handles irregular measurement times — common in claims/EHR — but imposes a trajectory shape (linear, spline) and a structured covariance. Prefer MMRM for a confirmatory continuous endpoint with scheduled visits; prefer a parametric-time LMM when visit timing is irregular or the covariance is too rich to estimate.
  • Longitudinal mean model vs the time-to-event / count families: If the question is "time to first event" or "are events recurring faster," a longitudinal mean model is the wrong family — use survival (`standard-cox-time-dependent`, `cumulative-incidence-risk-rwe`) or recurrent-event/count methods (`recurrent-events-analysis-rwe`, `poisson-negative-binomial-count-models`). Modeling a repeatedly-measured continuous or scalar outcome is this family's job; modeling event occurrence is not.

When NOT to use — and when it is actively misleading or dangerous

.

  • The outcome is an event, not a repeated measurement. Forcing "did the patient have an MI this month (0/1)" into a GLMM panel when the real question is incidence invites immortal-time and informative-censoring problems that survival/recurrent-event methods are built to handle; use those instead.
  • Reporting a conditional estimate for a population question (or vice versa). Presenting a subject-specific GLMM odds ratio as if it were the population-averaged effect a payer cares about — or a marginal GEE estimate as an individual-patient prognosis — is a silent estimand error that survives every model diagnostic and is genuinely misleading.
  • GEE with informative dropout. In RWE the sicker arm typically drops out or disenrolls faster; under that MAR-not-MCAR pattern, naive GEE is biased toward the null while an MMRM/LMM remains valid — defaulting to GEE "because it's marginal" can fabricate a false equivalence.
  • Too few clusters/patients. With a small number of patients the GEE sandwich SE is downward-biased and the mixed-model variance components are unstable; tests become anti-conservative.
  • Outcome measured at a single time point. There is no within-patient correlation to model; a longitudinal apparatus adds nothing and can obscure a simple cross-sectional contrast.

Data-source operational depth

.

  • Claims (FFS or commercial): The "repeated measurement" is usually a constructed monthly or quarterly aggregate — total paid cost, fill-derived adherence, a flag for any qualifying diagnosis — built by binning claims into fixed windows keyed off `index_date`. Two failure modes dominate. (1) MA-only person-time: months in which a patient is enrolled in Medicare Advantage (or a capitated arrangement) have no fee-for-service claims, so a "$0 cost" or "no diagnosis" cell is missingness disguised as data; you must carry an enrollment indicator and drop or explicitly model those cells, not treat them as observed zeros. (2) Differential disenrollment by arm makes month-level missingness depend on the (unobserved future) outcome — MAR at best — so an LMM/MMRM under MAR is safer than GEE; restrict to continuous medical+pharmacy enrollment per cycle and verify balance of observed person-months across arms.
  • EHR: Labs and PROs are recorded only when a visit happens, so measurement timing is irregular and informatively sampled — the sicker arm is drawn more often, which biases any method that assumes measurement times are unrelated to the outcome. Prefer a parametric-time LMM (continuous time, not categorical visit) and consider modeling the visit process; never assume equally-spaced visits when feeding a GEE working correlation like AR(1) that presumes equal spacing. Patients who leave the system are differentially lost; treat loss to follow-up as potentially informative.
  • Registry: Visit schedules are often protocolized (an advantage for MMRM), and outcomes may be adjudicated, but pharmacy exposure and out-of-registry care are weak; link to claims for complete exposure and to a death index so that "missing" late visits are correctly distinguished from death (a competing terminal event that must not be modeled as ordinary MAR dropout).
  • Linked claims–EHR–vital records: The ideal substrate — EHR severity and lab values, claims completeness, reliable mortality — but linkage selects the linkable subset and introduces date-discrepancy between order, fill, and service dates that must be reconciled before binning measurements into cycles relative to time zero.

Worked claims example

Question: 12-month HbA1c trajectory after initiating a DPP-4 inhibitor vs a second-generation sulfonylurea in an active-comparator new-user cohort (commercial + Medicare FFS). (1) Cohort: incident initiators with 365 days of continuous A/B/D (or commercial medical+pharmacy) enrollment before the first qualifying fill; `index_date` = that fill; arm = NDC dispensed that day.

(2) Build the panel: define visits at months 0, 3, 6, 9, 12; for each (`person_id`, `visit`) take the HbA1c lab value nearest the scheduled month within a ±45-day window from the linked EHR/lab feed; carry an `observed` flag and an `enroll_ffs` flag per cycle so MA-only or disenrolled months are missing, not zero.

(3) Fit three models on the same panel to make the estimand visible:

  1. MMRM — `PROC MIXED` with categorical `visit`, `arm`, `visit*arm`, baseline HbA1c as covariate, and `REPEATED visit / SUBJECT=person_id TYPE=UN` (unstructured), reading the month-12 `visit*arm` LS-means contrast as the regulatory primary marginal effect under MAR;
  2. GEE — exchangeable working correlation with robust SEs for the population-averaged mean difference;
  3. random-intercept LMM for the subject-specific trajectory.

(4) Expect the MMRM and random-intercept-LMM fixed effects to be similar (Gaussian, identity link) but their standard errors and missing-data validity to differ, and report the MMRM contrast as primary because dropout is informative. (5) Sensitivity: pattern-mixture or multiple-imputation under not-MAR (`multiple-imputation-longitudinal-rwe`), alternative covariance structures (TYPE=AR(1), TYPE=CS), and a tipping-point analysis on the month-12 contrast.

Decision diagram

flowchart TD
  Start[Repeatedly-measured outcome per patient over time] --> Q0{Is the outcome an EVENT<br/>occurrence/timing?}
  Q0 -->|Yes| TTE[Use survival / recurrent-event / count family<br/>NOT a longitudinal mean model]
  Q0 -->|No: continuous / scalar level| Q1{Target estimand?}
  Q1 -->|Population-averaged<br/>marginal mean contrast| Q2{Missingness mechanism?}
  Q1 -->|Subject-specific<br/>individual trajectory| LMM[Mixed model: LMM / GLMM<br/>random effects, valid under MAR]
  Q2 -->|Near-MCAR, many patients| GEE[GEE: working correlation + robust SE]
  Q2 -->|Informative / MAR dropout| MMRM[MMRM: categorical visit, UN covariance<br/>marginal mean, valid under MAR]
  LMM --> Report[Report estimand explicitly + missing-data + sensitivity]
  GEE --> Report
  MMRM --> Report
Family-level selection logic. The first fork rules out event outcomes (a different family); the second fork is the conditional-vs-marginal estimand choice; the third fork uses the missing-data mechanism to choose GEE (MCAR) vs MMRM (MAR) for a marginal estimand.
flowchart LR
  Conditional[Subject-specific / conditional<br/>random-effects model] -->|identity link, Gaussian| Same[Estimates COINCIDE]
  Marginal[Population-averaged / marginal<br/>GEE] -->|identity link, Gaussian| Same
  Conditional -->|non-linear link logit/log| Gap[Estimates DIVERGE:<br/>marginal attenuated toward null<br/>by random-effect variance]
  Marginal -->|non-linear link logit/log| Gap
Why the conditional-vs-marginal choice matters. For a Gaussian outcome with an identity link the two estimands give the same coefficient; for a logistic or log link they diverge, and a GLMM and GEE on the same binary panel are not interchangeable.

Worked example

Scenario

A researcher is studying monthly pain scores (0-10 scale) in five patients with chronic knee pain enrolled in a 3-visit study (baseline, month 3, month 6). All five patients are measured at each visit. The goal is to describe the average pain trajectory over 6 months. Before fitting any model, the researcher checks whether it is valid to treat each row in the dataset as independent. This small example shows why it is not, and what the long-format data actually looks like.

Dataset

Long-format pain score table — one row per patient per visit (15 rows total for 5 patients x 3 visits).

patient_idvisit_monthpain_score
108
136
165
204
233
263
307
335
364
405
434
464
509
537
566

Steps

1Notice that each patient appears in three rows. Patient 1 starts at 8, drops to 6, then 5. Patient 5 starts at 9 and also trends down. The data already hints that a high baseline score tends to pair with high later scores — within the same person.
2If you ran a naive ordinary regression ignoring patient identity, the model would treat all 15 rows as independent observations from 15 different people. It would see 15 pain scores and estimate a trend, but its standard error would be too small because it is pretending there are 15 independent data points when there are really only 5 independent patients.
3A longitudinal model adds a patient-level term that captures each person's overall average pain level. Patient 5 runs about 2 points higher than Patient 2 across all visits; the model learns this and no longer treats those differences as mysterious noise.
4With within-person correlation accounted for, the model estimates the average trajectory across all five patients: baseline mean of 6.6, month-3 mean of 5.0, month-6 mean of 4.4 — a drop of about 2.2 points over 6 months.
5Because the model correctly assigns observations to their source patients, the uncertainty estimate (standard error) around the 2.2-point drop reflects having 5 independent patients, not 15 independent rows. This gives an honest picture of how confident we should be.

Result

Average pain score fell from 6.6 at baseline to 4.4 at month 6 — a mean reduction of 2.2 points over 6 months. Accounting for within-person correlation (5 patients, not 15 independent rows) produces a standard error roughly 1.5-2x wider than a naive independent-row analysis would, correctly reflecting that the effective sample size is 5, not 15.

Trade-offs

vs. GEE (population averaged marginal model)
Pros of this
Likelihood-based and valid under MAR (the realistic RWE dropout mechanism); subject-specific interpretation; can predict individual trajectories and model the correlation explicitly.
vs. MMRM with unstructured covariance
Pros of this
A random-slope/continuous-time LMM is more parsimonious and handles irregular measurement times common in claims and EHR.
vs. Time to event and count/recurrent event models
Pros of this
Directly models the level or trajectory of a repeatedly-measured scalar outcome (cost, lab, PRO).

Runnable example

Fit a subject-specific LMM and a population-averaged GEE on the SAME longitudinal claims panel to expose the estimand difference. Required input (one row per person-visit, already built and cleaned): panel : person_id, visit (int month: 0,3,6,9,12), arm ('DPP4'/'SU'), hba1c (float outcome), hba1c_baseline (float),...

requires: pandas · statsmodels
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf

panel = panel[panel["observed"] == 1].copy()        # missing cycles are NOT observed zeros
panel["visit"] = panel["visit"].astype("category")   # categorical visit -> MMRM-style means

# (a) Subject-specific: random intercept per patient, treatment-by-visit interaction.
lmm = smf.mixedlm(
    "hba1c ~ C(arm) * visit + hba1c_baseline",
    data=panel,
    groups=panel["person_id"],
).fit(reml=True)
print(lmm.summary())   # coefficients are CONDITIONAL (subject-specific)

# (b) Population-averaged: GEE with exchangeable working correlation + robust (sandwich) SE.
gee = smf.gee(
    "hba1c ~ C(arm) * visit + hba1c_baseline",
    groups="person_id",
    data=panel,
    cov_struct=sm.cov_struct.Exchangeable(),
    family=sm.families.Gaussian(),
).fit()
print(gee.summary())   # coefficients are MARGINAL (population-averaged)
# Gaussian/identity -> point estimates align; SE & missing-data validity (MAR vs MCAR) differ.

Citations

FOUNDATIONAL / METHODS
  1. [1]Liang KY, Zeger SL. Longitudinal data analysis using generalized linear models. Biometrika. 1986;73(1):13-22.
  2. [2]Laird NM, Ware JH. Random-effects models for longitudinal data. Biometrics. 1982;38(4):963-974.
  3. [3]Hubbard AE, Ahern J, Fleischer NL, et al. To GEE or not to GEE: comparing population average and mixed models for estimating the associations between neighborhood risk factors and health. Epidemiology. 2010;21(4):467-474.
APPLIED EXAMPLES
  1. [4]Mallinckrodt CH, Lane PW, Schnell D, Peng Y, Mancuso JP. Recommendations for the primary analysis of continuous endpoints in longitudinal clinical trials. Drug Information Journal. 2008;42(4):303-319.