Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ho to make the Receiver operating characteristic (ROC) and identifying the Youden index

Tags:

r

roc

stata

I would like to make a ROC curve and identify the Youden-Index. I have a subsample as below. Where I need to find cut point for the column "val" based on the reference column "ref". How can I make the ROC plot, identifying the cutoff with specificities and sensitivities as well as Youden Index, in Stata or R?

cut_= structure(list(val = c("2.5", "3.5", "1.5", "1.1", "2.4", "1.6", 
    "1.9", "2.7", "1.2", "1.5", "2.1", "1.4", "1.8", "3.5", "2.5", 
    "2.4"), ref = c(1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 
    1)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
    -16L))
like image 355
Lisa Avatar asked Oct 25 '25 14:10

Lisa


1 Answers

As mentioned in the comments, it is pretty easy to obtain in R with pROC. You need to convert val to a numeric vector first, then you can create the ROC curve, let's call it cut_roc:

cut_$val <- as.numeric(cut_$val)
library(pROC)
cut_roc <- roc(cut_$ref, cut_$val)

Then it's as simple as a call to coords with x="best" to get the best threshold(s) (youden is the default so the last argument is optional):

coords(cut_roc, x="best", best.method="youden")
#   threshold specificity sensitivity
# 1      1.15       0.125       1.000
# 2      1.45       0.250       0.875
# 3      2.25       0.625       0.500
# 4      2.45       0.750       0.375
# 5      2.60       0.875       0.250

Note that in this specific ROC curve, multiple points of the curve maximize the Youden index.

like image 162
Calimo Avatar answered Oct 27 '25 03:10

Calimo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!