pROC: Lower Bound of Sensitivity is not displayed right on ROC-Curve

I can’t find the bug in my code:
At a threshold of 0.3173677 the following sensitivity + 95 % CI should be plotted:

–> low: 0.70590 median: 0.8235 upper: 0.9412

Unfortunately the lower bound of se is not plotted right. As you can see in the plot, it is something like 0.68 and should be more close to 0.71. I do not have this problem with my other plots. I have compared my other codes to the one you can see in this post, but I am not able to find the error.

Hope you can help me out.

  y_pred_gesund = c(0.00578237, 0.05329814, 0.06638863, 0.11657998, 0.09474952,
       0.04716528, 0.25119904, 0.47698594, 0.35833103, 0.15637362,
       0.27704507, 0.65919458, 0.24238073, 0.14910174, 0.69475357,
       0.50563552, 0.80002238, 0.7051007 , 0.44420608, 0.21037749,
       0.06397617, 0.11677541, 0.22466454, 0.56244532, 0.67774251,
       0.29863889, 0.89408624, 0.17934509, 0.18724151, 0.79841682,
       0.26589102, 0.19238419, 0.21952037, 0.06087548, 0.126379  ,
       0.03503891, 0.04095548, 0.22670706, 0.14717827, 0.72644492,
       0.40010552, 0.13536545, 0.1537661 , 0.20038037, 0.23552361,
       0.08008775, 0.59824239, 0.39967286, 0.07968716, 0.08699301,
       0.35625533, 0.6098194 , 0.60030958, 0.50903341, 0.79489929,
       0.47671656, 0.7150811 , 0.5059392 , 0.11725486, 0.63610276,
       0.33609659, 0.48355634, 0.87606138, 0.92928469, 0.69375865,
       0.97552441, 0.76878145, 0.64389963, 0.85130681, 0.61455325,
       0.56401338, 0.26522224, 0.95388585, 0.63344538, 0.1296849 ,
       0.47407066, 0.8483158 , 0.90031392, 0.8269378 )

y_true_gesund = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)


set.seed(99)
boot = 2000

rocobj <- roc(y_true_gesund, y_pred_gesund)
print(ci.thresholds(rocobj,method = 'bootstrap',boot.n = boot))
print(ci.auc(rocobj, method = 'bootstrap', boot.n=boot))
ci.auc(rocobj, method = 'bootstrap', boot.n=boot)
###
ci.sp.obj <- ci.sp(rocobj, sensitivities=seq(0, 1, .01), boot.n=boot, boot.stratified = TRUE)
plot(rocobj, main = '',
     grid = TRUE,percent=TRUE, xlab = 'Spezifität',ylab = 'Sensitivität')
plot(ci.sp.obj, type="shape", col="lightgrey",density = 50)
ci1 <- ci.thresholds(rocobj,.95, thresholds = 0.3173677, boot.n=boot , boot.stratified = TRUE) 
plot(ci1)

OUT
      95% CI (2000 stratified bootstrap replicates):
     thresholds  sp.low sp.median sp.high  se.low se.median se.high
      0.0730379 0.06667    0.1778  0.2889 1.00000    1.0000  1.0000
      0.1170151 0.13330    0.2444  0.3778 0.82350    0.9118  1.0000
      0.1280320 0.13330    0.2667  0.4000 0.76470    0.8824  0.9706
      0.2582106 0.46670    0.6222  0.7556 0.73530    0.8529  0.9419
      0.3173677 0.55560    0.6889  0.8222 0.70590    0.8235  0.9412
      0.3790019 0.57780    0.7111  0.8444 0.61760    0.7647  0.9118
      0.4591384 0.62220    0.7556  0.8667 0.58820    0.7353  0.8824
      0.4802711 0.66670    0.7778  0.8889 0.50000    0.6765  0.8235
      0.5057874 0.66670    0.8000  0.9111 0.47060    0.6471  0.7941
      0.5632294 0.71110    0.8222  0.9333 0.41180    0.5882  0.7353
      0.6857506 0.75560    0.8667  0.9556 0.20590    0.3529  0.5000
      0.7100909 0.82220    0.9111  0.9778 0.17650    0.3235  0.4706
      0.7476132 0.84440    0.9333  1.0000 0.14710    0.2941  0.4412
      0.8134801 0.93330    0.9778  1.0000 0.11760    0.2353  0.3824
      0.8972001 1.00000    1.0000  1.0000 0.02941    0.1176  0.2353
    95% CI: 0.6418-0.8627 (2000 stratified bootstrap replicates)
    2.5%
    0.637892156862745
    50%
    0.761437908496732
    97.5%
    0.864722222222222

enter image description here

Go to Source
Author: Mischa