Marginal structural models with IPTW
A marginal structural model uses treatment weights to compare treatment histories when earlier treatment changes later confounders.
Fit
When to use it, and when not to
Use it when
- A measured marker both guides later treatment and responds to earlier treatment.
- You can reconstruct treatment decisions and confounders before each decision.
Not when
- Treatment is assigned only at baseline. A baseline propensity-score analysis may answer the question. Read: Inverse probability of treatment weighting (IPTW)
- Key reasons for changing treatment were not measured. Plan sensitivity analysis; weights cannot fill that gap. Read: Sensitivity analyses
Before you start
What you need
- Treatment histories and follow-uptargetDefine sustained or changing strategies and a shared time zero.
- Data before each treatment decisionRecord previous treatment and confounders measured before the current decision.
- Weight and outcome modelssummaryMeasureChoose the effect scale, numerator, denominator, censoring model and diagnostics before fitting.
- Measured history explains each treatment decision relevant to the outcome.How to check: This is sequential exchangeability. Use clinical knowledge to identify unmeasured reasons for treatment changes.
- Each strategy is possible within relevant measured histories.How to check: Inspect support over time. Extreme weights may expose sparse support; truncating weights trades bias against precision.
- Each strategy represents a well-defined treatment.How to check: Specify dose, timing and versions. Rule out interference or account for it in the design.
- Weight and outcome models are suitable.How to check: Check weighted balance at each visit, weight tails and effective sample size. Add censoring weights when dropout needs them.
- Choose a missing-data method because of a stated assumption.How to check: Missing completely at random (MCAR) means gaps depend on neither observed nor unseen data. Missing at random (MAR) means recorded data explain gaps. Under MAR, suitable multiple imputation may help; it is not inherently better. Missing not at random (MNAR) means unseen values still predict gaps. Under plausible MNAR, add a delta or tipping-point sensitivity analysis. Dropping people with missing exposure can cause selection bias.
Plain language
How it works
Inverse probability of treatment weights (IPTW) give more weight to histories that were unlikely given measured health. Multiply each visit’s probability ratio across visits. The denominator uses past treatment and confounders; a stabilized numerator uses a smaller history. If baseline covariates enter the numerator, include them in the outcome model and standardize as needed.
Fit the chosen marginal structural outcome model using these weights. Use patient-level robust uncertainty or a bootstrap that re-estimates weights. The final effect compares specified strategies under the assumptions. A weighted model does not make those assumptions true.
Worked example
A worked example
- Setting
- Treatment can change at each of two clinic visits.
- Question
- How much weight does one observed treatment history receive?
- Approach
- The observed treatment probabilities are 0.50 and 0.25 given full history. Numerator probabilities given past treatment alone are 0.50 and 0.50.
- Result
- The numerator product is 0.25; the denominator product is 0.125. The stabilized weight is 0.25 / 0.125 = 2.
- What it means
- This patient contributes twice the usual weight. It is a weight calculation, not a fitted treatment effect.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
Weights cannot recover unmeasured treatment decisions or create support for impossible treatment histories. A stable-looking weight distribution does not establish exchangeability.
- Adjusting the final model for a treatment-affected confounder as if it were baseline.Instead: Use the time-ordered history in the weight model. Ensure the final model matches the causal contrast.
- Ignoring untreated visits.Instead: Use the probability of the treatment actually observed, including no treatment.
- Truncating extreme weights without reporting it.Instead: Report the thresholds and how estimates change under other choices.
Inside Mallard
How Mallard uses this
Plans do not link to this method yet. You can find it in Learn and the Atlas.
analysis.marginal_structural_iptw, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- Marginal structural models and causal inference in epidemiology (opens in a new tab) · Epidemiology · doi 10.1097/00001648-200009000-00011
- Marginal structural models to estimate the causal effect of zidovudine on the survival of HIV-positive men (opens in a new tab) · Epidemiology · doi 10.1097/00001648-200009000-00012
- Constructing inverse probability weights for marginal structural models (opens in a new tab) · Am J Epidemiol · doi 10.1093/aje/kwn164