Skip to content

Commit e0d0038

Browse files
authored
Fix double counting in two sided bootstrap confidence intervals (#1126)
* fixed double counting in bootstrap conf interval Signed-off-by: Amit Sharma <[email protected]> * fixed double counting in bootstrap conf interval Signed-off-by: Amit Sharma <[email protected]> * formatted correctly Signed-off-by: Amit Sharma <[email protected]> --------- Signed-off-by: Amit Sharma <[email protected]>
1 parent 0c47c45 commit e0d0038

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

dowhy/causal_estimator.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,11 @@ def _estimate_confidence_intervals_with_bootstrap(
350350
bootstrap_variations = [bootstrap_estimate - estimate_value for bootstrap_estimate in bootstrap_estimates]
351351
sorted_bootstrap_variations = np.sort(bootstrap_variations)
352352

353-
# Now we take the (1- p)th and the (p)th variations, where p is the chosen confidence level
354-
upper_bound_index = int((1 - confidence_level) * len(sorted_bootstrap_variations))
355-
lower_bound_index = int(confidence_level * len(sorted_bootstrap_variations))
353+
# Now we take the (1-p)/2 th and the 1-(1-p)/2 th variations, where p is the chosen confidence level
354+
left_fraction = (1 - confidence_level) / 2
355+
right_fraction = 1 - left_fraction
356+
upper_bound_index = int(left_fraction * len(sorted_bootstrap_variations))
357+
lower_bound_index = int(right_fraction * len(sorted_bootstrap_variations))
356358

357359
# Get the lower and upper bounds by subtracting the variations from the estimate
358360
lower_bound = estimate_value - sorted_bootstrap_variations[lower_bound_index]

0 commit comments

Comments
 (0)