InversePropensityWeighting#
- class causalpy.experiments.inverse_propensity_weighting.InversePropensityWeighting[source]#
A class to analyse inverse propensity weighting experiments.
- Parameters:
data (
DataFrame) – A pandas dataframe.formula (
str) – A statistical model formula for the propensity model.outcome_variable (
str) – A string denoting the outcome variable in data to be reweighted.weighting_scheme (
str) – A string denoting which weighting scheme to use among: ‘raw’, ‘robust’, ‘doubly_robust’ or ‘overlap’. See Aronow and Miller “Foundations of Agnostic Statistics” for discussion and computation of these weighting schemes.model (
PropensityScore|None) – A PyMC model. Defaults to PropensityScore.
Example
>>> import causalpy as cp >>> df = cp.load_data("nhefs") >>> seed = 42 >>> result = cp.InversePropensityWeighting( ... df, ... formula="trt ~ 1 + age + race", ... outcome_variable="outcome", ... weighting_scheme="robust", ... model=cp.pymc_models.PropensityScore( ... sample_kwargs={ ... "draws": 100, ... "target_accept": 0.95, ... "random_seed": seed, ... "progressbar": False, ... }, ... ), ... )
Methods
InversePropensityWeighting.__init__(data, ...)Run the experiment algorithm by fitting the propensity score model.
Generate a decision-ready summary of causal effects.
InversePropensityWeighting.fit(*args, **kwargs)Generate a self-contained HTML report for this experiment.
InversePropensityWeighting.get_ate(i, idata)Compute the Average Treatment Effect for a single posterior sample.
Recover the data of an experiment along with the prediction and causal impact information.
Return plot data for Bayesian models.
Return plot data for OLS models.
Validate the input data and model formula for correctness.
InversePropensityWeighting.make_doubly_robust_adjustment(ps)Compute doubly-robust adjusted outcomes.
Compute inverse-propensity-weighted outcomes using the overlap scheme.
Compute inverse-propensity-weighted outcomes using the raw (basic) scheme.
Compute inverse-propensity-weighted outcomes using the robust (Horvitz-Thompson) scheme.
InversePropensityWeighting.plot(*args[, show])Plot the model.
InversePropensityWeighting.plot_ate([idata, ...])Plot the Average Treatment Effect and propensity score distributions.
Plot the empirical CDF of a covariate before and after IPW adjustment.
Ask the model to print its coefficients.
Set optional maketables rendering options for this experiment.
Compute a weighted percentile of the data.
Attributes
idataReturn the InferenceData object of the model.
supports_bayessupports_olslabelsdata- classmethod __new__(*args, **kwargs)#