Skip to main content

API reference

Core fitting functions

fit_calibrator()

Fit a single calibration map on predictions from a separate calibration sample.

Required by loss

  • loss="dr": mu0, mu1, propensity
  • loss="r": outcome_mean, propensity

Common mistakes

  • supplying raw learner objects instead of prediction vectors,
  • forgetting outcome_mean for loss="r",
  • using non-binary treatment indicators.

fit_cross_calibrator()

Use for cross-fitted treatment-effect predictions.

Prediction inputs

  • predictions: pooled out-of-fold predictions used to fit the calibration map
  • fold_predictions: n x K matrix used for calibrated aggregation at prediction time
  • fold_ids: optional out-of-fold column index per observation; when supplied, the package checks that each out-of-fold prediction matches the entry in its designated column.

Common mistakes

  • swapping predictions and fold_predictions,
  • passing a single-column matrix instead of predictions from all fold-specific models,
  • forgetting that prediction later also expects a fold-specific matrix.

Validation helpers

  • validate_crossfit_bundle(...): validate pooled OOF predictions, fold matrices, and optional fold IDs before fitting.
  • crossfit_bundle(...) / crossfit_bundle_from_data_frame(...): collect predictions, nuisance estimates, and fold information in one object.

diagnose_calibration()

Estimate a calibration curve and squared L2 calibration error, and report confidence intervals and a best linear projection of the pseudo-outcome on the score.

Inputs

  • predictions, treatment, outcome, mu0, mu1, and propensity,
  • outcome_mean for the overlap target (if omitted, computed from mu0, mu1, and propensity),
  • optional comparison vector,
  • optional target_population = "dr" | "overlap" | "both".

Interpretation

Select the original or overlap-weighted population with target_population. See Diagnostics for interpretation.

assess_overlap()

Summarize propensity-score tails and effective sample sizes before choosing a calibration loss.

Outputs

  • propensity min/max,
  • tail fractions below 0.05, 0.10, above 0.90, 0.95 used by the default screen,
  • clipped fraction,
  • IPW effective sample size,
  • overlap-weight effective sample size,
  • severity label and recommended loss under the package defaults.

The severity label and loss recommendation use practical screening cutoffs. Choose the target population based on your scientific question.

Bundle helpers

  • calibration_bundle(...) / calibration_bundle_from_data_frame(...)
  • crossfit_bundle(...) / crossfit_bundle_from_data_frame(...)
  • fit_bundle_calibrator(...)
  • fit_bundle_cross_calibrator(...)

Fitted objects

Calibrator

  • predict(...): apply the fitted calibration map
  • summary(): fitting options and sample size
  • plotting: visualize the fitted calibration map

CrossCalibrator

  • predict(...): apply the map to a fold-specific matrix and aggregate with the order-statistic median
  • summary(): metadata summary including fold count

CalibrationDiagnostics

  • summary(): scalar results, BLP slope/intercept summaries, and intervals
  • plotting helpers: display the estimated calibration curve

Full examples