- Introduced by
- Robins, Hernan & Brumback (foundational MSM framework, 2000); heterogeneous-effect extensions developed throughout 2000s–2010s
- Year
- 2000–2010s
- Type
- Causal inference / weighted regression with effect modification
- Family
- Quasi-experimental / causal inference
What does it do?
The Heterogeneous Treatment Effect Marginal Structural Model extends the marginal structural model (MSM) framework of Robins, Hernan, and Brumback to estimate how a treatment effect varies across subgroups or along a continuous pre-treatment moderator.
Inverse probability of treatment weights (IPTW) reduce confounding by measured variables, and an interaction between treatment and the moderator in the weighted outcome model produces subgroup-specific or continuous causal effect estimates from observational data under identifying assumptions.
The intuition behind the method
A standard MSM estimates the average causal effect of a treatment in the whole population after re-weighting to remove measured confounding. In practice, a treatment often helps some people more than others. The heterogeneous-effect version adds interaction terms between the treatment and pre-treatment characteristics that may modify the effect, such as age, sex, or baseline severity, within the same IPTW-weighted regression. The interaction coefficient then shows how the causal effect changes as the moderator changes. Because the interaction is estimated in the weighted pseudo-population rather than in the raw data, measured confounding that can distort a simple stratified regression on unweighted data is balanced across treatment groups. This holds only if the propensity model is correctly specified and no important confounders are unmeasured.
History
Marginal structural models were introduced in a 2000 paper by Robins, Hernan and Brumback. They estimate causal effects of time-varying treatments in the presence of time-dependent confounders that are themselves affected by earlier treatment, using inverse-probability-of-treatment weighted (IPTW) estimators. The heterogeneous-effect variant applies the same weighting and adds treatment-by-moderator interaction terms to the weighted outcome model.
When to use it
Use HTE-MSM when the data are observational, the aim is a causal treatment effect, and there is a substantive reason to expect the effect to differ by a pre-treatment moderator that has been measured. It is particularly suited to time-varying treatments that are affected by earlier treatment or by time-varying confounders, where standard regression adjustment is biased. Do not use it when important confounders are unmeasured, when a moderator is itself affected by treatment (conditioning on it then changes the target effect), when propensity score overlap fails within some moderator levels, or when the sample is too small to estimate the interaction terms reliably. The causal reading rests on four assumptions: consistency (the treatment is well defined and there is no interference between units), conditional exchangeability given the measured confounders, positivity within each level of the moderator, and correct specification of both the propensity and outcome models.
Limitations and considerations
- Relies on the no-unmeasured-confounding (exchangeability) assumption, which cannot be tested from the data and may fail in practice.
- The positivity assumption requires every unit to have a non-zero probability of each treatment level within every moderator subgroup; violations produce extreme weights and unstable estimates.
- Interaction terms need substantially larger samples than main-effect MSMs, and power falls quickly when moderators are continuous or numerous.
- Misspecification of the propensity model biases both the average effect and the heterogeneity estimates at the same time.
- The number of subgroup effects that can be estimated reliably is limited by sample size and overlap; many interaction terms risk overfitting.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Handles time-varying treatments and time-varying confounders that are affected by prior treatment, a setting in which conventional regression adjustment is biased.
- Recovers subgroup-specific causal effects from observational data by combining IPTW re-weighting with interaction terms in the weighted outcome model.
- The interaction parameters have counterfactual interpretations under the identifying assumptions, unlike effects from a regression fitted to unweighted, stratified data.
- Stabilised weights typically have lower variance than unstabilised IPTW weights, so the weighted analysis is more precise than it would be with raw weights; compared with an unweighted analysis, the gain is in removing confounding bias, not in efficiency.
- Can be paired with several outcome model types, but the coefficients of logistic and survival models are conditional, not marginal, log-odds or log-hazard ratios, so interaction terms on those scales need careful interpretation.
Applications
- Estimating whether the causal effect of a drug or medical intervention varies by patient age, sex, or baseline disease severity in pharmacoepidemiology.
- Identifying which subgroups benefit most from a public health or social policy programme when treatment was not randomised.
- Assessing whether the effect of a time-varying exposure, such as cumulative medication dose, on long-term outcomes differs across demographic strata.
- Evaluating heterogeneous causal effects of occupational or environmental exposures across groups with different vulnerability.
- Precision medicine analyses that aim to identify patients for whom the estimated causal benefit of treatment is largest, using observational data.
How it works
How it works
Inverse probability of treatment weights are built from models for the probability of the treatment actually received, given measured confounders and treatment history. The formula shown is the stabilised weight: its numerator conditions only on past treatment, and the unstabilised weight replaces that numerator with 1. The weighted pseudo-population is designed so that treatment is independent of the measured confounders, approximating what randomisation would achieve.
Formula
w_i = \prod_{t} \frac{P(A_t \mid \bar{A}_{t-1})}{P(A_t \mid \bar{A}_{t-1}, \bar{L}_t)}The outcome model is fitted to the weighted data. Besides the treatment indicator A, it includes an effect modifier V and the product A x V, so the treatment effect is allowed to depend on V. In observed-data form the model is E[Y | A, V] in the weighted pseudo-population. Under consistency, conditional exchangeability given measured confounders, positivity and correct model specification, the treatment-by-moderator contrasts identify causal effects conditional on V. The scale matters: with an identity link, the treatment coefficient and the interaction coefficient are causal differences in means. With a log or logit link, the interaction coefficient is a conditional ratio on the link scale and is not a marginal contrast, so standardised (marginal) effects should be reported for each level of the moderator.
Formula
E[Y^{\bar{a}}] = \beta_0 + \beta_1 A + \beta_2 V + \beta_3 (A \times V)For a continuous moderator, the conditional causal effect at V = v is beta_1 + beta_3 v, so beta_3 gives the change in the treatment effect per unit change in V. For a categorical moderator, the same logic applies to the contrasts between category-specific effects.
Formula
\tau(v) = \beta_1 + \beta_3 V = E[Y^{a=1} - Y^{a=0} \mid V=v]Stabilised weights, whose numerator conditions on past treatment history, are generally preferred to unstabilised weights because they typically have lower variance. The unstabilised weight is the product over time of 1 divided by P(A_t | past treatment history and time-varying covariates), that is, the same denominator with a numerator of 1. Trimming very large weights is a common additional step; it reduces variance but introduces some bias, so its use should be reported.
Formula
sw_i = \prod_{t} \frac{P(A_t \mid \bar{A}_{t-1})}{P(A_t \mid \bar{A}_{t-1}, \bar{L}_t)}Because the weights are estimated, ordinary model-based standard errors are not appropriate, since they ignore the uncertainty in the propensity model. A bootstrap that re-estimates the propensity model, the weights and the weighted outcome model in each resample is a practical way to obtain valid confidence intervals. A standard sandwich estimator does not by itself account for the estimation of the propensity model. Weight diagnostics, such as the effective sample size and the weight distribution, should be reported alongside the estimates.
Common pitfalls
- Fitting the interaction model to unweighted data and calling it an MSM. The IPTW step is required for the causal reading.
- Ignoring weight diagnostics. Extreme or highly variable weights can distort the pseudo-population and should be checked using the effective sample size and the weight distribution.
- Treating an interaction in an observational regression as a causal moderating effect without checking the identifying assumptions. The weighted interaction supports a causal reading only if confounding is adequately controlled and the model is correctly specified.
- Using continuous moderators without checking whether the propensity model controls confounding across the whole range of the moderator.
- Overlooking positivity when the moderator strongly predicts treatment receipt, which leads to near-zero propensity scores in some subgroups.
Frequently asked questions
How does HTE-MSM differ from a standard MSM?
A standard MSM estimates the population-average causal effect of treatment. HTE-MSM adds interaction terms between treatment and pre-specified effect modifiers to the weighted outcome model, so the causal effect can vary across subgroups or along a continuous moderator. The IPTW weighting step is the same; the difference lies in the outcome model specification.
Why not just stratify by subgroup and run a separate MSM in each stratum?
Stratification can work when subgroups are large, but it loses statistical efficiency, makes cross-stratum comparisons informal, and may violate positivity within small strata. The interaction-based HTE-MSM uses the full sample to estimate the interaction, while still giving subgroup-specific effects.
What sample size is needed?
Substantially more than for a main-effect MSM, because interaction terms are estimated with less precision. No fixed rule applies to weighted observational analyses. Simulation or a formal power analysis that reflects the expected weight variability and overlap is advisable before data collection.
Can this be combined with doubly robust methods?
Yes. Augmented IPTW (AIPW) or targeted maximum likelihood estimation (TMLE) can replace pure IPTW to obtain doubly robust heterogeneous effect estimates, which remain consistent if either the propensity model or the outcome model, but not necessarily both, is correctly specified.
Does HTE-MSM handle multiple time points?
Yes. In longitudinal settings the product-of-ratios IPTW formula extends across time periods, and the moderator interaction is included in the weighted, pooled-over-time outcome model. Handling time-varying confounding that standard methods cannot address is the original motivation for the MSM framework.
Related methods
Sources
Robins, J. M., Hernan, M. A., & Brumback, B. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology, 11(5), 550-560.
Open DOI referenceHernan, M. A., & Robins, J. M. (2020). Causal Inference: What If. Chapman & Hall/CRC.
Open publication reference