diff --git a/src/turnbull.rs b/src/turnbull.rs index 6874a79..fa06274 100644 --- a/src/turnbull.rs +++ b/src/turnbull.rs @@ -723,12 +723,12 @@ fn survival_prob_likelihood_ratio_ci(data: &TurnbullData, progress_bar: Progress // Compute upper confidence limit root_finder = AndersonBjorckRootFinder::new( - 0.0, s[time_index], - f64::NAN, -CHI2_1DF_95 // Value of (lr_statistic - CHI2_1DF_95), which we are seeking the roots of + s[time_index], 1.0, + -CHI2_1DF_95, f64::NAN // Value of (lr_statistic - CHI2_1DF_95), which we are seeking the roots of ); - ci_estimate = s[time_index] - Z_97_5 * oim_se[time_index - 1]; - if ci_estimate < 0.0 { + ci_estimate = s[time_index] + Z_97_5 * oim_se[time_index - 1]; + if ci_estimate > 1.0 { ci_estimate = root_finder.next_guess(); // Returns interval midpoint in this case } @@ -744,8 +744,6 @@ fn survival_prob_likelihood_ratio_ci(data: &TurnbullData, progress_bar: Progress value_left, value_right // Value of (lr_statistic - CHI2_1DF_95), which we are seeking the roots of ); - // TODO: Terminate if reached precision already - ci_estimate = root_finder.next_guess(); // Returns interval midpoint in this case } }