swh:1:snp:ff0951ca787d0b7f47dc2335f47fed43820a6324
Tip revision: bf037739ff363e82379211828779a42a6e077559 authored by Venkatraman E. Seshan on 18 May 2015, 00:00:00 UTC
version 1.0.10
version 1.0.10
Tip revision: bf03773
roc.curve.R
roc.curve <- function(marker, status, method=c("empirical")) {
if (any(!is.finite(marker))) stop("Marker values should be finite")
if (any(!is.finite(status))) stop("All status should be finite")
method <- match.arg(method)
ii <- order(marker)
nu <- length(unique(marker)) + 1
n <- length(marker)
n1 <- sum(status)
n0 <- n - n1
if (min(n0,n1) == 0) stop("Status vector should have least one each of 0 & 1")
zzz <- .Fortran("roccurve",
as.integer(n),
as.integer(n0),
as.integer(n1),
as.double(marker[ii]),
as.integer(status[ii]),
as.integer(nu),
tpr=double(nu),
fpr=double(nu))
out <- NULL
out$marker <- marker
out$status <- status
out$tpr <- zzz$tpr
out$fpr <- zzz$fpr
class(out) <- "roc.curve"
out
}
print.roc.curve <- function(x, ...) {
out <- roc.area.test(x$marker, x$status)
cat(" ROC curve with AUC =", out$area, "and s.e. =", sqrt(out$var), "\n")
}
plot.roc.curve <- function(x, ...) {
plot(x$fpr, x$tpr, xlab="False positive rate", ylab="True positive rate", type="l", ...)
}
lines.roc.curve <- function(x, ...) {
lines(x$fpr, x$tpr, ...)
}