swh:1:snp:ff0951ca787d0b7f47dc2335f47fed43820a6324
Tip revision: fee23d9a9b7e105c4c1d61a01015be0575030e43 authored by Venkatraman E. Seshan on 22 February 2022, 23:50:02 UTC
version 1.1.0
version 1.1.0
Tip revision: fee23d9
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, ...)
}