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

MisspecifiedAdjustmentError

useUnknownAdjustment

fitCausalBNEstimator

MisspecifiedAdjustmentError

useRCTAdjustment, no covariate

fitDM, fitCausalBNEstimator

RCTError

useRCTAdjustment, covariates

fitDM (covariates ignored), fitSLearner, fitTLearner, fitXLearner, fitPStratification, fitIPW, fitCausalBNEstimator

RCTError

useBackdoorAdjustment, empty set

fitDM, fitCausalBNEstimator

ValueError for the 5 backdoor learners, BackdoorError otherwise

useBackdoorAdjustment, non-empty set

fitSLearner, fitTLearner, fitXLearner, fitPStratification, fitIPW, fitCausalBNEstimator

BackdoorError

useFrontdoorAdjustment

fitSimplePlugIn (covariates ignored), fitGeneralizedPlugIn (at least one covariate), fitCausalBNEstimator

ValueError for fitGeneralizedPlugIn without covariate, FrontdoorError otherwise

useIVAdjustment

fitWald (no covariate), fitWaldIPW and fitNormalizedWaldIPW (at least one covariate), fitTSLS, fitCausalBNEstimator

ValueError for fitWaldIPW and fitNormalizedWaldIPW without covariate, IVError otherwise

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:

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

estimateCausalEffect()

Estimate the causal or treatment effect based on the initialized data.

fitCausalBNEstimator()

Fit the Causal Bayesian Network Estimator.

fitCustomEstimator()

Fits the specified estimator object, which must implement .fit(), .predict(), and .estimate_ate() methods consistent with CausalML estimators.

fitDM()

Fits the Difference in Means (DM) Estimator.

fitGeneralizedPlugIn()

Fit the Generalized plug-in Estimator.

fitIPW()

Fit the Inverse Propensity score Weighting Estimator.

fitNormalizedWaldIPW()

Fit the Normalized Wald Inverse Probability Weighting Estimator.

fitPStratification()

Fit the Propensity score Stratification Estimator.

fitSLearner()

Fit the S-Learner Estimator.

fitSimplePlugIn()

Fit the Plug-in Estimator.

fitTLearner()

Fit the T-Learner Estimator.

fitTSLS()

Fit the Two Stage Least Squares Estimator.

fitWald()

Fit the Wald Estimator.

fitWaldIPW()

Fit the Wald Inverse Probability Weighting Estimator.

fitXLearner()

Fit the X-Learner Estimator.

identifyAdjustmentSet()

Identify the sufficent adjustment set of covariates.

useBackdoorAdjustment()

Specify the Backdoor Adjustment.

useFrontdoorAdjustment()

Specify the (General) Frontdoor Adjustment.

useIVAdjustment()

Specify the (Generalized) Instrumental Variable Adjustment.

useRCTAdjustment()

Specify the Randomized Controlled Trial (RCT) Adjustment.

useUnknownAdjustment()

Specify an Unknown Adjustment.

[BP02] (1,2)

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.

[CHL+20] (1,2)

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.

[GBN26] (1,2)

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.

[Nea20]

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.

[Pea95]

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.

[Rub05]

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.

[vdZTLiskiewicz15] (1,2)

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.

[Wag22]

Stefan Wager. STATS 361: causal inference. Course lecture notes, Stanford University, 2022. URL: https://web.stanford.edu/~swager/stats361.pdf.

References of the members