roc {kyotil} | R Documentation |
ROC and AUC
Description
ROC/AUC methods.
fastauc
calculates the AUC using a sort operation, instead of summing over pairwise differences in R.
computeRoc
computes an ROC curve.
plotRoc
plots an ROC curve.
addRoc
adds an ROC curve to a plot.
classification.error
computes classification error
Usage
fastauc (score, outcome, t0 = 0, t1 = 1, reverse.sign.if.nece = TRUE, quiet = FALSE)
computeRoc (score, outcome, reverse.sign.if.nece = TRUE, cutpoints
= NULL)
plotRoc(x, add = FALSE, type = "l", diag.line=TRUE,...)
addRoc (x,...)
classification.error(score, outcome, threshold=NULL, verbose=FALSE)
Arguments
score |
a vector. Linear combination or score. |
outcome |
a vector of 0 and 1. Outcome. |
t0 |
a number between 0 and 1 that is the lower boundary of pAUC |
t1 |
a number between 0 and 1 that is the upper boundary of pAUC |
reverse.sign.if.nece |
a boolean. If TRUE, score is multiplied by -1 if AUC is less than 0.5. |
x |
a list of two elements: sensitivity and specificity. |
diag.line |
boolean. If TRUE, a diagonal line is plotted |
add |
boolean. If TRUE, add to existing plot. If FALSE, create a new plot. |
quiet |
boolean |
cutpoints |
cutpoints |
threshold |
threshold |
verbose |
boolean |
type |
line type for |
... |
arguments passed to |
Details
These functions originally come from Thomas Lumley and Tianxi Cai et al.
Value
computeRoc
returns a list of sensitivity and specificity.
plotRoc
and addRoc
plots ROC curves.
Author(s)
Shuxin Yin
Youyi Fong youyifong@gmail.com
Krisztian Sebestyen
Examples
n=1e2
score=c(rnorm(n/2,1), rnorm(n/2,0))
outcome=rep(1:0, each=n/2)
# cannot print due to r cmd check
#plotRoc(computeRoc(score, outcome))
# commented out b/c slower on pc and cause note when r cmd check
## test, fastauc2 is a version without all the checking
#score=rnorm(1e5)
#outcome=rbinom(1e5,1,.5)
#system.time(for (i in 1:1e2) fastauc(score,outcome)) # 4.9 sec
#system.time(for (i in 1:1e2) fastauc2(score,outcome)) # 3.8 sec