Function to compute optimal cut-off scores
cutscores.RdThis function computes the optimal cut-off scores based on sensitivity, specificity, and the Youden Index (Youden, 1950) <doi:10.1002/1097-0142(1950)3:1<32::AID-CNCR2820030106>3.0.CO;2-3>.
Arguments
- outcome
The outcome variable indicating the status in the form of a data frame or matrix. This variable is typically coded as 0 (positive) and 1 (negative).
- predictor
A numerical vector of scores used to predict the status of the outcome. This variable should be of the same length as the outcome variable (i.e., two variables are from the same data set and also of the same number of data rows).
Value
A list of two objects: (1) summary statistics of selected cut scores, and (2) detailed information of each used cut score and corresponding classification statistics.
- Summary
Summary statistics of selected cut scores. Specifically,
* Cut.off, the select cut-off scores according to different criteria
* SEN, Sensitivity, also true positive rate, the y-axis of the ROC.
* SPE, Specificity, also true negative rate.
* 1-SPE, the x-axis of the ROC.
* Youden.Index.
* TP, true positives.
* FP, false positives.
* FN, false negatives.
* TN, true negatives.- Details
Detailed information of each used cut score and corresponding classification statistics.
References
Youden, W.J. (1950). "Index for rating diagnostic tests." Cancer,3, 32-35. doi:10.1002/1097-0142(1950)3:1<32::AID-CNCR2820030106>3.0.CO;2-3.
Examples
#read the example data
data(ROC.data.ex)
#run the function
result<-cutscores(ROC.data.ex$outcome, ROC.data.ex$predictor)
#obtain results
result$Summary
#> Cut.off SEN SPE 1-SPE Youden.Index TP FP FN TN
#> max.sen 66.790 0.9818182 0.8225806 0.177419355 0.8043988 54 33 1 153
#> max.spe 97.985 0.5272727 0.9946237 0.005376344 0.5218964 29 1 26 185
#> max.Youden 66.790 0.9818182 0.8225806 0.177419355 0.8043988 54 33 1 153
result$Details
#> Cut.off SEN SPE 1-SPE Youden.Index TP FP FN TN
#> 1 59.000 1.00000000 0.0000000 1.000000000 0.00000000 55 186 0 0
#> 2 60.185 1.00000000 0.1720430 0.827956989 0.17204301 55 154 0 32
#> 3 60.375 1.00000000 0.2580645 0.741935484 0.25806452 55 138 0 48
#> 4 60.390 1.00000000 0.2741935 0.725806452 0.27419355 55 135 0 51
#> 5 60.410 1.00000000 0.2795699 0.720430108 0.27956989 55 134 0 52
#> 6 60.490 1.00000000 0.2903226 0.709677419 0.29032258 55 132 0 54
#> 7 60.650 1.00000000 0.2956989 0.704301075 0.29569892 55 131 0 55
#> 8 60.755 1.00000000 0.3387097 0.661290323 0.33870968 55 123 0 63
#> 9 60.940 1.00000000 0.3548387 0.645161290 0.35483871 55 120 0 66
#> 10 61.130 1.00000000 0.3924731 0.607526882 0.39247312 55 113 0 73
#> 11 61.175 1.00000000 0.3978495 0.602150538 0.39784946 55 112 0 74
#> 12 61.225 1.00000000 0.4086022 0.591397849 0.40860215 55 110 0 76
#> 13 61.365 1.00000000 0.4139785 0.586021505 0.41397849 55 109 0 77
#> 14 61.510 1.00000000 0.4569892 0.543010753 0.45698925 55 101 0 85
#> 15 61.570 1.00000000 0.4677419 0.532258065 0.46774194 55 99 0 87
#> 16 61.725 1.00000000 0.4731183 0.526881720 0.47311828 55 98 0 88
#> 17 61.885 1.00000000 0.5215054 0.478494624 0.52150538 55 89 0 97
#> 18 61.960 1.00000000 0.5322581 0.467741935 0.53225806 55 87 0 99
#> 19 62.085 1.00000000 0.5483871 0.451612903 0.54838710 55 84 0 102
#> 20 62.195 1.00000000 0.5537634 0.446236559 0.55376344 55 83 0 103
#> 21 62.265 1.00000000 0.5698925 0.430107527 0.56989247 55 80 0 106
#> 22 62.450 1.00000000 0.5752688 0.424731183 0.57526882 55 79 0 107
#> 23 62.640 1.00000000 0.5913978 0.408602151 0.59139785 55 76 0 110
#> 24 62.805 1.00000000 0.6021505 0.397849462 0.60215054 55 74 0 112
#> 25 62.940 1.00000000 0.6075269 0.392473118 0.60752688 55 73 0 113
#> 26 63.020 1.00000000 0.6236559 0.376344086 0.62365591 55 70 0 116
#> 27 63.140 1.00000000 0.6290323 0.370967742 0.62903226 55 69 0 117
#> 28 63.265 1.00000000 0.6397849 0.360215054 0.63978495 55 67 0 119
#> 29 63.515 1.00000000 0.6774194 0.322580645 0.67741935 55 60 0 126
#> 30 63.885 1.00000000 0.7043011 0.295698925 0.70430108 55 55 0 131
#> 31 64.120 1.00000000 0.7150538 0.284946237 0.71505376 55 53 0 133
#> 32 64.375 1.00000000 0.7204301 0.279569892 0.72043011 55 52 0 134
#> 33 64.600 1.00000000 0.7258065 0.274193548 0.72580645 55 51 0 135
#> 34 64.715 0.98181818 0.7258065 0.274193548 0.70762463 54 51 1 135
#> 35 65.115 0.98181818 0.7419355 0.258064516 0.72375367 54 48 1 138
#> 36 65.490 0.98181818 0.7526882 0.247311828 0.73450635 54 46 1 140
#> 37 65.580 0.98181818 0.7580645 0.241935484 0.73988270 54 45 1 141
#> 38 65.625 0.98181818 0.7634409 0.236559140 0.74525904 54 44 1 142
#> 39 65.975 0.98181818 0.7795699 0.220430108 0.76138807 54 41 1 145
#> 40 66.330 0.98181818 0.7903226 0.209677419 0.77214076 54 39 1 147
#> 41 66.380 0.98181818 0.8010753 0.198924731 0.78289345 54 37 1 149
#> 42 66.435 0.98181818 0.8118280 0.188172043 0.79364614 54 35 1 151
#> 43 66.505 0.98181818 0.8172043 0.182795699 0.79902248 54 34 1 152
#> 44 66.790 0.98181818 0.8225806 0.177419355 0.80439883 54 33 1 153
#> 45 67.090 0.96363636 0.8279570 0.172043011 0.79159335 53 32 2 154
#> 46 67.225 0.94545455 0.8279570 0.172043011 0.77341153 52 32 3 154
#> 47 67.360 0.87272727 0.8279570 0.172043011 0.70068426 48 32 7 154
#> 48 67.665 0.87272727 0.8387097 0.161290323 0.71143695 48 30 7 156
#> 49 67.960 0.87272727 0.8440860 0.155913978 0.71681329 48 29 7 157
#> 50 68.040 0.87272727 0.8494624 0.150537634 0.72218964 48 28 7 158
#> 51 68.115 0.87272727 0.8602151 0.139784946 0.73294233 48 26 7 160
#> 52 68.240 0.87272727 0.8709677 0.129032258 0.74369501 48 24 7 162
#> 53 68.425 0.83636364 0.8709677 0.129032258 0.70733138 46 24 9 162
#> 54 68.580 0.83636364 0.8763441 0.123655914 0.71270772 46 23 9 163
#> 55 68.745 0.83636364 0.8817204 0.118279570 0.71808407 46 22 9 164
#> 56 68.970 0.83636364 0.8978495 0.102150538 0.73421310 46 19 9 167
#> 57 69.785 0.83636364 0.9032258 0.096774194 0.73958944 46 18 9 168
#> 58 70.920 0.81818182 0.9032258 0.096774194 0.72140762 45 18 10 168
#> 59 71.450 0.81818182 0.9086022 0.091397849 0.72678397 45 17 10 169
#> 60 71.695 0.81818182 0.9139785 0.086021505 0.73216031 45 16 10 170
#> 61 72.035 0.81818182 0.9193548 0.080645161 0.73753666 45 15 10 171
#> 62 72.265 0.81818182 0.9247312 0.075268817 0.74291300 45 14 10 172
#> 63 72.450 0.81818182 0.9301075 0.069892473 0.74828935 45 13 10 173
#> 64 72.640 0.81818182 0.9354839 0.064516129 0.75366569 45 12 10 174
#> 65 73.635 0.81818182 0.9408602 0.059139785 0.75904203 45 11 10 175
#> 66 74.600 0.78181818 0.9408602 0.059139785 0.72267840 43 11 12 175
#> 67 75.135 0.78181818 0.9516129 0.048387097 0.73343109 43 9 12 177
#> 68 76.060 0.76363636 0.9516129 0.048387097 0.71524927 42 9 13 177
#> 69 77.285 0.76363636 0.9569892 0.043010753 0.72062561 42 8 13 178
#> 70 79.265 0.74545455 0.9569892 0.043010753 0.70244379 41 8 14 178
#> 71 81.325 0.74545455 0.9623656 0.037634409 0.70782014 41 7 14 179
#> 72 82.570 0.74545455 0.9677419 0.032258065 0.71319648 41 6 14 180
#> 73 83.960 0.74545455 0.9731183 0.026881720 0.71857283 41 5 14 181
#> 74 85.575 0.74545455 0.9784946 0.021505376 0.72394917 41 4 14 182
#> 75 86.555 0.74545455 0.9838710 0.016129032 0.72932551 41 3 14 183
#> 76 87.370 0.72727273 0.9838710 0.016129032 0.71114370 40 3 15 183
#> 77 87.930 0.69090909 0.9838710 0.016129032 0.67478006 38 3 17 183
#> 78 88.605 0.61818182 0.9838710 0.016129032 0.60205279 34 3 21 183
#> 79 91.955 0.56363636 0.9838710 0.016129032 0.54750733 31 3 24 183
#> 80 95.345 0.52727273 0.9838710 0.016129032 0.51114370 29 3 26 183
#> 81 96.155 0.52727273 0.9892473 0.010752688 0.51652004 29 2 26 184
#> 82 97.985 0.52727273 0.9946237 0.005376344 0.52189638 29 1 26 185
#> 83 99.785 0.50909091 0.9946237 0.005376344 0.50371457 28 1 27 185
#> 84 101.460 0.47272727 0.9946237 0.005376344 0.46735093 26 1 29 185
#> 85 103.865 0.47272727 1.0000000 0.000000000 0.47272727 26 0 29 186
#> 86 106.455 0.43636364 1.0000000 0.000000000 0.43636364 24 0 31 186
#> 87 108.595 0.38181818 1.0000000 0.000000000 0.38181818 21 0 34 186
#> 88 109.730 0.32727273 1.0000000 0.000000000 0.32727273 18 0 37 186
#> 89 111.765 0.29090909 1.0000000 0.000000000 0.29090909 16 0 39 186
#> 90 113.310 0.27272727 1.0000000 0.000000000 0.27272727 15 0 40 186
#> 91 113.765 0.25454545 1.0000000 0.000000000 0.25454545 14 0 41 186
#> 92 114.815 0.20000000 1.0000000 0.000000000 0.20000000 11 0 44 186
#> 93 116.310 0.18181818 1.0000000 0.000000000 0.18181818 10 0 45 186
#> 94 117.420 0.14545455 1.0000000 0.000000000 0.14545455 8 0 47 186
#> 95 119.115 0.09090909 1.0000000 0.000000000 0.09090909 5 0 50 186
#> 96 122.100 0.07272727 1.0000000 0.000000000 0.07272727 4 0 51 186
#> 97 123.875 0.03636364 1.0000000 0.000000000 0.03636364 2 0 53 186
#> 98 125.150 0.01818182 1.0000000 0.000000000 0.01818182 1 0 54 186
#> 99 127.300 0.00000000 1.0000000 0.000000000 0.00000000 0 0 55 186