Skip to content

Commit

Permalink
Fix double counting in two sided bootstrap confidence intervals (#1126)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
amit-sharma committed Dec 22, 2023
1 parent 0c47c45 commit e0d0038
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dowhy/causal_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ def _estimate_confidence_intervals_with_bootstrap(
bootstrap_variations = [bootstrap_estimate - estimate_value for bootstrap_estimate in bootstrap_estimates]
sorted_bootstrap_variations = np.sort(bootstrap_variations)

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

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

0 comments on commit e0d0038

Please sign in to comment.