Y
Observed scalar outcomes for all units.
Causal Inference
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
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
YObserved scalar outcomes for all units.
AObserved treatment assignments. Binary, discrete, and categorical labels are supported.
Yhat_potentialA matrix or DataFrame with one column per treatment arm and one row per unit.
treatment_levelsOptional arm labels matching the columns of Yhat_potential. If omitted, DataFrame columns are used; otherwise the sorted unique values in A are used.
control_armOptional control arm used for ATE comparisons. The default is the minimum resolved treatment level.
methodAny calibration method supported by mean_inference(), including "aipw", "linear", "prognostic_linear", "sigmoid", "monotone_spline", "isotonic", and "auto".
XOptional 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_fitDefaults 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.
wOptional 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_meansEstimated mean potential outcome for every resolved treatment arm.
arm_cisWald confidence intervals for each arm-specific mean.
ateTreatment effects for each arm relative to control.
arm_resultsThe underlying arm-by-arm MeanInferenceResult objects, exposed for inspection.
summary()Estimates, standard errors, and Wald confidence intervals for arm means and treatment effects.
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.