CCausal inference · causal.dml
Double/debiased machine learning (DoubleML)
What is the treatment effect when flexible machine-learning models adjust for the confounders?
Double/debiased machine learning with DoubleML (the same package in Python and R): the partially linear model (PLR; partialling out or IV-type score) for a binary or numeric treatment, or the interactive regression model (IRM) for the ATE of a binary treatment (for the ATT use the doubly robust method: the Python and R packages implement the ATTE score differently). Nuisance functions are learned by linear/logistic regression or XGBoost with cross-fitting on sample splits drawn from a shared random stream and passed to both engines, so the estimates agree. Reports θ̂ with its standard error and interval and the out-of-fold nuisance errors.
A real result
Example “Plr linear”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
Double machine learning (partially linear model, partialling out score, linear/logistic regression nuisances cross-fitted on 5 folds) estimates the effect of treated = true vs false on outcome as 1.99 (95% CI [1.85, 2.14], p < .001).
- θ̂
- 1.992
- 95% CI
- [1.849, 2.136]
- p
- < .001
Assumptions
- No unmeasured confounding — The estimate is causal only if the covariates include every common cause of treatment and outcome; check how strong an omitted confounder would have to be with the sensitivity analysis.
DoubleML estimate
| Term | θ̂ | SE | z | p | 95% CI low | 95% CI high |
|---|---|---|---|---|---|---|
| treated | 1.992 | 0.0733 | 27.165 | < .001 | 1.849 | 2.136 |
Partially linear model, score 'partialling out'; 5-fold cross-fitting with splits from seed 42.
Nuisance models (out of fold)
| Model | RMSE |
|---|---|
| Outcome (outcome) | 1.447 |
| Treatment (treated) | 0.4586 |
- 15 of 1200 rows were left out because a value was missing.
- Same DoubleML sample splits in Python and R (portable Wichmann–Hill stream).
Double machine learning (partially linear model, partialling out score, linear/logistic regression nuisances cross-fitted on 5 folds) estimates the effect of treated = true vs false on outcome as 1.99 (95% CI [1.85, 2.14], p < .001).
- θ̂
- 1.992
- 95% CI
- [1.849, 2.136]
- p
- < .001
Assumptions
- No unmeasured confounding — The estimate is causal only if the covariates include every common cause of treatment and outcome; check how strong an omitted confounder would have to be with the sensitivity analysis.
DoubleML estimate
| Term | θ̂ | SE | z | p | 95% CI low | 95% CI high |
|---|---|---|---|---|---|---|
| treated | 1.992 | 0.0733 | 27.165 | < .001 | 1.849 | 2.136 |
Partially linear model, score 'partialling out'; 5-fold cross-fitting with splits from seed 42.
Nuisance models (out of fold)
| Model | RMSE |
|---|---|
| Outcome (outcome) | 1.447 |
| Treatment (treated) | 0.4586 |
- 15 of 1200 rows were left out because a value was missing.
- Same DoubleML sample splits in Python and R (portable Wichmann–Hill stream).
Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.
Worked examples in the app
- Plr linearc2_obs · covariates: x1, x2, segment, member, income (k) · outcome: outcome · treatment: treated
- Irm linear trimmedc2_obs · covariates: x1, x2, segment, member, income (k) · outcome: outcome · treatment: treated
- Plr xgboost ivtypec2_lalonde · covariates: age, educ, race, married, nodegree, re74, re75 · outcome: earnings 1978 · treatment: treat
- Irm xgboost binaryc2_obs · covariates: x1, x2, segment, member · outcome: converted · treatment: treated
- Degenerate constantc2_obs · covariates: x1, x2, segment, member, income (k) · outcome: outcome · treatment: treated
- Degenerate n1c2_obs · covariates: x1, x2, segment, member, income (k) · outcome: outcome · treatment: treated
- Degenerate n3c2_obs · covariates: x1, x2, segment, member, income (k) · outcome: outcome · treatment: treated
In the guides
Where it sits in the decision guides
- Causal ML (uplift modeling) · DS & ML Decision Guide · Explain — why is it happening?
What you need
- Outcomenumeric / boolean · 1 column
- The outcome the treatment may affect (a number, or yes/no).
- Treatmentboolean / categorical / numeric · 1 column · 2–2 levels
- Binary (both models) or numeric (partially linear model only).
- Confounders (covariates)numeric / categorical / boolean · 1–100 columns · 2–30 levels
- Background variables that affect treatment and outcome; adjusting for them removes their confounding.
Choices you make
hypothesis
- Treated groupdefault —
Default: the second stored level (true for yes/no columns).
- Confidence leveldefault 0.95
How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.
statistics
- Modeldefault plr
PLR assumes a constant treatment effect; IRM lets the effect vary with covariates (binary treatment only).
- Partially linear (PLR): y = θ·d + g(x) + ε(default) — Assumes one constant treatment effect with flexible confounder adjustment; the usual choice, and it handles numeric treatments.
- Interactive (IRM): fully heterogeneous, binary treatment — Lets effects vary with the covariates for a yes/no treatment; pick it when effects may differ between people.
- PLR scoredefault partialling out
Score used to estimate θ in the partially linear model. Partialling out is the usual choice.
- Partialling out (Robinson)(default) — Residualizes outcome and treatment on the covariates, then regresses one on the other; the usual choice.
- IV-type — Uses a score that models the outcome with the treatment included; a second view, often noisier.
- Nuisance learnerdefault linear
Model used for the outcome and treatment nuisance functions: linear/logistic regression or XGBoost.
- Linear / logistic regression(default) — Fits the nuisance models with linear or logistic regression; pick it for small samples or simple confounding.
- XGBoost — Fits the nuisance models with gradient-boosted trees; pick it for nonlinear confounding with plenty of rows.
- Cross-fitting foldsdefault 5
Rows are split into this many parts; each part's nuisance predictions come from models fit on the others (cross-fitting).
- Propensity trimming (IRM)default 0.01
In IRM, propensity scores are kept away from 0 and 1 by this much to stabilize the weights.
model
- Boosting roundsdefault 100
Number of trees (boosting rounds). More is steadier but slower; boosting can overfit if there are too many.
- Learning ratedefault 0.1
How much each boosting round corrects the last. Smaller values learn slower but usually generalize better (add rounds).
- Tree depthdefault 3
Depth of the XGBoost trees in the nuisance models. Shallow trees are usually enough and overfit less.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
No unmeasured confounding
Overlap (IRM)
Extreme propensity scores inflate the variance.
What it reports
- Tests: DML treatment effect
- estimate
- How much the outcome changes for a one-unit change in a predictor, holding the others fixed.
- se
- The typical size of the error in an estimate, the standard deviation of its sampling distribution.
- ci_low
- A range of effect values compatible with your data at the chosen confidence level.
- ci_high
- A range of effect values compatible with your data at the chosen confidence level.
- z
- An estimate in standard-error units, compared with the standard normal distribution.
- p_value
- How surprising your data would be if the null hypothesis were true, as a probability.
- n
- How many independent units the analysis used; it sets precision and power.
- estimand
- The exact quantity an analysis targets, such as a difference in means or a ratio of medians.
- effect_label
- Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.
- claim_level_max
- How strong a causal statement the design supports, from association up to a causal effect.
- model
- The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
- score
- Score used to estimate the effect: partialling out or IV-type for the partially linear model, ATE for the interactive model.
- learner
- Model used for the outcome and treatment nuisance functions: linear (linear or logistic regression) or xgboost.
- folds
- Rotates which part of the data is held out, so every row is used for both training and validation.
- rmse_outcome
- Uses flexible models to remove confounding from treatment and outcome, with cross-fitting to keep inference valid.
- rmse_treatment
- Uses flexible models to remove confounding from treatment and outcome, with cross-fitting to keep inference valid.
- treated_level
- Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.
- control_level
- Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-8). Python uses pandas, numpy, doubleml, scikit-learn, xgboost, codesplash; R uses DoubleML, mlr3, mlr3learners, xgboost, nanoparquet, codesplashr.
Default traps between the two languages
- DoubleML in both engines with the same sample splits (portable Wichmann–Hill folds, draw_sample_splitting = FALSE). Linear nuisances and XGBoost (shared core, one thread) give identical predictions; the IRM propensity model is scikit-learn's Newton logistic regression vs mlr3's glm (both converged to 1e-12) — agreement ≈ 1e-14.
- DoubleML's IRM ATTE score differs between the Python and R packages (relative gap 1e-5 to 2e-3), so this method offers the IRM ATE only; causal.doubly_robust gives the ATT at P0.
- DoubleML's propensity trimming defaults differ (Python 0.01, R 1e-12); the option sets it in both.
The exact script CodeSplash ran for example “Plr linear” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Double/debiased machine learning (DoubleML)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method causal.dml 1.0.1 · spec 1170f1d86a11a842
# Dataset: c2_obs (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import warnings as _warnings
import numpy as np
import pandas as pd
import doubleml as dml
from scipy import stats
from sklearn.linear_model import LinearRegression, LogisticRegression
import codesplash as cs
from codesplash.causal import dml as csdml
from codesplash.causal import weighting as csw
# %% Data
df = pd.read_parquet("tests/parity/fixtures/c2_obs.parquet", columns=["outcome", "treated", "x1", "x2", "segment", "member", "income (k)"])
n_input = len(df)
df["treated"] = pd.Categorical(df["treated"], categories=["false", "true"]) # stored level order
df["segment"] = pd.Categorical(df["segment"], categories=["a", "b", "c"]) # stored level order
df["member"] = pd.Categorical(df["member"], categories=["false", "true"]) # stored level order
df = df.dropna(subset=["outcome", "treated", "x1", "x2", "segment", "member", "income (k)"]) # listwise deletion over the analysis columns
df["treated"] = df["treated"].cat.remove_unused_categories()
df["segment"] = df["segment"].cat.remove_unused_categories()
df["member"] = df["member"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["outcome", "treated", "x1", "x2", "segment", "member", "income (k)"]) # infinite values stop the run (registry/errors.yaml)
# %% Treatment, outcome and covariates
treatment = "treated"
outcome = "outcome"
covariates = ["x1", "x2", "segment", "member", "income (k)"]
conf = 0.95
seed = 42 # portable Wichmann–Hill stream: R gets the same sample splits
model_kind = "plr" # plr | irm
learner = "linear" # linear | xgboost
k = int(5)
trimming = 0.01
if isinstance(df[treatment].dtype, pd.CategoricalDtype):
t, treated_level, control_level = csw.treatment_indicator(df, treatment, None)
contrast_text = f"{treatment} = {treated_level} vs {control_level}"
else:
if model_kind == "irm":
raise ValueError("The interactive model needs a binary treatment; use the partially linear model for a numeric treatment.")
t = df[treatment].to_numpy(dtype=float)
treated_level = control_level = None
contrast_text = f"one unit of {treatment}"
y, event_level = csw.outcome_vector(df, outcome)
X, labels, binary, sources = csw.covariate_matrix(df, covariates)
csw.check_rank(X, labels)
n = len(y)
outcome_text = f"{outcome} = {event_level}" if event_level is not None else outcome
score = "partialling out" if model_kind == "plr" else "ATE"
# %% Learners (deterministic: same predictions as the R twins under the same splits)
if learner == "xgboost":
from xgboost import XGBClassifier, XGBRegressor
xgb = dict(n_estimators=int(100), learning_rate=0.1, max_depth=int(3),
n_jobs=1, random_state=seed, tree_method="hist")
reg = lambda: XGBRegressor(**xgb) # noqa: E731 — = mlr3 lrn("regr.xgboost", nrounds, eta, max_depth, nthread = 1)
clf = lambda: XGBClassifier(**xgb) # noqa: E731
else:
reg = LinearRegression # = mlr3 lrn("regr.lm")
clf = lambda: LogisticRegression(C=np.inf, solver="newton-cholesky", tol=1e-12, max_iter=1000) # noqa: E731 — = lrn("classif.log_reg")
names = [f"X{j + 1}" for j in range(X.shape[1])]
data = pd.DataFrame(X, columns=names)
data["y"] = y
data["d"] = t
dml_data = dml.DoubleMLData(data, y_col="y", d_cols="d", x_cols=names)
splits = csdml.sample_splits(n, k, seed)
with _warnings.catch_warnings():
_warnings.simplefilter("ignore")
if model_kind == "plr":
obj = dml.DoubleMLPLR(dml_data, reg(), reg(), ml_g=reg() if score == "IV-type" else None, n_folds=k, score=score, draw_sample_splitting=False)
else:
obj = dml.DoubleMLIRM(dml_data, reg(), clf(), n_folds=k, score=score, trimming_rule="truncate", trimming_threshold=trimming, draw_sample_splitting=False)
obj.set_sample_splitting(all_smpls=splits)
obj.fit(store_predictions=True)
est, se = float(obj.coef[0]), float(obj.se[0])
zc = stats.norm.ppf(1 - (1 - conf) / 2)
z = est / se
p_value = float(2 * stats.norm.sf(abs(z)))
ci_low, ci_high = est - zc * se, est + zc * se
pred = obj.predictions
if model_kind == "plr":
rmse_y = float(np.sqrt(np.mean((y - pred["ml_l"][:, 0, 0]) ** 2)))
else:
g = t * pred["ml_g1"][:, 0, 0] + (1 - t) * pred["ml_g0"][:, 0, 0]
rmse_y = float(np.sqrt(np.mean((y - g) ** 2)))
m_hat = pred["ml_m"][:, 0, 0]
if model_kind == "irm":
m_hat = np.clip(m_hat, trimming, 1 - trimming) # the packages store trimmed vs raw scores; compare the trimmed ones
rmse_d = float(np.sqrt(np.mean((t - m_hat) ** 2)))
# %% Result
estimand = {"plr": "ATE (partially linear)", "ATE": "ATE", "ATTE": "ATT"}[model_kind if model_kind == "plr" else score]
mname = "partially linear model" if model_kind == "plr" else "interactive regression model"
lname = "XGBoost" if learner == "xgboost" else "linear/logistic regression"
effect_label = f"Effect of {contrast_text} on {outcome_text} ({estimand}, double machine learning)"
pct = f"{conf:.0%}"
summary = (
f"Double machine learning ({mname}, {score} score, {lname} nuisances cross-fitted on {k} folds) estimates the effect of "
f"{contrast_text} on {outcome_text} as {cs.fmt_num(est)} ({pct} CI [{cs.fmt_num(ci_low)}, {cs.fmt_num(ci_high)}], {cs.fmt_p(p_value)})."
)
checks = [csw.no_confounding_check()]
if model_kind == "irm":
checks.insert(0, csw.overlap_check(m_hat, t))
values = {
"estimate": est, "se": se, "ci_low": ci_low, "ci_high": ci_high, "z": z, "p_value": p_value, "n": n, "estimand": estimand,
"effect_label": effect_label, "claim_level_max": "L2", "model": model_kind, "score": score, "learner": learner, "folds": k,
"rmse_outcome": rmse_y, "rmse_treatment": rmse_d, "treated_level": treated_level, "control_level": control_level,
}
cs.publish({
"method": "causal.dml",
"methodVersion": "1.0.1",
"title": f"Double machine learning ({model_kind.upper()}, {estimand})",
"engine": cs.engine_info("doubleml", "scikit-learn", *(["xgboost"] if learner == "xgboost" else []), "numpy", "pandas"),
"n": n,
"summary": summary,
"statistics": [
{"key": "estimate", "label": "θ̂", "value": est},
{"key": "ci", "label": f"{pct} CI", "value": [ci_low, ci_high]},
{"key": "p_value", "label": "p", "value": p_value, "format": "p"},
],
"tables": [
{"key": "estimate", "title": "DoubleML estimate", "columns": [
{"key": "term", "label": "Term", "type": "string"}, {"key": "coef", "label": "θ̂", "type": "number"},
{"key": "se", "label": "SE", "type": "number"}, {"key": "z", "label": "z", "type": "number"},
{"key": "p", "label": "p", "type": "pvalue"}, {"key": "ci_low", "label": f"{pct} CI low", "type": "number"},
{"key": "ci_high", "label": f"{pct} CI high", "type": "number"}],
"rows": [{"term": treatment, "coef": est, "se": se, "z": z, "p": p_value, "ci_low": ci_low, "ci_high": ci_high}],
"note": f"{mname.capitalize()}, score {score!r}; {k}-fold cross-fitting with splits from seed {seed}."},
{"key": "nuisance", "title": "Nuisance models (out of fold)", "columns": [
{"key": "model", "label": "Model", "type": "string"}, {"key": "rmse", "label": "RMSE", "type": "number"}],
"rows": [{"model": f"Outcome ({outcome})", "rmse": rmse_y}, {"model": f"Treatment ({treatment})", "rmse": rmse_d}]},
],
"assumptions": [{"key": c["id"], "label": c["label"], "status": {"concern": "warn"}.get(c["status"], c["status"]), "detail": c["detail"]} for c in checks],
"checks": checks,
"warnings": warnings,
"notes": ["Same DoubleML sample splits in Python and R (portable Wichmann–Hill stream)."],
"values": values,
})
The exact script CodeSplash ran for example “Plr linear” · R version 4.5.1 (2025-06-13)
# Double/debiased machine learning (DoubleML)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method causal.dml 1.0.1 · spec 1170f1d86a11a842
# Dataset: c2_obs (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
suppressPackageStartupMessages({
library(DoubleML)
library(mlr3)
library(mlr3learners)
})
lgr::get_logger("mlr3")$set_threshold("warn")
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/c2_obs.parquet", col_select = c("outcome", "treated", "x1", "x2", "segment", "member", "income (k)")))
n_input <- nrow(df)
df[["treated"]] <- factor(df[["treated"]], levels = c("false", "true")) # stored level order
df[["segment"]] <- factor(df[["segment"]], levels = c("a", "b", "c")) # stored level order
df[["member"]] <- factor(df[["member"]], levels = c("false", "true")) # stored level order
df <- df[stats::complete.cases(df[c("outcome", "treated", "x1", "x2", "segment", "member", "income (k)")]), , drop = FALSE] # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("outcome", "treated", "x1", "x2", "segment", "member", "income (k)")) # infinite values stop the run (registry/errors.yaml)
# %% Treatment, outcome and covariates
treatment <- "treated"
outcome <- "outcome"
covariates <- c("x1", "x2", "segment", "member", "income (k)")
conf <- 0.95
seed <- 42 # portable Wichmann–Hill stream: Python gets the same sample splits
model_kind <- "plr" # plr | irm
learner <- "linear" # linear | xgboost
k <- as.integer(5)
trimming <- 0.01
if (is.factor(df[[treatment]])) {
tr_info <- cs_causal_treatment(df, treatment, NULL)
t <- tr_info$t
treated_level <- tr_info$treated
control_level <- tr_info$control
contrast_text <- sprintf("%s = %s vs %s", treatment, treated_level, control_level)
} else {
if (model_kind == "irm") stop("The interactive model needs a binary treatment; use the partially linear model for a numeric treatment.")
t <- as.numeric(df[[treatment]])
treated_level <- NULL
control_level <- NULL
contrast_text <- sprintf("one unit of %s", treatment)
}
y_info <- cs_causal_outcome(df, outcome)
y <- y_info$y
event_level <- y_info$event
des <- cs_causal_design(df, covariates)
X <- des$X
cs_causal_check_rank(X, des$labels)
n <- length(y)
outcome_text <- if (!is.null(event_level)) sprintf("%s = %s", outcome, event_level) else outcome
score <- if (model_kind == "plr") "partialling out" else "ATE"
# %% Learners (deterministic: same predictions as the Python twins under the same splits)
if (learner == "xgboost") {
xgb <- list(nrounds = as.integer(100), eta = 0.1, max_depth = as.integer(3),
nthread = 1L, verbose = 0L, seed = seed)
reg <- function() do.call(lrn, c(list("regr.xgboost"), xgb))
clf <- function() do.call(lrn, c(list("classif.xgboost", predict_type = "prob"), xgb))
} else {
reg <- function() lrn("regr.lm")
clf <- function() lrn("classif.log_reg", predict_type = "prob", epsilon = 1e-12, maxit = 1000)
}
Xn <- X
colnames(Xn) <- paste0("X", seq_len(ncol(X)))
data <- data.frame(Xn, y = y, d = t)
dml_data <- DoubleMLData$new(data, y_col = "y", d_cols = "d", x_cols = colnames(Xn))
splits <- cs_causal_dml_splits(n, k, seed)
if (model_kind == "plr") {
obj <- if (score == "IV-type") DoubleMLPLR$new(dml_data, reg(), reg(), reg(), n_folds = k, score = score, draw_sample_splitting = FALSE)
else DoubleMLPLR$new(dml_data, reg(), reg(), n_folds = k, score = score, draw_sample_splitting = FALSE)
} else {
obj <- DoubleMLIRM$new(dml_data, reg(), clf(), n_folds = k, score = score, trimming_rule = "truncate", trimming_threshold = trimming,
draw_sample_splitting = FALSE)
}
obj$set_sample_splitting(splits)
obj$fit(store_predictions = TRUE)
est <- unname(obj$coef[1])
se <- unname(obj$se[1])
zc <- stats::qnorm(1 - (1 - conf) / 2)
z <- est / se
p_value <- 2 * stats::pnorm(abs(z), lower.tail = FALSE)
ci_low <- est - zc * se
ci_high <- est + zc * se
pred <- obj$predictions
if (model_kind == "plr") {
rmse_y <- sqrt(mean((y - pred$ml_l[, 1, 1])^2))
} else {
g <- t * pred$ml_g1[, 1, 1] + (1 - t) * pred$ml_g0[, 1, 1]
rmse_y <- sqrt(mean((y - g)^2))
}
m_hat <- pred$ml_m[, 1, 1]
if (model_kind == "irm") m_hat <- pmin(pmax(m_hat, trimming), 1 - trimming) # the packages store trimmed vs raw scores
rmse_d <- sqrt(mean((t - m_hat)^2))
# %% Result
estimand <- if (model_kind == "plr") "ATE (partially linear)" else if (score == "ATTE") "ATT" else "ATE"
mname <- if (model_kind == "plr") "partially linear model" else "interactive regression model"
lname <- if (learner == "xgboost") "XGBoost" else "linear/logistic regression"
effect_label <- sprintf("Effect of %s on %s (%s, double machine learning)", contrast_text, outcome_text, estimand)
pct <- sprintf("%.0f%%", conf * 100)
summary <- sprintf("Double machine learning (%s, %s score, %s nuisances cross-fitted on %d folds) estimates the effect of %s on %s as %s (%s CI [%s, %s], %s).",
mname, score, lname, k, contrast_text, outcome_text, cs_fmt_num(est), pct, cs_fmt_num(ci_low), cs_fmt_num(ci_high), cs_fmt_p(p_value))
checks <- list(cs_causal_no_confounding_check())
if (model_kind == "irm") checks <- c(list(cs_causal_overlap_check(m_hat, t)), checks)
values <- list(estimate = est, se = se, ci_low = ci_low, ci_high = ci_high, z = z, p_value = p_value, n = n, estimand = estimand,
effect_label = effect_label, claim_level_max = "L2", model = model_kind, score = score, learner = learner, folds = k,
rmse_outcome = rmse_y, rmse_treatment = rmse_d, treated_level = treated_level, control_level = control_level)
cs_publish(list(
method = "causal.dml",
methodVersion = "1.0.1",
title = sprintf("Double machine learning (%s, %s)", toupper(model_kind), estimand),
engine = do.call(cs_engine_info, as.list(c("DoubleML", "mlr3", "mlr3learners", if (learner == "xgboost") "xgboost"))),
n = n,
summary = summary,
statistics = list(
list(key = "estimate", label = "θ̂", value = est),
list(key = "ci", label = paste(pct, "CI"), value = c(ci_low, ci_high)),
list(key = "p_value", label = "p", value = p_value, format = "p")),
tables = list(
list(key = "estimate", title = "DoubleML estimate", columns = list(
list(key = "term", label = "Term", type = "string"), list(key = "coef", label = "θ̂", type = "number"),
list(key = "se", label = "SE", type = "number"), list(key = "z", label = "z", type = "number"),
list(key = "p", label = "p", type = "pvalue"), list(key = "ci_low", label = paste(pct, "CI low"), type = "number"),
list(key = "ci_high", label = paste(pct, "CI high"), type = "number")),
rows = list(list(term = treatment, coef = est, se = se, z = z, p = p_value, ci_low = ci_low, ci_high = ci_high)),
note = sprintf("%s%s, score '%s'; %d-fold cross-fitting with splits from seed %d.", toupper(substr(mname, 1, 1)), substr(mname, 2, nchar(mname)), score, k, seed)),
list(key = "nuisance", title = "Nuisance models (out of fold)", columns = list(
list(key = "model", label = "Model", type = "string"), list(key = "rmse", label = "RMSE", type = "number")),
rows = list(list(model = sprintf("Outcome (%s)", outcome), rmse = rmse_y), list(model = sprintf("Treatment (%s)", treatment), rmse = rmse_d)))),
assumptions = lapply(checks, function(c) list(key = c$id, label = c$label, status = if (c$status == "concern") "warn" else c$status, detail = c$detail)),
checks = checks,
warnings = warnings,
notes = list("Same DoubleML sample splits in Python and R (portable Wichmann–Hill stream)."),
values = values
))
Sources
- Chernozhukov, V., Chetverikov, D., Demirer, M., Duflo, E., Hansen, C., Newey, W., & Robins, J. (2018). Double/debiased machine learning for treatment and structural parameters. The Econometrics Journal, 21, C1–C68.
- Bach, P., Chernozhukov, V., Kurz, M. S., & Spindler, M. (2022). DoubleML — An object-oriented implementation of double machine learning in Python. JMLR, 23(53); (2024) in R. Journal of Statistical Software, 108(3).
From the CodeSplash method registry · causal.dml v1.0.1.