Causal Inference

Potential outcome means and treatment effects.

For each treatment arm, causal_inference(...) estimates the mean potential outcome using the corresponding column of Yhat_potential. Observations in that arm are labeled; those in other arms are unlabeled for that calculation.

Quickstart

Estimate treatment effects

The combined quickstart notebook opens in Colab installs ppi-aipw and includes examples of mean and treatment-effect estimation.

from ppi_aipw import causal_inference

result = causal_inference(
    Y,
    A,
    Yhat_potential,
    X=X,
    w=w,
    treatment_levels=("control", "treated"),
    method="prognostic_linear",
    alpha=0.1,
)

mu_control = result.arm_means["control"]
mu_treated = result.arm_means["treated"]
ate = result.ate["treated"]
lower, upper = result.ate_cis["treated"]

print(result.summary())

The returned result object also has summary() for a compact Wald summary of the arm means and treatment effects.

Inputs

Inputs

Y

Observed scalar outcomes for all units.

A

Observed treatment assignments. Binary, discrete, and categorical labels are supported.

Yhat_potential

A matrix or DataFrame with one column per treatment arm and one row per unit.

treatment_levels

Optional arm labels matching the columns of Yhat_potential. If omitted, DataFrame columns are used; otherwise the sorted unique values in A are used.

control_arm

Optional control arm used for ATE comparisons. The default is the minimum resolved treatment level.

method

Any calibration method supported by mean_inference(), including "aipw", "linear", "prognostic_linear", "sigmoid", "monotone_spline", "isotonic", and "auto".

X

Optional extra covariates passed through arm by arm. This is most useful with method="prognostic_linear", which uses the arm-specific predicted outcome plus X in a linear adjustment.

cross_fit

Defaults to False. Set True for honest calibration within each treatment arm, with calibration_folds=10 by default. Wald standard errors use the same held-out predictions.

w

Optional full-sample observation weights. These can be inverse propensity weights or balancing weights. In randomized studies, they can be used to adjust for chance covariate imbalance and improve efficiency; in observational studies, they can be used to adjust for confounding and reduce bias. Uniform weights reproduce the unweighted behavior.

Outputs

Arm means, ATEs, and diagnostics

arm_means

Estimated mean potential outcome for every resolved treatment arm.

arm_cis

Wald confidence intervals for each arm-specific mean.

ate

Treatment effects for each arm relative to control.

arm_results

The underlying arm-by-arm MeanInferenceResult objects, exposed for inspection.

summary()

Estimates, standard errors, and Wald confidence intervals for arm means and treatment effects.

Scope

Supply the predicted potential outcomes and any observation weights. The function does not fit propensity models or other nuisance functions.

Weights must be constructed before calling the function.

Causal inference currently supports Wald intervals. Standard errors for arm means and treatment effects use the contributions from each arm-specific mean estimate.