This function computes the confidence interval (CI) of a ROC curve. The
of argument controls the type of CI that will be computed.
By default, the 95% CI are computed with 2000 stratified bootstrap
replicates.
Usage
ci(...)
## S3 method for class 'roc'
ci(roc, of = c("auc", "thresholds", "sp", "se", "coords"), ...)
## S3 method for class 'smooth.roc'
ci(smooth.roc, of = c("auc", "sp", "se", "coords"), ...)
## S3 method for class 'formula'
ci(formula, data, ...)
## Default S3 method:
ci(response, predictor, ...)
Arguments
roc, smooth.roc
a “roc” object from the
roc function, or a “smooth.roc” object from the
smooth function.
response, predictor
arguments for the roc function.
formula, data
a formula (and possibly a data object) of type
response~predictor for the roc function.
of
The type of confidence interval. One of “auc”,
“thresholds”, “sp”, “se” or “coords”. Note that
confidence interval on “thresholds” are not available for
smoothed ROC curves.
...
further arguments passed to or from other methods,
especially auc, roc, and the specific
ci functions ci.auc, ci.se,
ci.sp and ci.thresholds.
Details
ci.formula and ci.default are convenience methods
that build the ROC curve (with the roc function) before
calling ci.roc. You can pass them arguments for both
roc and ci.roc. Simply use ci
that will dispatch to the correct method.
This function is typically called from roc when ci=TRUE (not by
default). Depending on the of argument, the specific
ci functions ci.auc, ci.thresholds,
ci.sp, ci.se or ci.coords are called.
When the ROC curve has an auc of 1 (or 100%), the confidence interval will always be null
(there is no interval). This is true for both “delong” and “bootstrap” methods that can
not properly assess the variance in this case. This result is misleading, as the variance is of course not null.
A warning will be displayed to inform of this condition, and of the misleading output.
Value
The return value of the specific ci functions
ci.auc, ci.thresholds, ci.sp, ci.se or ci.coords, depending on the
of argument.
References
Xavier Robin, Natacha Turck, Alexandre Hainard, et al.
(2011) “pROC: an open-source package for R and S+ to analyze and
compare ROC curves”. BMC Bioinformatics, 7, 77.
DOI: 10.1186/1471-2105-12-77.
data(aSAH)
# Syntax (response, predictor):
ci(aSAH$outcome, aSAH$s100b)
# With a roc object:
rocobj <- roc(aSAH$outcome, aSAH$s100b)
# Of an AUC
ci(rocobj)
ci(rocobj, of="auc")
# this is strictly equivalent to:
ci.auc(rocobj)
# Of thresholds, sp, se...
## Not run:
ci(rocobj, of="thresholds")
ci(rocobj, of="thresholds", thresholds=0.51)
ci(rocobj, of="thresholds", thresholds="all")
ci(rocobj, of="sp", sensitivities=c(.95, .9, .85))
ci(rocobj, of="se")
## End(Not run)
# Alternatively, you can get the CI directly from roc():
rocobj <- roc(aSAH$outcome, aSAH$s100b, ci=TRUE, of="auc")
rocobj$ci