API Reference#

Automatically-generated API documentation.

estimation#

IPW

Causal model implementing inverse probability (propensity score) weighting.

OverlapWeights

Implementation of overlap (propensity score) weighting:

Matching

Match treatment and control samples with similar covariates.

PropensityMatching

Matching on propensity score only.

Standardization

Standard standardization model for causal inference.

StratifiedStandardization

Standardization model that learns a model for each treatment group (i.e. subgroup of subjects with the same treatment assignment).

TMLE

Targeted Maximum Likelihood Estimation.

AIPW

Calculates a doubly-robust estimate of the treatment effect by performing potential-outcome prediction (outcome_model) and then correcting its prediction-residuals using re-weighting from a treatment model (weight_model, like IPW).

PropensityFeatureStandardization

A doubly-robust estimator of the effect of treatment.

WeightedStandardization

This model uses the weights from the weight-model (e.g. inverse probability weighting) as individual weights for fitting the outcome model.

RLearner

Given the measured outcome Y, the assignment A, and the coefficients X calculate an R-learner estimator of the effect of the treatment Let e(X) be the estimated propensity score and m(X) is the estimated outcome (E[Y|X]) by an estimator, then the R-learner minimize the following: ||Y - m(X) - (A-e(X)) au(X)||^2_2 + lambda ( au) where au(X) is a conditional average treatment effect and lambda is a regularize coefficient.

XLearner

An X-learner model for causal inference (künzel et al. 2018.

MarginalOutcomeEstimator

A marginal outcome predictor.

survival#

WeightedSurvival

Weighted survival estimator

StandardizedSurvival

Standardization survival estimator. Computes parametric curve by fitting a time-varying hazards model that includes baseline covariates. :param survival_model: Two alternatives: 1. Scikit-Learn estimator (needs to implement predict_proba) - compute parametric curve by fitting a time-varying hazards model that includes baseline covariates. Note that the model is fitted on a person-time table with all covariates, and might be computationally and memory expansive. 2. lifelines RegressionFitter - use lifelines fitter to compute survival curves from baseline covariates, events and durations :param stratify: if True, fit a separate model per treatment group :type stratify: bool.

WeightedStandardizedSurvival

Combines WeightedSurvival and StandardizedSurvival:

MarginalSurvival

Marginal (un-adjusted) survival estimator.

RegressionCurveFitter

Default implementation of a parametric survival curve fitter with covariates (pooled regression).

UnivariateCurveFitter

Default implementation of a univariate survival curve fitter. Construct a curve fitter, either non-parametric (Kaplan-Meier) or parametric. API follows 'lifelines' convention for univariate models, see here for example: https://lifelines.readthedocs.io/en/latest/fitters/univariate/KaplanMeierFitter.html#lifelines.fitters.kaplan_meier_fitter.KaplanMeierFitter.fit :param learner: optional scikit-learn estimator (needs to implement predict_proba). If provided, will compute parametric curve by fitting a time-varying hazards model. if None, will compute non-parametric Kaplan-Meier estimator.

preprocessing#

transformers#

PropensityTransformer

Transform covariates by adding/replacing with the propensity score.

MatchingTransformer

Transform data by removing poorly matched samples.

confounder_selection#

DoubleLASSO

A method for selecting confounders using sparse regression on both the treatment and the outcomes, and select for

RecursiveConfounderElimination

Recursively eliminate confounders to prune confounders.

positivity#

Trimming

UnivariateBoundingBox

Filter positivity by calculating univariate support

model selection and evaluation#

metrics#

get_scorer

Gets a scorer callable from string.

get_scorer_names

Get the name of all available scorers.

model_selection#

causalize_searcher

wraps a hyperparameter search algorithm (like sklearn's GridSearchCV) with a causallib model interface.

GridSearchCV

RandomizedSearchCV

TreatmentStratifiedKFold

Creates stratified folds based on the treatment assignment.

TreatmentOutcomeStratifiedKFold

Creates stratified folds based on both the treatment assignment and the outcome.

evaluate#

evaluate

Evaluate model in cross-validation of the provided data

evaluate_bootstrap

Evaluate model on a bootstrap sample of the provided data

datasets#

datasets.load_nhefs

Loads the NHEFS smoking-cessation and weight-loss dataset.

datasets.load_nhefs_survival

Loads and pre-processes the NHEFS smoking-cessation dataset.

datasets.load_acic16

Loads single dataset from the 2016 Atlantic Causal Inference Conference data challenge.

simulation.CausalSimulator3

contrib#

AdversarialBalancing

Adversarial Balancing finds sample weights such that the weighted population under any treatment A looks similar (distribution-wise) to the true population.

HEMM

This is the model defintion.

BICauseTree

A causal model effect estimator built on top of a tree recursively stratifying the covariate space to balance between treated and untreated.

FaissNearestNeighbors

NearestNeighbors object utilizing the faiss library for speed