Skip to main content

Diagnostics

diagnose_calibration() estimates calibration error, reports a confidence interval, and compares raw and calibrated predictions. Supply predictions, treatment, outcome, and nuisance estimates for the same observations. Use cross-fitted nuisance estimates when possible.

Outputs

  • A calibration curve.
  • A robust estimate of squared L2 calibration error and a plug-in estimate.
  • A K-fold jackknife standard error and confidence interval.
  • A best linear projection (BLP) of the treatment-effect pseudo-outcome on an intercept and the score, with coefficient estimates, intervals, and p-values.
  • An optional comparison with another prediction vector.
  • Propensity-score and effective-sample-size summaries.

Target populations

target_population Calibration error reported for
"dr" The original study population, using a doubly robust pseudo-outcome
"overlap" The overlap-weighted population used by the R-loss
"both" Both populations, reported separately

For an R-loss fit, report the overlap-weighted diagnostic to assess calibration in the population used for fitting. You can also report the DR diagnostic to assess the same predictions in the original population.

Read the results

Calibration error

A small calibration error suggests that people with similar scores have an average treatment effect close to those scores, for the selected population. Read the estimate together with its confidence interval.

Supply the raw scores as comparison_predictions to compare them with calibrated scores on the same evaluation observations.

BLP intercept and slope

The BLP summarizes the linear relationship between the score and the treatment-effect pseudo-outcome. An intercept near 0 and a slope near 1 are consistent with calibration under this linear approximation. They do not establish calibration of the full curve.

A slope confidence interval excluding 0 provides evidence of treatment-effect variation associated with the score. An interval containing 0 means the data do not establish such an association. The BLP intervals and p-values use the same jackknife folds as the calibration-error estimate.

Example

from causal_calibration import diagnose_calibration

diagnostics = diagnose_calibration(
    predictions=tau_cross_calibrated,
    comparison_predictions=tau_raw,
    treatment=a,
    outcome=y,
    mu0=mu0_hat,
    mu1=mu1_hat,
    propensity=e_hat,
    target_population="both",
)

diagnostics.blp_diagnostic.summary()
library(causalCalibration)

diagnostics <- diagnose_calibration(
  predictions = tau_cross_calibrated,
  comparison_predictions = tau_raw,
  treatment = a,
  outcome = y,
  mu0 = mu0_hat,
  mu1 = mu1_hat,
  propensity = e_hat,
  target_population = "both"
)

summary(diagnostics$blp)

Here tau_cross_calibrated and tau_raw refer to the same evaluation observations as a, y, and the nuisance estimates.

Estimation details

The robust estimator follows Equation (2.4) of Xu and Yadlowsky (2022):

mean((Gamma_i - Delta_i) * (gamma_hat_oof(Delta_i) - Delta_i))

Delta_i is the input score, Gamma_i is the pseudo-outcome for the chosen population, and gamma_hat_oof is an out-of-fold estimate of the calibration curve. For the overlap target, the package uses the corresponding observation weights.

Curve estimation depends on curve_method:

  • linear uses exact leave-one-out updates.
  • histogram uses within-bin leave-one-out corrections with fixed bin boundaries.
  • isotonic and monotone_spline use K-fold refits.

The jackknife uses supplied fold_ids when available. Otherwise, it creates deterministic balanced folds with jackknife_folds=100 by default.

See Losses and methods for target-population choices and the API reference for inputs.