I was comparing the performance of pROC and AUC libraries when performing auc() calculations on random data:
library("pROC");
library("AUC")
predictor <- rnorm(10000, 5);
outcome <- rnorm(10000) > 0;
print ("pROC:::auc() time & output")
system.time(x <- pROC:::auc(outcome, predictor))
print(x);
print ("AUC:::auc() time & output")
system.time(x <- AUC:::auc(AUC:::roc(predictor, factor(outcome))))
print(x);
AUC:::auc seemed to perform substantially faster, but what I found strange is that the compute different auc values for the same dataset:
> system.time(x <- pROC:::auc(outcome, predictor))
user system elapsed
1.00 0.01 1.31
> print(x);
Area under the curve: 0.5058
> print ("AUC:::auc() time & output")
[1] "AUC:::auc() time & output"
> system.time(x <- AUC:::auc(AUC:::roc(predictor, factor(outcome))))
user system elapsed
0.19 0.00 0.18
> print(x);
[1] 0.4942452
I thought the Auc() function was deterministic so they should produce the same number.
Yet pROC produces 0.5058 and AUC produces 0.4942452 .
Am I misusing either function?
EDIT: FYI I tried making the number semi random and the functions now give identical results (bar rounding errors):
predictor <- runif(10000);
outcome <- as.integer((predictor + runif(10000)) > 0.5);