InversePropensityWeighting#
- class causalpy.experiments.inverse_propensity_weighting.InversePropensityWeighting[source]#
A class to analyse inverse propensity weighting experiments.
- Parameters:
- :param outcome_variable
A string denoting the outcome variable in datq to be reweighted
- Parameters:
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 – A PyMC model
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, ...)Abstract method for plotting the model.
InversePropensityWeighting.get_ate
(i, idata)Validate the input data and model formula for correctness
InversePropensityWeighting.make_doubly_robust_adjustment
(ps)The doubly robust weighting scheme is also discussed in Aronow and Miller, but a bit more generally than our implementation here.
This weighting scheme was adapted from Lucy D’Agostino McGowan's blog on Propensity Score Weights referenced in the primary CausalPy explainer notebook
This estimator is discussed in Aronow and Miller as the simplest of base form of inverse propensity weighting schemes
This estimator is discussed in Aronow and Miller's book as being related to the Horvitz Thompson method
InversePropensityWeighting.ols_plot
(*args, ...)Abstract method for plotting the model.
InversePropensityWeighting.plot
(*args, **kwargs)Plot the model.
InversePropensityWeighting.plot_ate
([idata, ...])Plotting function takes a single covariate and shows the differences in the ECDF between the treatment and control groups before and after weighting.
Ask the model to print its coefficients.
perc : percentile in [0-1]!
Attributes
idata
Return the InferenceData object of the model.
supports_bayes
supports_ols
- __new__(**kwargs)#