A Marginal Structural Model (MSM) is a statistical framework for estimating the causal effect of a treatment that varies over time on a subsequent outcome, specifically designed to handle time-dependent confounding—where a variable is both affected by prior treatment and affects future treatment and the outcome. The model is 'marginal' because it models the population-average (marginal) distribution of counterfactual outcomes, and 'structural' because it describes a causal, rather than purely associational, relationship.
Glossary
Marginal Structural Model (MSM)

What is Marginal Structural Model (MSM)?
A class of causal models designed to estimate the marginal effect of a time-varying treatment on an outcome in the presence of time-dependent confounding.
MSMs are typically estimated using Inverse Probability of Treatment Weighting (IPTW) to create a pseudo-population where treatment assignment is independent of measured confounders, thereby breaking the feedback loop between confounders and treatment. This approach avoids the bias introduced by standard regression adjustment for time-varying confounders, which can block causal pathways or introduce collider bias. The method requires the sequential ignorability assumption—that all confounders are measured—and correct model specification for the treatment weights.
Key Features of Marginal Structural Models
Marginal Structural Models (MSMs) are a robust class of causal models designed to estimate the marginal effect of a time-varying treatment on an outcome. They achieve this by using inverse probability of treatment weighting (IPTW) to create a pseudo-population where treatment assignment is independent of time-dependent confounders, thereby breaking the feedback loop between treatment history and covariates.
Inverse Probability of Treatment Weighting (IPTW)
The foundational estimation technique for MSMs. Each subject receives a weight inversely proportional to their probability of receiving the treatment they actually received, conditional on their covariate and treatment history.
- Stabilized Weights: A variant that reduces variability by multiplying the inverse probability weight by the marginal probability of treatment.
- Pseudo-Population: Weighting creates a synthetic sample where treatment is unconfounded, allowing a simple regression of the outcome on the treatment history to yield a causal estimate.
- Handles Feedback: Explicitly adjusts for scenarios where a confounder (e.g., CD4 count) is affected by prior treatment (e.g., antiretroviral therapy) and predicts future treatment.
Time-Dependent Confounding Adjustment
MSMs are uniquely suited to handle time-dependent confounders affected by prior treatment, a scenario where standard regression adjustment fails.
- The Feedback Loop: In longitudinal studies, a covariate like disease severity is both a confounder (predicts future treatment) and an intermediate variable (is affected by past treatment).
- G-Computation Alternative: While g-computation also addresses this, MSMs are often preferred for their ease of implementation with standard weighted regression software.
- Censoring Weights: An additional set of weights can be applied to adjust for potentially informative loss to follow-up, assuming censoring is random conditional on observed history.
Marginal vs. Conditional Effects
MSMs estimate a marginal (population-average) causal effect, contrasting with the conditional (subject-specific) effects from mixed models or G-estimation of structural nested models.
- Marginal Effect: Compares the expected outcome if the entire population were treated versus untreated, a parameter often most relevant for public health policy.
- Collapsibility: The odds ratio from a logistic MSM is non-collapsible, meaning the marginal effect differs from the conditional effect even without confounding.
- Link Function Choice: Using a log link for binary outcomes in an MSM directly estimates a marginal risk ratio, a collapsible measure that avoids the non-collapsibility issue of the odds ratio.
Positivity and Model Specification
Valid causal inference with MSMs depends critically on the positivity assumption and correct specification of the treatment and censoring models.
- Positivity: Requires a non-zero probability of each treatment level for every covariate history. Violations occur if a treatment is strictly contraindicated for a subgroup.
- Weight Truncation: Extreme weights can inflate variance. Truncating weights at a percentile (e.g., 1st and 99th) trades bias for precision.
- Doubly Robust MSMs: Combine IPTW with an outcome regression model to provide two chances to correctly specify the model, yielding a consistent estimate if either the treatment model or the outcome model is correct.
MSM vs. Standard Regression vs. Propensity Score Matching
Comparative analysis of three statistical approaches for estimating causal effects from observational data with time-varying exposures and confounders.
| Feature | Marginal Structural Model | Standard Regression | Propensity Score Matching |
|---|---|---|---|
Handles time-varying confounding affected by prior treatment | |||
Estimates marginal (population-level) treatment effects | |||
Requires positivity assumption for continuous treatments | |||
Adjusts for confounding via weighting rather than conditioning | |||
Susceptible to collider-stratification bias with time-varying covariates | |||
Requires correct specification of treatment model | |||
Naturally accommodates censoring by informative loss to follow-up | |||
Typical implementation uses stabilized inverse probability weights |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Direct answers to the most common technical questions about Marginal Structural Models and their application in longitudinal causal inference for biomedicine.
A Marginal Structural Model (MSM) is a class of causal models that estimates the marginal effect of a time-varying treatment on an outcome by adjusting for time-dependent confounding using Inverse Probability of Treatment Weighting (IPTW). Unlike standard regression adjustment, which can introduce collider-stratification bias when conditioning on variables affected by prior treatment, MSMs create a pseudo-population where treatment assignment is independent of measured confounders. The process involves two stages: first, estimating each subject's probability of receiving their observed treatment at each time point given their covariate and treatment history; second, fitting a weighted outcome model where each observation is weighted by the inverse of that probability. This stabilizes the causal contrast, allowing valid estimation of parameters like the Average Treatment Effect (ATE) in the presence of treatment-confounder feedback loops common in chronic disease progression studies.
Related Terms
Marginal Structural Models are part of a broader causal inference toolkit. These related concepts are essential for understanding time-dependent confounding and treatment effect estimation.
Inverse Probability of Treatment Weighting (IPTW)
The core estimation engine for MSMs. IPTW creates a pseudo-population where treatment assignment is independent of measured confounders. Each observation is weighted by the inverse of its probability of receiving the treatment it actually received, given its covariate history. Stabilized weights reduce variance by multiplying by the marginal probability of treatment.
Time-Dependent Confounding
The central problem MSMs are designed to solve. Occurs when a variable is simultaneously a confounder for future treatment and affected by prior treatment. Example: Disease severity affects both current treatment and future outcomes, but prior treatment also affects current severity. Standard regression adjustment fails here because it blocks the causal effect of prior treatment.
G-Estimation of Structural Nested Models
An alternative to MSMs for time-varying treatments. G-estimation models the contrast between observed and counterfactual outcomes rather than the marginal mean. It is more robust to model misspecification when treatment effects are homogeneous, but does not directly estimate population-average effects like MSMs do.
Censoring and Attrition Weights
MSMs handle informative censoring through inverse probability of censoring weighting (IPCW). When patients drop out for reasons related to their prognosis, IPCW up-weights uncensored individuals with similar covariate histories. The final weight is the product: IPTW × IPCW, creating a pseudo-population free of both confounding and selection bias.
Longitudinal Causal DAGs
Directed Acyclic Graphs with time-indexed nodes that explicitly represent the assumed causal structure over multiple time points. They distinguish between:
- Confounders (Lₜ): Affect both treatment and outcome
- Exposures (Aₜ): Time-varying treatments
- Outcome (Y): End-of-study result Essential for identifying which variables must be included in the IPTW model.
Positivity Assumption
A critical requirement for MSM estimation: at every level of confounder history, there must be a non-zero probability of receiving each treatment level. Violations occur with deterministic treatment rules (e.g., 'always treat if CD4 < 200'). Practical fix: Truncate extreme weights or use target trial emulation to exclude deterministic periods.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us