0

I use the function auc in the R package pROC to calculate the auc value in a simulation study. test.y is the observed response, y_pred_mle is the predicted response.

> test.y
   test.y
1      -1
2      -1
3      -1
4      -1
5      -1
6      -1
7       1
8       1
9       1
10      1
11      1
12      1

> y_pred_mle
        [,1]
76 -166.7094
53 -203.4014
52 -220.0880
51 -189.4703
95 -222.5294
72 -207.0304
24  722.8809
44  727.5353
12  770.5053
42  783.7437
27  733.3144
3   773.2688


> out_auc_mle<- auc( test.y, y_pred_mle  )
> out_auc_mle
[1] Inf

I wonder how can this generate Inf value? In my understanding on auc, the range of auc should be 0 to 1. I am not asking an coding question. I just wonder how the auc value can be Inf. Can anybody explain me about is it possible that the auc is Inf? Then how to interpret it?

user93892
  • 305
  • 6
  • 12

1 Answers1

2

The AUC should be 1 for this data because all 1 examples are ranked higher than all -1 examples. This is because AUC corresponds exactly to the probability that a randomly-selected positive is ranked more highly than a randomly-selected negative. Matthew Drury has a nice write-up here. There must be either an error in usage or a bug, probably the former.

A useful CV thread on AUC, what it is, and how to interpret it is here.

Sycorax
  • 76,417
  • 20
  • 189
  • 313
  • Thank you for your answer. Your answer inspires me to solve this problem. But I still wonder about what you said **The AUC should be 1 for this data because all 1 examples are ranked higher than all -1 examples (note the signs)** , why **if all 1 examples are ranked higher than all -1 examples**, we can directly said "AUC" =1? Could you give me some explanation? Many thanks. – user93892 Aug 17 '17 at 07:50
  • 1
    I've added more detail. – Sycorax Aug 18 '17 at 04:46
  • 2
    I worte a less technical proof of the AUC equivelence here: http://madrury.github.io/jekyll/update/statistics/2017/06/21/auc-proof.html – Matthew Drury Aug 18 '17 at 05:03