Sequential Transport for Causal Mediation Analysis
1 Preface
This ebook contains the codes and explanations of codes used to produce the results of our paper titled Sequential Transport for Causal Mediation Analysis.
Abstract
We propose a distributional framework for causal mediation analysis based on optimal transport (OT) and its sequential extension along a mediator DAG. Instead of relying on cross-world structural counterfactuals, we construct mediator counterfactuals in a mutatis mutandis sense: mediators are modified only as needed to align an individual with the distribution under the alternative treatment, while respecting causal dependencies among mediators. Sequential transport (ST) builds these counterfactuals by applying univariate or conditional OT maps in a topological order of the mediator DAG, and extends naturally to categorical mediators through simplex representation, and adapted transport techniques. We establish consistency of the estimated transport maps and of the induced individual-level decompositions of treatment effects. Gaussian examples show that ST recovers classical mediation formulas, while simulations confirm good performance in nonlinear and mixed-type settings. An application to the COMPAS dataset illustrates how ST yields deterministic, DAG-consistent counterfactual mediators and provides a fine-grained attribution of group disparities across mediators. The framework offers a flexible and interpretable alternative to structural causal models, and suggests extensions to longitudinal mediators, dynamic interventions, and stochastic transport flows.
1.1 Replication Package
To replicate the empirical results of the paper (using R and pyton):
Download the Replication Codes (Zip archive)
(See the readme file in the archive for more details.)
The results presented in the paper focus on the following chapters of this ebook:
The other chapters provide additional context and details.
1.2 Outline of this Ebook
The document is made of 5 parts:
Introduction
This part provides some refresher about causal mediation analysis (Chapter 2), gives a few colours and plot theme functions (Chapter 3), and contains the main estimation functions that are used in the subsequent chapter (Chapter 4).A Gaussian Example
Simulations are conducted using Gaussian variables to evaluate the estimation of causal effects in the presence of a mediator. In particular, we compare estimates obtained using the Linear Structural Equation Model (LSEM) approach, implemented in the R package {mediation}, with those derived from counterfactuals constructed via optimal transport techniques (see Chapter 5). Monte Carlo experiments are then performed to assess how these estimates behave under varying data conditions (see Chapter 6).Counterfactuals for Categorical Data After a short presentation of the context (Chapter 7), we present different methods to build counterfactuals for a categorical variable: using matching (Chapter 11), using optimal transport on label-encoded variables (Chapter 9), and using optimal transport on the simplex (Chapter 10).
Transport with Weight In (Chapter Gaussian? Conditional Univariate Transport with Local Weights), we show another method to performe univariate transport in the Gaussian case, using local weights. We illustrate the method with simulated data and compare the results with transported values obtained with sequential transport.
Experiments We run some experiments on a synthetic dataset in Chapter 13 and on a real-world dataset in Chapter 14 to illustrate the entire method.