ROC curve discrete predictors not working as expected (R) I am doing an ROC analysis for the first time. I taught myself the basics by reading a few articles and tutorials online, but I am in a bit over my head.
I am using the pROC package in R to run the analysis. My question involves using a discrete predictor (ranging from 1-20) to try and identify a threshold for a binary outcome. I want to keep the predictor discrete rather than computing probabilities because I ultimately want to give a concrete recommendation to a group of practitioners. 
When I run the commands to identify the best thresholds, all of the thresholds produced are decimals. So, for example, instead of identifying the best threshold as 7 or 8, the best threshold is computed as 7.5. This also happens when I look at the sensitivities and specificities for all thresholds (i.e., thresholds show up as 0.5, 1.5, 2.5, etc. instead of as 0, 1, 2, etc).
Does anyone know why this might be happening or if there is anything I can do to adjust it?
Thank you!
 A: The threshold must be a mid-point between data, if it was 7, like you proposed, what would be the assignment for a datum whose discrete predictor was also 7? It would not be possible to determine it.
As your data are coded as integers, you get half-integers only as thresholds as a compromise. Any other non-integer would be a valid threshold however.


Thanks! Can you explain a bit more in layman's terms?

@szq It's already in quite simplified terms, really. But think this way: you have these data c(1,1,1,1,2,2,2). 


*

*If we establish a threshold t = 0, so that everything >t is labelled A and everything <t is labelled B, our classification would look like c(A,A,A,A,A,A,A). 

*What if we set t=1.5? Then the resulting vector is c(B,B,B,B,A,A,A)

*And now, what happens in t=1? c(NA,NA,NA,NA,A,A,A). Analogously for t=2, we get c(B,B,B,B,NA,NA,NA)
The point is a valid threshold must be able to separate the data. If it coincides with any single datum that datum's classification is indeterminate, as its predictor is neither lower or higher than the threshold.
A: Let's say you have one observation with value exactly 7. We can write $x = 7$.
Now want to analyze your data at a threshold 7, or $t = 7$. In order to perform ROC analysis, you need to determine if your observation x positive or a negative?
It will depend on how you define positivity. If you say that an observation is positive if $x > t$, then $x$ is negative because $7 \ngtr 7$.
If you instead define that an observation is positive if $x \ge t$, then your same observation $x$ is positive, because  $7 \ge 7$.
As you can see, it might be hard to tell if a given value is positive or negative at a given threshold. Most statistical definitions use the $x \ge t$ definition, but it is impossible to tell for sure which one a tool is using without looking into the documentation (if it is documented at all).
The approach taken by pROC to avoid this dilemma is to show unambiguous mid-points between the observed data points. If the threshold $t = 6.5$ then the observation $x = 7$ is obviously positive with both definitions. Similarly, it will be negative for $t = 7.5$.
