Title: | utilities for ROC, with microarray focus |
---|---|
Description: | Provide utilities for ROC, with microarray focus. |
Authors: | Vince Carey <[email protected]>, Henning Redestig for C++ language enhancements |
Maintainer: | Vince Carey <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.83.0 |
Built: | 2024-11-18 04:08:50 UTC |
Source: | https://github.com/bioc/ROC |
various functionals of ROC (Receiver Operating Characteristic) curves
AUC(rocobj) AUCi(rocobj) pAUC(rocobj,t0) pAUCi(rocobj,t0)
AUC(rocobj) AUCi(rocobj) pAUC(rocobj,t0) pAUCi(rocobj,t0)
rocobj |
element of class rocc |
t0 |
FPR point at which TPR is evaluated or limit in (0,1) to integrate to |
AUC, pAUC, AUCi and pAUCi compute the Area Under the Curve.
AUC and pAUC employ the trapezoidal rule. AUCi and pAUCi use integrate().
AUC and AUCi compute the area under the curve from 0 to 1 on the x-axis (i.e., the 1 - specificity axis).
pAUC and pAUCi compute the are under the curve from 0 to argument t0 on the x-axis (i.e., the 1 - specificity axis).
Elements of class rocc can be created by rocdemo.sca() or other constructors you might make using the code of rocdemo.sca() as a template.
Vince Carey ([email protected])
Rosner, B., 2000, Fundamentals of Biostatistics, 5th Ed., pp. 63–65
Duda, R. O., Hart, P. E., Stork, D. G., 2001 Pattern Classification, 2nd Ed., p. 49
rocdemo.sca
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) print(AUC(R1)) print(pAUC(R1,.3)) print(pAUCi(R1,.3)) print(ROC(R1,.3))
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) print(AUC(R1)) print(pAUC(R1,.3)) print(pAUCi(R1,.3)) print(ROC(R1,.3))
plot method for ROC curves
plots an ROC curve object, with additional parameters available:
should marker threshold values be plotted?
should plotted points be jittered?
increment to current plot?
plot points or lines?
if showing threshold values, set
character expansion in text
call to this value
if showing threshold values, add this quantity to y coordinate of curve to plot the threshold value (should be negative for printing below point)
if showing threshold values, use
this as the digits parameter to round
to display the
threshold
extra parameters passed to base
plot
, lines
or points
as needed
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot(R1, line=TRUE, show.thresh=TRUE, lwd=2, threshDig=2) R2 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot(R2, line=TRUE, add=TRUE, col="green", lwd=2 ) R3 <- rocdemo.sca( rbinom(40,1,.4), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) points(R3, col="red", pch=19)
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot(R1, line=TRUE, show.thresh=TRUE, lwd=2, threshDig=2) R2 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot(R2, line=TRUE, add=TRUE, col="green", lwd=2 ) R3 <- rocdemo.sca( rbinom(40,1,.4), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) points(R3, col="red", pch=19)
object representing ROC curve, typically created using rocdemo.sca
new('rocc',
sens = ...., # Object of class numeric
spec = ...., # Object of class numeric
rule = ...., # Object of class function
cuts = ...., # Object of class numeric
markerLabel = ...., # Object of class character
caseLabel = ...., # Object of class character
)
sens
:Object of class "numeric" sensitivity values
spec
:Object of class "numeric" specificity values
rule
:Object of class "function" rule to classify objects
cuts
:Object of class "numeric" thresholds defining curve
markerLabel
:Object of class "character" name of measured marker
caseLabel
:Object of class "character" name of condition
(rocc, missing): a plotting function with some additional parameters
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot( R1, show.thresh=TRUE )
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), dxrule.sca, caseLabel="new case", markerLabel="demo Marker" ) plot( R1, show.thresh=TRUE )
rocdemo.sca – demonstrate 'rocc' class construction using a scalar marker and simple functional rule
rocdemo.sca(truth, data, rule=NULL, cutpts=NA, markerLabel="unnamed marker", caseLabel="unnamed diagnosis", quiet=TRUE)
rocdemo.sca(truth, data, rule=NULL, cutpts=NA, markerLabel="unnamed marker", caseLabel="unnamed diagnosis", quiet=TRUE)
truth |
true classification of objects. Must take values 0 or 1. |
data |
quantitative markers used to classify |
rule |
rule: a function with arguments (x, thresh) returning 0
or 1. If no rule is provided or the standard rule |
cutpts |
values of thresholds; no NA allowed, or they will be recomputed using smallest gap between data points with distinct values |
markerLabel |
textual label describing marker |
caseLabel |
textual label describing classification |
quiet |
defaults to TRUE, suppressing message about discovery of NA in cutpts |
dxrule.sca
is function (x, thresh) ifelse(x > thresh, 1, 0)
The default value of argument cutpts is a point less than min(data), points separating the unique values of data and a point greater than max(data).
an object of S4 class rocc
Vince Carey ([email protected])
AUC
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), caseLabel="new case", markerLabel="demo Marker" ) plot(R1, line=TRUE, show.thresh=TRUE) truth <- c(0, 1, 0, 1, 1, 0, 1, 1) data <- c(2, 3, 4, 4, 5, 6, 7, 8) R2 <- rocdemo.sca(truth, data, dxrule.sca) plot(R2, line=TRUE, show.thresh=TRUE) R3 <- rocdemo.sca(truth, data, function(x, thresh) 1 - dxrule.sca(x, thresh)) if (AUC(R2) + AUC(R3) != 1) stop('Sum of AUCs should be 1.') # # more involved # set.seed(1234) x = runif(1000) w = runif(1000) z = rbinom(1000, 1, plogis(-2.7+6.2*x + .3*w)) m1 = glm(z~x, fam=binomial) demorule.glm.clo = function(model) function(w,thresh) ifelse(predict(model, newdata=list(x=w), type="response")>thresh, 1, 0) demorule.glm = demorule.glm.clo(m1) R4 = rocdemo.sca(z, x, demorule.glm ) plot(R4)
set.seed(123) R1 <- rocdemo.sca( rbinom(40,1,.3), rnorm(40), caseLabel="new case", markerLabel="demo Marker" ) plot(R1, line=TRUE, show.thresh=TRUE) truth <- c(0, 1, 0, 1, 1, 0, 1, 1) data <- c(2, 3, 4, 4, 5, 6, 7, 8) R2 <- rocdemo.sca(truth, data, dxrule.sca) plot(R2, line=TRUE, show.thresh=TRUE) R3 <- rocdemo.sca(truth, data, function(x, thresh) 1 - dxrule.sca(x, thresh)) if (AUC(R2) + AUC(R3) != 1) stop('Sum of AUCs should be 1.') # # more involved # set.seed(1234) x = runif(1000) w = runif(1000) z = rbinom(1000, 1, plogis(-2.7+6.2*x + .3*w)) m1 = glm(z~x, fam=binomial) demorule.glm.clo = function(model) function(w,thresh) ifelse(predict(model, newdata=list(x=w), type="response")>thresh, 1, 0) demorule.glm = demorule.glm.clo(m1) R4 = rocdemo.sca(z, x, demorule.glm ) plot(R4)
trapezoidal rule for AUC
trapezint(x, y, a, b)
trapezint(x, y, a, b)
x |
x - abscissae |
y |
y - ordinates |
a |
a - lower limit of integration |
b |
b - upper limit of integration |
uses approx
estimated AUC
x <- sort(runif(30)) y <- sin(x) print(trapezint(x,y,0,1))
x <- sort(runif(30)) y <- sin(x) print(trapezint(x,y,0,1))