@@ -1494,7 +1494,9 @@ class InversePropensityWeighting(ExperimentalDesign, PropensityDataValidator):
14941494 A string denoting the outcome variable in datq to be reweighted
14951495 :param weighting_scheme:
14961496 A string denoting which weighting scheme to use among: 'raw', 'robust',
1497- 'doubly robust'
1497+ 'doubly robust' or 'overlap'. See Aronow and Miller "Foundations
1498+ of Agnostic Statistics" for discussion and computation of these
1499+ weighting schemes.
14981500 :param model:
14991501 A PyMC model
15001502
@@ -1548,6 +1550,9 @@ def __init__(
15481550 self .model .fit (X = self .X , t = self .t , coords = COORDS )
15491551
15501552 def make_robust_adjustments (self , ps ):
1553+ """ This estimator is discussed in Aronow
1554+ and Miller's book as being related to the
1555+ Horvitz Thompson method """
15511556 X = pd .DataFrame (self .X , columns = self .labels )
15521557 X ["ps" ] = ps
15531558 X [self .outcome_variable ] = self .y
@@ -1565,6 +1570,9 @@ def make_robust_adjustments(self, ps):
15651570 return weighted_outcome0 , weighted_outcome1 , n_ntrt , n_trt
15661571
15671572 def make_raw_adjustments (self , ps ):
1573+ """ This estimator is discussed in Aronow and
1574+ Miller as the simplest of base form of
1575+ inverse propensity weighting schemes"""
15681576 X = pd .DataFrame (self .X , columns = self .labels )
15691577 X ["ps" ] = ps
15701578 X [self .outcome_variable ] = self .y
@@ -1581,6 +1589,10 @@ def make_raw_adjustments(self, ps):
15811589 return weighted_outcome0 , weighted_outcome1 , n_ntrt , n_trt
15821590
15831591 def make_overlap_adjustments (self , ps ):
1592+ """This weighting scheme was adapted from
1593+ Lucy D’Agostino McGowan's blog on
1594+ Propensity Score Weights referenced in
1595+ the primary CausalPy explainer notebook"""
15841596 X = pd .DataFrame (self .X , columns = self .labels )
15851597 X ["ps" ] = ps
15861598 X [self .outcome_variable ] = self .y
@@ -1597,6 +1609,12 @@ def make_overlap_adjustments(self, ps):
15971609 return weighted_outcome0 , weighted_outcome1 , n_ntrt , n_trt
15981610
15991611 def make_doubly_robust_adjustment (self , ps ):
1612+ """ The doubly robust weighting scheme is also
1613+ discussed in Aronow and Miller, but a bit more generally
1614+ than our implementation here. Here we have specified
1615+ the outcome model to be a simple OLS model.
1616+ In this way the compromise between the outcome model and
1617+ the propensity model is always done with OLS."""
16001618 X = pd .DataFrame (self .X , columns = self .labels )
16011619 X ["ps" ] = ps
16021620 t = self .t .flatten ()
@@ -1722,8 +1740,9 @@ def make_hists(idata, i, axs, method=method):
17221740 0.9 , linestyle = "--" , label = "Hi Extreme Propensity Scores" , color = "black"
17231741 )
17241742 axs [0 ].set_title (
1725- "Draws from the Posterior \n Propensity Scores Distribution" , fontsize = 20
1743+ "Weighted and Unweighted Draws from the Posterior \n Propensity Scores Distribution" , fontsize = 20
17261744 )
1745+ axs [0 ].set_ylabel ("Counts of Observations" )
17271746 axs [0 ].set_xlabel ("Propensity Scores" )
17281747 custom_lines = [
17291748 Line2D ([0 ], [0 ], color = "skyblue" , lw = 2 ),
0 commit comments