简体   繁体   中英

Wrong(?) Thresholds in dataframe using R and PROC

I'm trying to calculate new cutoff values for a project, but it seems like a) I do not understand the threshholds at all or b) I'm doing something wrong while calculating

The Data I use

data_sub$ENTLASSMANAGEMENT_BIN: Binary variable, containing 0 and 1 data_sub$DOKU_INDEXWERT: The values that should decide if ENTLASSMANAGEMENT_BIN is 0 or 1. Numbers between 1 and 41

glm.fit=glm(data_sub$ENTLASSMANAGEMENT_BIN ~ data_sub$DOKU_INDEXWERT, family=binomial)
lines(data_sub$DOKU_INDEXWERT, glm.fit$fitted.values)

Drawing my ROC

par(pty = "s")
roc(data_sub$ENTLASSMANAGEMENT_BIN, glm.fit$fitted.values, 
    plot = TRUE, legacy.axes=TRUE, col="#377eb8", lwd=4, print.auc=TRUE)

This ROC looks fine for me so I thought I just have to get the thresholds and I will be able to choose a new cutoff value.

So I made a new dataframe containing the true positive percentage (tpp) and the false positive percentage (fpp) as well as the thresholds:

roc.info <- roc(data_sub$ENTLASSMANAGEMENT_BIN, glm.fit$fitted.values, legacy.axes=TRUE)
roc.df <- data.frame(tpp=roc.info$sensitivities*100,
                     fpp= (1- roc.info$specificities)*100,
                     threshholds=roc.info$thresholds)
head(roc.df)

But the thresholds seems odd to me:

> head(roc.df)
        tpp       fpp threshholds
1 100.00000 100.00000        -Inf
2  98.31461  72.64957   0.1178571
3  96.62921  58.11966   0.2178571
4  92.13483  41.02564   0.3095238
5  89.88764  34.18803   0.3750000
6  87.07865  28.20513   0.4940476

Shouldn't they be similar to the numbers from data_sub$DOKU_INDEXWERT? I don't understand how I can interpret these if they are above the highest number from my cut offs...

Did I make a mistake calculating? Or did I just misinterpret the threshold?

Thanks!

I guess I found my mistake: Anyway maybe this could be useful for other people. I used the glm.fit$fitted.values because else I would get the Error that my data should be numeric. I now used as.numeric(data_sub$DOKU_INDEXWERT) instead and it worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM