pROC icon indicating copy to clipboard operation
pROC copied to clipboard

Ordered treated as numbers

Open xrobin opened this issue 6 years ago • 3 comments

> text.levels <- aSAH$wfns
> head(text.levels)
[1] 1 1 1 1 3 2
Levels: 1 < 2 < 3 < 4 < 5
> levels(text.levels)
[1] "1" "2" "3" "4" "5"
> levels(text.levels) <- c("very low", "low", "medium", "high", "very high")
> head(text.levels)
[1] very low very low very low very low medium   low     
Levels: very low < low < medium < high < very high
> r <- roc(aSAH$outcome, text.levels)
> r$thresholds
[1] -Inf  1.5  2.5  3.5  4.5  Inf

Only makes sense if ordered values are actually 1, 2, ... n

Steps to reproduce:

text.levels <- aSAH$wfns
levels(text.levels) <- c("very low", "low", "medium", "high", "very high")
r <- roc(aSAH$outcome, text.levels)
r$thresholds

xrobin avatar Oct 06 '19 12:10 xrobin

Allowing textual thresholds seems to break a lot of assumptions. Initial work in separate ordered_fix branch breaks horribly many tests. Coordinates are converted to text (with transpose=TRUE). It might be better to just warn the user.

xrobin avatar Oct 06 '19 17:10 xrobin

Previous commit is a workaround to convert through a character vector if possible (keeping numeric values if the ordered values are numbers). There is now a warning in case of a conversion to integer values.

xrobin avatar Nov 29 '19 10:11 xrobin

The 1.16 release will have the previous workaround to use the correct numbers (if actually numbers) or warn the user.

Once we return a data.frame by default, and transpose becomes deprecated, it will be possible to return character thresholds in coords, and revisit this issue. Until then it will be on hold.

xrobin avatar Dec 08 '19 09:12 xrobin