coords(...)
## S3 method for class 'roc':
coords(roc, x, input=c("threshold", "specificity",
"sensitivity"), ret=c("threshold", "specificity", "sensitivity"),
as.list=FALSE, ...)
## S3 method for class 'smooth.roc':
coords(smooth.roc, x, input=c("specificity",
"sensitivity"), ret=c("specificity", "sensitivity"), as.list=FALSE, ...)
roc
function, or a smooth.roc
function.input
argument) or one of x
is numeric, the kind of input coordinate (x). One of
FALSE
(default), a named numeric vector is returned.x
and as.list
argument.
as.list=TRUE
a list of the length of, in the order of, and named after, ret
. a list of the length of, and named after, x
. Each element of this list is a list of the length of, in the order of, and named after, ret
.
as.list=FALSE
a numeric vector of the length of, in the order of, and named after, ret
. a numeric matrix with one row for each ret
and one column for each x
}
In all cases if input="specificity"
or input="sensitivity"
and interpolation was required, threshold is returned as NA
.
Note that if giving a character as x
(as.list=FALSE
) or either a list
of numeric or a list of lists (if as.list=TRUE
). Even
x
and input
arguments. If input="threshold"
, the coordinates for the threshold
are reported, even if the exact threshold do not define the ROC
curve. The following convenience characters are allowed: x
is a character, the
coordinates are limited to the thresholds within the partial AUC if it
has been defined, and not necessarily to the whole curve.
For input="specificity"
and input="sensitivity"
,
the function checks if the specificity or sensitivity is one of the
points of the ROC curve (in roc$sensitivities
or
roc$specificities
). More than one point may match (in
step curves), then only the upper-left-most point coordinates
are returned. Otherwise,
the specificity and specificity of the point is interpolated and
NA
is returned as threshold.
The coords function in this package is a generic, but it might be
superseded by functions in other packages such as
coords.roc
or
coords.smooth.roc
functions directly.
roc
data(aSAH)
# Print a roc object:
rocobj <- roc(aSAH$outcome, aSAH$s100b)
coords(rocobj, 0.55)
coords(rocobj, 0.9, "specificity", as.list=TRUE)
coords(rocobj, 0.5, "se", ret="se")
# fully qualified but identical:
coords(roc=rocobj, x=0.5, input="sensitivity", ret="sensitivity")
# Same in percent
rocobj <- roc(aSAH$outcome, aSAH$s100b,
percent=TRUE)
coords(rocobj, 0.55)
coords(rocobj, 90, "specificity", as.list=TRUE)
coords(rocobj, x=50, input="sensitivity", ret=c("sen", "spec"))
# Get the sensitivities for all thresholds
sensitivities <- coords(rocobj, rocobj$thresholds, "thr", "se")
# This is equivalent to taking sensitivities from rocobj directly
stopifnot(all.equal(as.vector(rocobj$sensitivities), as.vector(sensitivities)))
# You could also write:
sensitivities <- coords(rocobj, "all", ret="se")
stopifnot(all.equal(as.vector(rocobj$sensitivities), as.vector(sensitivities)))
# Get the best threshold
coords(rocobj, "b", ret="t")
Run the code above in your browser using DataLab