Y
Observed scalar outcomes for all units.
Causal Inference
causal_inference(...) reuses the package's
semisupervised mean engine. For each treatment arm, it uses the
corresponding column of Yhat_potential, treats units
in that arm as labeled, and units outside that arm as unlabeled.
Quickstart
The combined
quickstart notebook opens in Colab
installs ppi-aipw automatically and pairs this causal example with the main semisupervised mean workflow, so it is a good single entry point if you want both APIs side by side.
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.
All numeric inputs must be finite. The package rejects
NaN and Inf values in outcomes,
potential-outcome predictions, covariates, and weights with clear
validation errors.
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 mean-API calibration method, 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.
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.
ateAll non-control-vs-control treatment effects by default.
arm_resultsThe underlying arm-by-arm MeanInferenceResult objects, exposed for inspection.
summary()A human-readable Wald summary for all arm means and control-vs-treatment ATEs.
This API reuses the package's semisupervised mean machinery. It does not fit a propensity model or other nuisance functions for you.
Optional full-sample weights are supported, but this package does not currently provide a causal-arm-specific weight-construction helper.
In this version, uncertainty is Wald-only. The API uses arm-specific Wald contributions from the semisupervised mean engine to build both arm-level and ATE-level standard errors.