Causal Effect Estimation
The Neyman-Rubin Potential Outcomes Framework is an approach for estimating causal effects (also known as treatment effects) in causal inference. It defines causality through the potential outcomes \(Y\) of a binary intervention \(T\). The causal effect, defined as the difference between these potential outcomes, is the core focus of this framework. Rubin [Rub05]
However, since only one of the potential outcomes is observed—either the unit receives the intervention or it does not—the difference in potential outcomes is unobservable. This is known as the “Fundamental Problem of Causal Inference”.
Recent advancements have developed improved statistical estimators for causal effects, each associated with specific causal assumptions. This module integrates these advancements with foundational causal identification through Bayesian networks. Pearl [Pea95] It provides a pipeline for detecting suitable adjustment sets and applying the appropriate estimators to achieve accurate causal effect estimations.
Adjustments and estimators
An estimator is fitted after an adjustment has been chosen, either by identifyAdjustmentSet or by one of the
use*Adjustment methods (these do not check the adjustment against the causal graph). Each fit* method checks
that its estimator suits the chosen adjustment:
Adjustment |
Accepted estimators |
Other estimators raise |
|---|---|---|
none chosen |
none |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Without covariate, the probability of the instrument does not depend on the individual: fitWaldIPW and
fitNormalizedWaldIPW would then give the same estimate as fitWald. Likewise, fitGeneralizedPlugIn would
estimate the same quantity as fitSimplePlugIn. The error message names the estimator to use instead.
fitCustomEstimator accepts any adjustment but the unknown one, without further check. All these exceptions derive
from ValueError. The instrument of useIVAdjustment is the name of a single variable. Choosing an adjustment
forgets the previous one and the fitted estimator: an estimator is fitted again before estimateCausalEffect.
- class pyagrum.causalEffectEstimation.CausalEffectEstimation(df, causal_model)
Estimates causal effects using a dataset and a causal graph within the Neyman-Rubin Potential Outcomes framework.
This class performs causal identification based on user-specified datasets and causal graphical models. It determines the appropriate adjustment method — suchas backdoor, front-door, or instrumental variables (IV) — to optimally estimate the causal effect (or treatment effect) between the intervention (treatment assignment) and the outcome.
The class integrates domain-specific statistical estimators and recent advancements in machine learning techniques to estimate various causal effects, including the Average Causal Effect (ACE), Conditional Average Causal Effect (CACE), Individual Causal Effect (ICE), and Local Average Treatment Effect (LATE), among others.
This module is inspired by the works of Wager [Wag22] and Neal [Nea20].
- Raises:
AssertionError – If the input dataframe is empty, indicating that predictions cannot be made.
ValueError – If the provided estimator_string does not correspond to any supported estimator.
- Parameters:
df (
DataFrame)causal_model (
CausalModel)
Scientific notes
CausalEffectEstimation estimates, from data, the effect of a binary treatment \(T \in \{0, 1\}\) on an outcome \(Y\) in the potential outcomes framework [1]: the average causal effect \(\tau = E[Y(1) - Y(0)]\) (ACE), its mean over the rows of a query (CACE) or its value for each row given as a data frame (ICE). The causal graph is used for identification [2], the estimation itself is statistical; the module follows the lecture notes [3][4].
Identification (identifyAdjustmentSet), tried in this order: randomized controlled trial (\(T\) and
\(Y\) d-separated once the arc \(T \to Y\) is removed; the covariates are the parents of \(Y\)); back-door
set (pyagrum.CausalModel.backDoor); generalized front-door [5] (mediators on the directed
paths from \(T\) to \(Y\), covariates gathered from the back-door sets of \((T, M)\) and \((M, Y)\));
conditional instrument [6], searched among the parents of \(T\), its conditioning set
being the nearest separator of [7]. Otherwise only the estimator by do-calculus can be used.
Estimators (\(\hat e(x) = \hat P(T=1 \mid x)\), \(\hat\mu\) regressions of the outcome; by default linear regressions for the outcomes and logistic regressions for the probabilities):
RCT: the difference in means \(\bar y_1 - \bar y_0\).
Back-door [8][9]: S-learner \(\hat\mu(x, 1) - \hat\mu(x, 0)\) (one regression with \(T\) as a feature); T-learner \(\hat\mu_1(x) - \hat\mu_0(x)\) (one regression per group); X-learner: the imputed effects \(y - \hat\mu_0(x)\) of the treated and \(\hat\mu_1(x) - y\) of the controls are regressed into \(\hat\tau_1\) and \(\hat\tau_0\), combined as \(\hat e(x)\,\hat\tau_0(x) + (1 - \hat e(x))\,\hat\tau_1(x)\) (\(\hat\tau_0\) relies on \(\hat\mu_1\), the better estimated where the treated are many); inverse propensity weighting \(\frac1n \sum_i \big(\frac{t_i}{\hat e(x_i)} - \frac{1 - t_i}{1 - \hat e(x_i)}\big) y_i\) (not normalized); stratification into
num_strata(100) strata of equal size on \(\hat e\), the differences in means of the strata being averaged with their sizes (strata without treated or control units are ignored).Front-door [10]: the plug-in estimate of \(\sum_m (P(m \mid T{=}1) - P(m \mid T{=}0)) \sum_t P(t)\,E[Y \mid m, t]\), computed as \(\frac1n \sum_i \big(\frac{\hat P(T=1 \mid m_i)}{\hat P(T=1)} - \frac{\hat P(T=0 \mid m_i)}{\hat P(T=0)}\big) \sum_t \hat P(t)\,\hat\mu(m_i, t)\); with covariates, \(\xi(m, x) = \sum_t \hat\mu(m, x, t)\,\hat P(t \mid x)\) is regressed on \(x\) in each group, and the ACE is the mean difference of the two regressions.
Instrument \(W\) (binary): the Wald estimator \((\bar y_{W=1} - \bar y_{W=0}) / (\bar t_{W=1} - \bar t_{W=0})\), the local average effect on the compliers [11] (no covariate allowed); its inverse probability weighted versions, plain and normalized, with \(\hat P(W=1 \mid x)\) [12]; the two-stage least squares [13] (coefficient of \(\hat t\) in the regression of \(y\) on \(x\) and \(\hat t\), \(\hat t\) being the regression of \(t\) on \(x\) and \(w\)).
Causal Bayesian network: the parameters of the network are learned from the data (smoothing prior \(10^{-9}\)) and the ACE is \(E[Y \mid do(T{=}1)] - E[Y \mid do(T{=}0)]\) (
pyagrum.causalImpact, the labels of \(Y\) read as numbers); with an instrument, the ratio of the differences of \(E[Y \mid w]\) and \(E[T \mid w]\).Any estimator with the interface of CausalML [14].
Implementation limit. The causal Bayesian network estimator does not keep the latent variables of the causal model: its do-calculus is done as if there were none.
Methods
Estimate the causal or treatment effect based on the initialized data. |
|
Fit the Causal Bayesian Network Estimator. |
|
Fits the specified |
|
Fits the Difference in Means (DM) Estimator. |
|
Fit the Generalized plug-in Estimator. |
|
Fit the Inverse Propensity score Weighting Estimator. |
|
Fit the Normalized Wald Inverse Probability Weighting Estimator. |
|
Fit the Propensity score Stratification Estimator. |
|
Fit the S-Learner Estimator. |
|
Fit the Plug-in Estimator. |
|
Fit the T-Learner Estimator. |
|
Fit the Two Stage Least Squares Estimator. |
|
Fit the Wald Estimator. |
|
Fit the Wald Inverse Probability Weighting Estimator. |
|
Fit the X-Learner Estimator. |
|
Identify the sufficent adjustment set of covariates. |
|
Specify the Backdoor Adjustment. |
|
Specify the (General) Frontdoor Adjustment. |
|
Specify the (Generalized) Instrumental Variable Adjustment. |
|
Specify the Randomized Controlled Trial (RCT) Adjustment. |
|
Specify an Unknown Adjustment. |
Carlos Brito and Judea Pearl. Generalized instrumental variables. In Proceedings of the Eighteenth Conference on Uncertainty in Artificial Intelligence (UAI 2002), 85–93. Morgan Kaufmann, 2002. URL: https://arxiv.org/abs/1301.0560.
Huigang Chen, Totte Harinen, Jeong-Yoon Lee, Mike Yung, and Zhenyu Zhao. Causalml: python package for causal machine learning. arXiv preprint arXiv:2002.11631, 2020. URL: https://arxiv.org/abs/2002.11631.
Anna Guo, David Benkeser, and Razieh Nabi. Flexible nonparametric inference for causal effects under the front-door model. Journal of the Royal Statistical Society Series B: Statistical Methodology, 2026. URL: https://arxiv.org/abs/2312.10234, doi:10.1093/jrsssb/qkag122.
Brady Neal. Introduction to causal inference from a machine learning perspective. Course lecture notes, 2020. URL: https://www.bradyneal.com/Introduction_to_Causal_Inference-Dec17_2020-Neal.pdf.
Judea Pearl. Causal diagrams for empirical research. Biometrika, 82(4):669–688, 1995. URL: https://ftp.cs.ucla.edu/pub/stat_ser/R218-B.pdf, doi:10.1093/biomet/82.4.669.
Donald B Rubin. Causal inference using potential outcomes: design, modeling, decisions. Journal of the American Statistical Association, 100(469):322–331, 2005. URL: https://doi.org/10.1198/016214504000001880, doi:10.1198/016214504000001880.
Benito van der Zander, Johannes Textor, and Maciej Liśkiewicz. Efficiently finding conditional instruments for causal inference. In Proceedings of the Twenty-Fourth International Joint Conference on Artificial Intelligence (IJCAI 2015), 3243–3249. 2015. URL: https://www.ijcai.org/Proceedings/15/Papers/457.pdf.
Stefan Wager. STATS 361: causal inference. Course lecture notes, Stanford University, 2022. URL: https://web.stanford.edu/~swager/stats361.pdf.
References of the members
Joshua D Angrist and Guido W Imbens. Two-stage least squares estimation of average causal effects in models with variable treatment intensity. Journal of the American statistical Association, 90(430):431–442, 1995. URL: https://www.tandfonline.com/doi/abs/10.1080/01621459.1995.10476535, doi:10.1080/01621459.1995.10476535.
Carlos Brito and Judea Pearl. Generalized instrumental variables. In Proceedings of the Eighteenth Conference on Uncertainty in Artificial Intelligence (UAI 2002), 85–93. Morgan Kaufmann, 2002. URL: https://arxiv.org/abs/1301.0560.
Huigang Chen, Totte Harinen, Jeong-Yoon Lee, Mike Yung, and Zhenyu Zhao. Causalml: python package for causal machine learning. arXiv preprint arXiv:2002.11631, 2020. URL: https://arxiv.org/abs/2002.11631.
Byeong Yeob Choi. Instrumental variable estimation of truncated local average treatment effects. Plos one, 16(4):e0249642, 2021. URL: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8021190/, doi:10.1371/journal.pone.0249642.
Isabel R Fulcher, Ilya Shpitser, Stella Marealle, and Eric J Tchetgen Tchetgen. Robust inference on population indirect causal effects: the generalized front door criterion. Journal of the Royal Statistical Society Series B: Statistical Methodology, 82(1):199–214, 2020. URL: https://academic.oup.com/jrsssb/article/82/1/199/7056027, doi:10.1111/rssb.12345.
Anna Guo, David Benkeser, and Razieh Nabi. Flexible nonparametric inference for causal effects under the front-door model. Journal of the Royal Statistical Society Series B: Statistical Methodology, 2026. URL: https://arxiv.org/abs/2312.10234, doi:10.1093/jrsssb/qkag122.
Sören R Künzel, Jasjeet S Sekhon, Peter J Bickel, and Bin Yu. Metalearners for estimating heterogeneous treatment effects using machine learning. Proceedings of the national academy of sciences, 116(10):4156–4165, 2019. URL: https://arxiv.org/abs/1706.03461, doi:10.1073/pnas.1804597116.
Jared K Lunceford and Marie Davidian. Stratification and weighting via the propensity score in estimation of causal treatment effects: a comparative study. Statistics in medicine, 23(19):2937–2960, 2004. URL: https://doi.org/10.1002/sim.1903, doi:10.1002/sim.1903.
Benito van der Zander, Johannes Textor, and Maciej Liśkiewicz. Efficiently finding conditional instruments for causal inference. In Proceedings of the Twenty-Fourth International Joint Conference on Artificial Intelligence (IJCAI 2015), 3243–3249. 2015. URL: https://www.ijcai.org/Proceedings/15/Papers/457.pdf.