Bayesian Marginal Structural Model

Statistics
Introduced by
Saarela, Stephens, Moodie & Klein (Bayesian extension); Robins, Hernan & Brumback (original MSM)
Year
2015 (Bayesian extension); 2000 (MSM foundation)
Type
Causal inference / Bayesian weighted regression
Family
Quasi-experimental / causal inference

What does it do?

Bayesian Marginal Structural Model (Bayesian MSM) applies Bayesian posterior inference to the structural model of an inverse-probability-weighted marginal structural model, which is used to estimate causal effects of time-varying treatments.

Saarela et al. (2015) give the inverse-probability weights a Bayesian interpretation and propose a fully Bayesian procedure for estimating MSM parameters. The output is a posterior distribution over causal parameters, but whether uncertainty in the weight model is carried into that posterior depends on the implementation.

The intuition behind the method

Marginal structural models use inverse-probability weights to construct a pseudo-population in which treatment assignment is independent of measured time-varying confounders, which allows an unconfounded estimate of the effect of a time-varying treatment. The classical MSM then fits a weighted regression and reports frequentist confidence intervals. The Bayesian MSM replaces that final step with Bayesian inference: prior beliefs are placed on the structural-model parameters, and the weighted likelihood updates them to a posterior distribution. This is most useful when the sample is small or moderate, when prior evidence from earlier studies can be defended scientifically, or when a downstream decision model needs a full posterior predictive distribution rather than a single estimate.

History

Robins, Hernan and Brumback (2000) introduced marginal structural models and inverse-probability-of-treatment weighted estimators for consistent estimation of causal effects when time-dependent confounders are also affected by previous treatment. Saarela, Stephens, Moodie and Klein (2015), in Biometrics, describe their procedure as the first fully Bayesian procedure for estimating MSM parameters with inverse-probability-of-treatment weighting. Their approach derives the weights from the posterior predictive treatment assignment and censoring probabilities.

When to use it

Use Bayesian MSM when you have longitudinal or panel data with time-varying treatments and time-varying confounders that are themselves affected by past treatment, the setting in which standard regression adjustment is biased. Choose the Bayesian version when the sample is small or moderate and large-sample frequentist intervals may be unreliable, when prior information from previous studies is available and can be justified, or when the results feed a decision model that needs a full posterior predictive distribution. If you want the uncertainty in the weights to be reflected in the posterior, use the fully Bayesian procedure in which weights come from the posterior predictive treatment assignment and censoring probabilities (Saarela et al., 2015); a Bayesian MSM with plug-in weights may understate posterior variance. Do not use it when treatment is fixed at baseline, where a standard propensity-score method is sufficient. Do not use it when no prior information is available and the sample is large, because the classical MSM-IPW estimator is simpler and gives the same type of causal estimate. Do not use it when the MCMC software and computing resources are not available.

Limitations and considerations

  • Requires correct specification of both the treatment (weight) model and the structural outcome model; misspecification of either can bias causal estimates.
  • Computationally intensive: MCMC sampling for complex longitudinal models can be slow, and fully propagating the uncertainty in the weights adds further cost.
  • Sensitivity to the prior can be substantial when data are sparse, so results should be accompanied by a prior-sensitivity analysis.
  • Stabilised weights can still be highly variable when positivity is nearly violated, which inflates variance regardless of the Bayesian framework.
  • Fewer ready-made implementations exist than for the frequentist MSM, so the analyst often has to write and check the sampling code.

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 earlier treatment. Robins et al. (2000) show that standard approaches are biased in this setting, and the weighting in MSMs is designed to address it.
  • Gives a full posterior distribution for the causal parameters, so uncertainty is reported without relying on asymptotic standard errors for the summary.
  • Allows prior knowledge from previous trials, meta-analyses, or expert elicitation to enter the analysis in a formal way.
  • Posterior predictive distributions can be passed directly into downstream decision analysis and policy simulation.
  • A 95% credible interval has a direct probability reading under the stated prior, likelihood and weight model: there is a 95% posterior probability that the causal effect lies in the interval. If plug-in weights are used, the interval may be too narrow.

Applications

  • Saarela et al. (2015) applied the Bayesian procedure to data from the Canadian Co-infection Cohort, after comparing it with existing methods in simulated data.
  • Illustrative setting: longitudinal HIV cohorts in which treatment regimens change over time and the outcome is viral suppression.
  • Illustrative setting: repeatedly prescribed medications, where time-varying measures are affected by earlier prescribing decisions.
  • Illustrative setting: decision-analytic health technology assessment, where posterior distributions of treatment effects are needed as inputs to cost-effectiveness models.
  • Illustrative setting: programme evaluations with repeated participation decisions, such as job-training attendance across several periods.

How it works

How it works

1

A treatment model is specified for each time point. For unit i, the numerator is the probability of the observed treatment at time k given past treatment history alone, and the denominator is the probability of the observed treatment given past treatment history and measured time-varying covariates. The ratios are multiplied over time points k = 1,...,t, where t is the time index of the observation, giving the stabilised inverse-probability weight for that unit.

Formula
w_t = \prod_{k=1}^{t} \frac{P(A_k \mid \bar{A}_{k-1})}{P(A_k \mid \bar{A}_{k-1}, \bar{L}_k)}
2

Weights are estimated from the observed data, typically with logistic regression or machine-learning classifiers for binary treatments, or with density-ratio or density regression for continuous treatments. Saarela et al. (2015) argue that the weights should be derived from the posterior predictive treatment assignment and censoring probabilities, which makes the weight uncertainty part of the Bayesian analysis. In common practice, plug-in weights from a frequentist treatment model are used instead, and the posterior then does not reflect the uncertainty in those weights.

3

The structural model is a regression of the counterfactual mean outcome on treatment and time. The displayed formula is a simplified special case in which the effect depends only on the current treatment level and time. The superscript refers to a full treatment history, so in general the model should express how that history enters, for example through cumulative treatment. Time-varying confounders are not entered as covariates in the structural model because the weights are intended to remove their confounding. This holds only if the weight model is correctly specified and positivity holds.

Formula
E[Y^{\bar{a}}] = \beta_0 + \beta_1 A_t + \beta_2 t
4

Prior distributions are placed on the structural-model parameters. Bayes' theorem combines the weighted likelihood with these priors to give the posterior distribution. Posterior sampling is typically performed with MCMC (for example in Stan or JAGS) or with variational inference.

Formula
P(\beta \mid Y, w) \propto P(Y \mid \beta, w)\, P(\beta)
5

The posterior mean or median is reported as the point estimate of the causal effect, with posterior credible intervals as uncertainty bounds. Posterior predictive checks assess model fit, and sensitivity analyses across prior choices assess how much the conclusions depend on the priors.

Common pitfalls

  • Treating plug-in weight estimates as fixed, without propagating their uncertainty, can understate the posterior variance, especially in small samples.
  • Using non-informative priors when informative priors are available wastes prior information. Using informative priors without a sensitivity analysis imposes strong assumptions that are not visible in the results.
  • Ignoring positivity: if some treatment histories have near-zero probability in the observed data, extreme weights destabilise the weighted likelihood and therefore the posterior.
  • Confusing the marginal structural model, which averages over the covariate distribution, with a conditional model. Adding time-varying confounders as covariates in the structural model reintroduces the confounding that the weights were meant to remove.
  • Reporting only the posterior mean, without credible intervals or posterior predictive checks, leaves out the main advantage of the Bayesian approach.

Frequently asked questions

How does the Bayesian MSM differ from the classical (frequentist) MSM?

Both use inverse-probability weights to construct a pseudo-population free of measured time-varying confounding, and both fit a marginal structural model in that pseudo-population. The difference is inference: the classical approach reports a point estimate with asymptotic standard errors or a bootstrap interval, while the Bayesian MSM specifies priors and produces a full posterior distribution over causal parameters, enabling credible intervals and direct probability statements.

Do I need to model the weights in a Bayesian way as well?

Not necessarily. Many implementations estimate the weights from a frequentist propensity model and then condition on those plug-in weights in the Bayesian structural model. Saarela et al. (2015) argue that the weights should instead come from the posterior predictive treatment assignment and censoring probabilities. That fully Bayesian treatment propagates uncertainty through both stages, which is more principled but also more computationally demanding, since the treatment and censoring models must be handled together with the outcome model. See the paper for implementation details.

What software can I use?

Stan (via rstan or cmdstanr in R) and JAGS are the main platforms for specifying and sampling the Bayesian structural model. Weight models are typically fitted first with standard regression tools, such as glm in R or sklearn in Python.

When is the positivity assumption violated and why does it matter?

Positivity requires that every treatment history has a non-zero probability of occurring in the observed data. Violations cause extreme weights, which make the weighted likelihood, and therefore the posterior, unstable. Trim or stabilise the weights and report the range of estimated weights as a diagnostic check.

Can Bayesian MSM handle continuous or multivalued treatments?

Yes. For continuous treatments, the denominator of the stabilised weights is a conditional density rather than a probability, and it is estimated with density regression. The structural model then parameterises the dose-response curve. This is more complex than the binary case but remains feasible with appropriate software.

Related methods

Sources

  1. Saarela, O., Stephens, D. A., Moodie, E. E. M., & Klein, M. B. (2015). On Bayesian estimation of marginal structural models. Biometrics, 71(2), 279-288.

    Open DOI reference
  2. Robins, J. M., Hernan, M. A., & Brumback, B. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology, 11(5), 550-560.

    Open DOI reference