API Reference#
Automatically-generated API documentation.
estimation#
Causal model implementing inverse probability (propensity score) weighting. |
|
Implementation of overlap (propensity score) weighting: |
|
Match treatment and control samples with similar covariates. |
|
Matching on propensity score only. |
|
Standard standardization model for causal inference. |
|
Standardization model that learns a model for each treatment group (i.e. subgroup of subjects with the same treatment assignment). |
|
Targeted Maximum Likelihood Estimation. |
|
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). |
|
A doubly-robust estimator of the effect of treatment. |
|
This model uses the weights from the weight-model (e.g. inverse probability weighting) as individual weights for fitting the outcome model. |
|
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. |
|
An X-learner model for causal inference (künzel et al. 2018. |
|
A marginal outcome predictor. |
survival#
Weighted survival estimator |
|
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: |
|
Combines WeightedSurvival and StandardizedSurvival: |
|
Marginal (un-adjusted) survival estimator. |
|
Default implementation of a parametric survival curve fitter with covariates (pooled regression). |
|
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#
Transform covariates by adding/replacing with the propensity score. |
|
Transform data by removing poorly matched samples. |
confounder_selection#
A method for selecting confounders using sparse regression on both the treatment and the outcomes, and select for |
|
Recursively eliminate confounders to prune confounders. |
positivity#
Filter positivity by calculating univariate support |
model selection and evaluation#
metrics#
Gets a scorer callable from string. |
|
Get the name of all available scorers. |
model_selection#
wraps a hyperparameter search algorithm (like sklearn's GridSearchCV) with a causallib model interface. |
|
Creates stratified folds based on the treatment assignment. |
|
Creates stratified folds based on both the treatment assignment and the outcome. |
evaluate#
Evaluate model in cross-validation of the provided data |
|
Evaluate model on a bootstrap sample of the provided data |
datasets#
Loads the NHEFS smoking-cessation and weight-loss dataset. |
|
Loads and pre-processes the NHEFS smoking-cessation dataset. |
|
Loads single dataset from the 2016 Atlantic Causal Inference Conference data challenge. |
|
contrib#
Adversarial Balancing finds sample weights such that the weighted population under any treatment A looks similar (distribution-wise) to the true population. |
|
This is the model defintion. |
|
A causal model effect estimator built on top of a tree recursively stratifying the covariate space to balance between treated and untreated. |
|
NearestNeighbors object utilizing the faiss library for speed |