@@ -59,14 +59,18 @@ def _pointwise_estimate(self, t, m, x, y):
59
59
60
60
t , m , x , y = self ._resize (t , m , x , y )
61
61
p_x = self ._estimate_treatment_propensity_x (x )
62
+ p_x = np .clip (p_x , self ._clip , 1 - self ._clip )
62
63
63
64
if self ._prop_ratio == "treatment" :
64
65
p_xm = self ._estimate_treatment_propensity_xm (m , x )
66
+ p_xm = np .clip (p_xm , self ._clip , 1 - self ._clip )
65
67
prop_ratio_t1_m0 = (1 - p_xm ) / ((1 - p_x ) * p_xm )
66
68
prop_ratio_t0_m1 = p_xm / ((1 - p_xm ) * p_x )
67
69
68
70
elif self ._prop_ratio == "mediator" :
69
71
f_m0x , f_m1x = self ._estimate_mediator_probability (x , m )
72
+ f_m0x = np .clip (f_m0x , self ._clip , None )
73
+ f_m1x = np .clip (f_m1x , self ._clip , None )
70
74
prop_ratio_t1_m0 = f_m0x / (p_x * f_m1x )
71
75
prop_ratio_t0_m1 = f_m1x / ((1 - p_x ) * f_m0x )
72
76
@@ -79,8 +83,6 @@ def _pointwise_estimate(self, t, m, x, y):
79
83
prop_ratio_t0_m1 [ind ],
80
84
)
81
85
82
- p_x = np .clip (p_x , self ._clip , 1 - self ._clip )
83
-
84
86
# importance weighting
85
87
y1m1 = (y * t / p_x ) / np .mean (t / p_x )
86
88
y1m0 = (y * t * prop_ratio_t1_m0 ) / np .mean (t * prop_ratio_t1_m0 )
0 commit comments