Skip to contents

Performance of ROC curves

Usage

perf_ROC(response, predictor, how = "pROC", positive_label = NULL, ...)

Arguments

response

A vector containing the true class labels. Care that it is VERY important which class is the positive class because the predictions are ordered according to restriction

predictor

A vector containing the predictions.

how

Previously, I allowed "pROC" and "ROCR", but now I only allow "pROC" after it is way faster.

positive_label

Label of the positive class

...

Further arguments to perf_pROC()

Value

List of perf: Result of perf_pROC(), comes from pROC::coords() auc: Area under the ROC curve, comes from pROC::auc() positive_label: Label of the positive class auc_variance: Variance of the AUC under Nullhypothesis: $$\frac{n_{positives} + n_{negatives} + 1}{12\cdot n_{positives} \cdot n_{negatives}}$$ rzAUC: restricted standardized AUC, combines the calculated AUC with the variance.

Looks then e.g. like:
 $perf
 # A tibble: 110 × 5
       tp    fp   tpr   fpr threshold
    <dbl> <dbl> <dbl> <dbl>     <dbl>
  1    41    72 1     1       -Inf
  2    41    71 1     0.986      3.44
  3    40    71 0.976 0.986      4.24
  4    40    70 0.976 0.972      4.82
  5    40    69 0.976 0.958      5.11
  6    39    69 0.951 0.958      5.18
  7    38    69 0.927 0.958      5.28
  8    37    69 0.902 0.958      5.68
  9    37    68 0.902 0.944      6.00
 10    37    67 0.902 0.931      6.15
 # … with 100 more rows
 # ℹ Use `print(n = ...)` to see more rows

 $auc
 [1] 0.611958

 $positive_label
 [1] "Poor"

 $auc_variance
 [1] 0.003218157

 $rzAUC
 [1] 1.973565

Examples


data(aSAH, package = "pROC")
if (FALSE) { # \dontrun{
# ROCR is not implemented anymore
perf_ROC(
    response = aSAH$outcome,
    predictor = aSAH$ndka,
    how = "ROCR"
)
} # }
perf_ROC(
    response = aSAH$outcome,
    predictor = aSAH$ndka,
    how = "pROC"
)
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases
#> $perf
#> # A tibble: 110 × 5
#>       tp    fp   tpr   fpr threshold
#>    <dbl> <dbl> <dbl> <dbl>     <dbl>
#>  1    41    72 1     1       -Inf   
#>  2    41    71 1     0.986      3.44
#>  3    40    71 0.976 0.986      4.24
#>  4    40    70 0.976 0.972      4.82
#>  5    40    69 0.976 0.958      5.11
#>  6    39    69 0.951 0.958      5.18
#>  7    38    69 0.927 0.958      5.28
#>  8    37    69 0.902 0.958      5.68
#>  9    37    68 0.902 0.944      6.00
#> 10    37    67 0.902 0.931      6.15
#> # ℹ 100 more rows
#> 
#> $auc
#> [1] 0.611958
#> 
#> $positive_label
#> [1] "Poor"
#> 
#> $auc_variance
#> [1] 0.003218157
#> 
#> $rzAUC
#> [1] 1.973565
#> 
perf_ROC(
    response = aSAH$outcome,
    predictor = aSAH$ndka
)
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases
#> $perf
#> # A tibble: 110 × 5
#>       tp    fp   tpr   fpr threshold
#>    <dbl> <dbl> <dbl> <dbl>     <dbl>
#>  1    41    72 1     1       -Inf   
#>  2    41    71 1     0.986      3.44
#>  3    40    71 0.976 0.986      4.24
#>  4    40    70 0.976 0.972      4.82
#>  5    40    69 0.976 0.958      5.11
#>  6    39    69 0.951 0.958      5.18
#>  7    38    69 0.927 0.958      5.28
#>  8    37    69 0.902 0.958      5.68
#>  9    37    68 0.902 0.944      6.00
#> 10    37    67 0.902 0.931      6.15
#> # ℹ 100 more rows
#> 
#> $auc
#> [1] 0.611958
#> 
#> $positive_label
#> [1] "Poor"
#> 
#> $auc_variance
#> [1] 0.003218157
#> 
#> $rzAUC
#> [1] 1.973565
#> 
a <- perf_ROC(
    response = aSAH$outcome,
    predictor = aSAH$ndka
)
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases