# [R] optimal cut off with Epi package

Frank Harrell f.harrell at vanderbilt.edu
Thu Jul 26 15:37:57 CEST 2012

```It is not appropriate to seek a cutoff for a test unless every patient is
known to have exactly the same utility function, which is extremely rare.
There is nothing wrong with developing probability models and stopping at
that point, deferring the decision to the possessor of the utility function.
Frank

Luigi wrote
>
> Dear all,
>
> I would like to calculate the optimal cut off (threshold) of a test using
> the Epi package. Here I am presenting some data based on the output of two
> tests. I am interested in identifying the optimal cut off an its 95% CI.
>
> Running the ROC() function with the Epi package I obtain a nice picture
> that
> returns what I interpret as the optimal cut off with lr.eta=0.431. would
> be
> this the optimal cut off? Otherwise I can I calculate it? And its
> confidence
> interval?
>
> Thank you,
>
> Luigi Marongiu, MSc
>
>
>
> ####################################
>
> test1<-c(  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)
>
>
>
> test2<-c(  0.65662706,     0.009706075,    0.003134876,    0.049831384,
> 1.089876198,    0.136582023,    0.165812622,    1.316512535,
> 0.725196908,
> 6.214688703,    48.26356415,    0.004775112,    0.035568226,
> 0.36934994,
> 0.452627677,    1.001904226,    0.116876181,    0.127614619,
> 1.345812733,
> 1.487365838,    4.321874201,    0.373389928,    0.002137676,
> 0.019958462,
> 43.51470584,    10.07600936,    8.668998078,    11.2505088,
> 45.53510205,
> 49.80855616,    1.375550815,    9.798996492,    9.494694175,
> 23.24171357,
> 0.779040988,    664.0886249,    15.05400384,    2.365265177,
> 0.076619211,
> 0.692909116,    8.497272898,    15.57700003,    20.83909961,
> 0.833613282,
> 2.84624862,     0.46118499,     7.330049094,    1.612815795,
> 3.695709614,
> 17.75107595)
>
>
>
> ### create data frame from matrix
>
>      my.mat<-matrix(c(test1, test2), nrow=50, byrow=FALSE)
>
>      dimnames(my.mat)<-list(c(1:50),c("class", "test"))
>
>      my.data<-as.data.frame(my.mat)
>
>      attach(my.data)
>
>
>
>
>      library(Epi)
>
>
>
> ### ROC analysis
>
>            ROC(form=my.data\$class ~ my.data\$test, plot="ROC",
> data=my.data,
>
> main="ROC with Epi package", MI=TRUE, MX=TRUE, PV=TRUE)
>
>
>
> ### REPORT: lr.eta=0.491
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/optimal-cut-off-with-Epi-package-tp4637904p4637932.html
Sent from the R help mailing list archive at Nabble.com.

```