R + Python · Paper companion
Doubly robust inference
via calibration.
Estimate average treatment effects after calibrating outcome predictions and inverse probability weights. Calibration improves their fit to the data and supports doubly robust inference: confidence intervals can remain valid if one nuisance function is estimated well enough, even when the other is estimated badly or slowly.
Binary and multi-arm treatments. Point estimates, standard errors, and confidence intervals.
Estimate the average treatment effect
from calibrateddml import CalibratedDML
fit = CalibratedDML(
control_level=0,
outcome_model="lasso",
treatment_model="lasso",
random_state=123,
).fit(X, A, y)
fit.summary()
fit.confint()library(calibratedDML)
fit <- calibrated_dml(
data = df,
outcome = "Y",
treatment = "A",
covariates = c("W1", "W2", "W3"),
control_level = 0,
outcome_model = "lasso",
treatment_model = "lasso",
seed = 123
)
summary(fit)
confint(fit)X contains covariates, A is treatment, and y is the outcome. The package fits and calibrates the nuisance estimates.
Using the package
Start with data or fitted models.
Fit from raw data
Choose outcome and treatment models. The package handles cross-fitting, calibration, and inference.
fit(X, A, y)Use your own predictions
Supply cross-fitted predictions from models you already use, then calibrate them and estimate effects.
fit_from_nuisancesCompare treatment arms
Estimate each arm's mean potential outcome and its difference from a chosen control.
control_levelWhy calibrate?
Double robustness
for inference.
A doubly robust point estimate can be consistent when only one nuisance estimator is consistent. Its usual confidence interval can still fail. Calibrating the nuisance estimates allows valid inference under weaker estimation requirements.
Calibration can also stabilize extreme inverse probability weights and reduce variance, especially with limited treatment overlap. See Stabilized Inverse Probability Weighting via Isotonic Calibration.
Calibration and confidence intervals- 1
Fit the nuisance models
Estimate outcomes and treatment probabilities with cross-fitting.
- 2
Calibrate the estimates
Apply one-dimensional adjustments to the outcome predictions and inverse probability weights.
- 3
Estimate effects and intervals
Compute the calibrated doubly robust estimate and a confidence interval.
Install
Available in R and Python.
Use the same estimation procedure in either language.
Installation and first examplepython -m pip install git+https://github.com/Larsvanderlaan/calibratedDML.gitremotes::install_github("Larsvanderlaan/calibratedDML")For other regression targets, specify a linear functional and supply cross-fitted regression and Riesz estimates. For binary-treatment estimation using a learned treatment-effect model, see Adaptive DML. For semisupervised mean estimation, see ppi_aipw.