Go back to basics. The AUROC is mainly a good measure because of a coincidence: it equals the concordance probability ($c$-index; $U$-statistic) commonly used in rank correlation measures and the Wilcoxon-Mann-Whitney statistic. Concordance is an excellent measure of separation or predictive discrimination. So calculate it efficiently:
require(Hmisc)
somers2(predicted, real)
C Dxy n Missing
0.9545455 0.9090909 20.0000000 0.0000000
The efficient calculation is essentially a one-liner in somers2
:
c.index <- (mean(rank(x)[y == 1]) - (n1 + 1)/2)/(n - n1)
But be clear on why you are using AUROC in the first place. It is a nice supplement to log-likelihood-based measures but not a substitute for the gold standard.