calibratedDML GitHub

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

Fit and summarize
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()

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.

Why 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. 1

    Fit the nuisance models

    Estimate outcomes and treatment probabilities with cross-fitting.

  2. 2

    Calibrate the estimates

    Apply one-dimensional adjustments to the outcome predictions and inverse probability weights.

  3. 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 example
Install the package
python -m pip install git+https://github.com/Larsvanderlaan/calibratedDML.git

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.