[R] assign optimal cut-off to variable using Epi/pROC packages

Luigi Marongiu marongiu.luigi at gmail.com
Tue Jul 28 00:45:26 CEST 2015


Dear all,
I am calculating the optimal cut-off for a test against a gold
standard measure. I can determine the cut-off (in the following
example 5.905) but I would like to assign it to an atomic variable so
that the cut-off is updated every time the data is changed. I am using
the ROC and roc functions of the packages Epi and pROC respectively.
Would you know how to extract the optimal cut-off from these functions
or a similar way to get such value?
Best regards
Luigi

>>>
query.test <- c(5.43,    6.63,    0,    6.2,    5.61,    0,    5.59,
 0,    0,    5.49,    18.35,    0,    6.07,    4.54,    4.73,    0,
5.74,    33.02,    4.45,    31.16,    0,    0,    3.12,    0,    0,
4.78,    0,    0,    0,    0,    0,    32.42
)
gold.std <- c(0,    1,    0,    1,    0,    0,    0,    0,    0,    0,
   1,    0,    1,    0,    0,    0,    0,    1,    0,    1,    0,
0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    1
)
df <- data.frame(cbind(query.test, gold.std))

library(Epi)
library(pROC)
# Epi
ROC(form=gold.std ~ query.test, plot="ROC", data=df, MI=FALSE,
MX=FALSE, PV=TRUE)
# pROC
roc(gold.std ~ query.test, df, smooth=FALSE, plot=TRUE,
auc.polygon=TRUE, max.auc.polygon=TRUE, grid=TRUE, print.auc=TRUE,
print.thres="best")



More information about the R-help mailing list