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))
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With