gws_design_of_experiments

Menu
Publication date

Jul 10, 2025

Confidentiality
Public
Reactions
0
Share

Causal inference

Principle of Double Machine Learning (DML)


Double Machine Learning (DML) is a modern causal inference method designed to estimate treatment effects in high-dimensional settings while addressing the risk of overfitting and model misspecification. It is particularly useful when dealing with many covariates or confounders, which are common in observational studies.


1. Core Idea


DML combines machine learning with semiparametric theory to:


  • Flexibly model the relationship between covariates and outcomes/treatments.
    • Debias the estimation of treatment effects, even if the initial models are complex or misspecified.

      2. How DML Works


      Step 1: Model the "Nuisance Parameters"


      • Outcome Model (Y-model): Predict the outcome YYY using covariates XXX, ignoring the treatment DDD.
        • Treatment Model (D-model): Predict the treatment DDD using covariates XXX.

          These models are estimated using flexible machine learning algorithms (e.g., Random Forests, Gradient Boosting, Neural Networks).


          Step 2: Cross-Fitting


          • Split the data into K folds.
            • For each fold kkk:
              • Train the Y-model and D-model on the out-of-fold data (all folds except kkk).
                • Predict the residuals (errors) for the observations in fold kkk:
                  • Y =Y~−Y^Y~=\tilde{Y} - \hat{Y}Y =Y~−Y^ (outcome residuals)
                    • D =D~−D^D~=\tilde{D} - \hat{D}D =D~−D^ (treatment residuals)

                  Step 3: Estimate the Treatment Effect


                  • Use the residuals Y~\tilde{Y}Y~ and D~\tilde{D} D~to estimate the Average Treatment Effect (ATE) or Conditional Average Treatment Effect (CATE) via a simple regression:
                    • Y~=θD~+error\tilde{Y} = \theta \tilde{D} + \text{error}Y~=θD~+error
                      • where θ\thetaθ is the unbiased estimate of the treatment effect.

                      3. Why "Double"?


                      • The term "double" refers to the use of two machine learning models (one for the outcome, one for the treatment) and the cross-fitting procedure to avoid overfitting.
                        • This ensures that the estimation of the treatment effect is robust to misspecification of the nuisance models.

                          4. Advantages of DML


                          • High-Dimensional Data: Works well even with many covariates.
                            • Flexibility: Can use any ML algorithm for nuisance modeling.
                              • Debiased Estimation: Corrects for overfitting and model errors.
                                • Inference: Allows for valid confidence intervals and hypothesis testing.

                                  5. Applications


                                  • Bioprocessing: Estimating the causal effect of process parameters on yield.
                                    • Economics: Evaluating the impact of policies or interventions.
                                      • Healthcare: Assessing the effect of treatments in observational studies.

                                        6. Does DML Isolate the "True Marginal Effect" of a Treatment?


                                        Double Machine Learning (DML) estimates the Average Treatment Effect (ATE) or Conditional Average Treatment Effect (CATE) of a treatment variable DDD on an outcome YYY, controlling for confounders XXX.


                                        Key Points:


                                        1. Marginal Effect vs. Causal Effect: The marginal effect of DDD on YYY (e.g., from a simple regression) is often confounded by other variables XXX that affect both DDD and YYY.DML isolates the causal effect of DDD by accounting for the influence of XXX, but it does not ignore the role of XXX. Instead, it adjusts for their confounding influence.
                                          1. What DML Achieves: DML estimates the effect of DDD on YYY as if the treatment were randomly assigned, holding confounders XXX constant.It does not estimate the effect of DDD in a vacuum (ignoring all other variables). Rather, it answers: "What is the effect of DDD on YYY, after accounting for the fact that XXX influences both DDD and YYY?"
                                            1. No Impact of Others?DML does not remove the impact of other variables entirely. It controls for their confounding influence so that the estimated effect of DDD is unbiased.If other variables XXX directly affect YYY (e.g., mediators), DML does not remove their effect—it only ensures that the estimate for DDD is not distorted by their confounding role.

                                              7. Example


                                              Suppose you want to estimate the causal effect of a fermentation temperature (DDD) on yield (YYY), but pH (XXX) affects both temperature and yield.


                                              • A naive regression of YYY on DDD would give a biased estimate because pH is a confounder.
                                                • DML estimates the effect of temperature on yield as if pH were held constant, giving you the unconfounded causal effect of temperature.

                                                  8. Example in Python (EconML)


                                                  from econml.dml import DML
                                                  from sklearn.ensemble import RandomForestRegressor
                                                  
                                                  # Define models for Y and D
                                                  model_y = RandomForestRegressor()
                                                  model_t = RandomForestRegressor()
                                                  
                                                  # Initialize DML
                                                  est = DML(model_y=model_y, model_t=model_t, cv=3)
                                                  est.fit(Y, T, X=X)  # Y: outcome, T: treatment, X: covariates
                                                  
                                                  # Estimate ATE
                                                  ate = est.ate()
                                                  print(f"Average Treatment Effect: {ate}")from econml.dml import DML
                                                  from sklearn.ensemble import RandomForestRegressor
                                                  
                                                  # Define models for Y and D
                                                  model_y = RandomForestRegressor()
                                                  model_t = RandomForestRegressor()
                                                  
                                                  # Initialize DML
                                                  est = DML(model_y=model_y, model_t=model_t, cv=3)
                                                  est.fit(Y, T, X=X)  # Y: outcome, T: treatment, X: covariates
                                                  
                                                  # Estimate ATE
                                                  ate = est.ate()
                                                  print(f"Average Treatment Effect: {ate}")

                                                  9. Summary Table



                                                  Shine Logo
                                                  Technical bricks to reuse or customize

                                                  Have you developed a brick?

                                                  Share it to accelerate projects for the entire community.