ci.auc  R Documentation 
This function computes the confidence interval (CI) of an area under the curve (AUC). By default, the 95% CI is computed with 2000 stratified bootstrap replicates.
# ci.auc(...)
## S3 method for class 'roc'
ci.auc(roc, conf.level=0.95, method=c("delong",
"bootstrap"), boot.n = 2000, boot.stratified = TRUE, reuse.auc=TRUE,
progress = getOption("pROCProgress")$name, parallel=FALSE, ...)
## S3 method for class 'smooth.roc'
ci.auc(smooth.roc, conf.level=0.95, boot.n=2000,
boot.stratified=TRUE, reuse.auc=TRUE,
progress=getOption("pROCProgress")$name, parallel=FALSE, ...)
## S3 method for class 'auc'
ci.auc(auc, ...)
## S3 method for class 'multiclass.roc'
ci.auc(multiclass.roc, ...)
## S3 method for class 'multiclass.auc'
ci.auc(multiclass.auc, ...)
## S3 method for class 'auc'
ci.auc(auc, ...)
## S3 method for class 'formula'
ci.auc(formula, data, ...)
## Default S3 method:
ci.auc(response, predictor, ...)
roc, smooth.roc 
a “roc” object from the

auc 
an “auc” object from the 
multiclass.roc, multiclass.auc 
not implemented. 
response, predictor 
arguments for the 
formula, data 
a formula (and possibly a data object) of type
response~predictor for the 
conf.level 
the width of the confidence interval as [0,1], never in percent. Default: 0.95, resulting in a 95% CI. 
method 
the method to use, either “delong” or “bootstrap”. The first letter is sufficient. If omitted, the appropriate method is selected as explained in details. 
boot.n 
the number of bootstrap replicates. Default: 2000. 
boot.stratified 
should the bootstrap be stratified (default, same number of cases/controls in each replicate than in the original sample) or not. 
reuse.auc 
if 
progress 
the name of progress bar to display. Typically
“none”, “win”, “tk” or “text” (see the

parallel 
if TRUE, the bootstrap is processed in parallel, using parallel backend provided by plyr (foreach). 
... 
further arguments passed to or from other methods,
especially arguments for 
This function computes the CI of an AUC. Two methods are available:
“delong” and “bootstrap” with the parameters defined in “roc$auc” to
compute a CI. When it is called with two vectors (response, predictor)
or a formula (response~predictor) arguments, the roc
function is called to build the ROC curve first.
The default is to use
“delong” method except for comparison of partial AUC and smoothed
curves, where bootstrap
is used. Using “delong” for
partial AUC and smoothed ROCs is not supported.
With method="bootstrap"
, the function calls auc
boot.n
times. For more details about the bootstrap, see the Bootstrap section in
this package's documentation.
For smoothed ROC curves, smoothing is performed again at each
bootstrap replicate with the parameters originally provided.
If a density smoothing was performed with userprovided
density.cases
or density.controls
the bootstrap cannot
be performed and an error is issued.
With method="delong"
, the variance of the AUC is computed as
defined by DeLong et al. (1988) using the algorithm by Sun and Xu (2014)
and the CI is deduced with qnorm
.
CI of multiclass ROC curves and AUC is not implemented yet. Attempting to call these methods returns an error.
A numeric vector of length 3 and class “ci.auc”, “ci” and “numeric” (in this order), with the lower bound, the median and the upper bound of the CI, and the following attributes:
conf.level 
the width of the CI, in fraction. 
method 
the method employed. 
boot.n 
the number of bootstrap replicates. 
boot.stratified 
whether or not the bootstrapping was stratified. 
auc 
an object of class “auc” stored for reference about the compued AUC details (partial, percent, ...) 
The aucs
item is not included in this list since version 1.2 for
consistency reasons.
The comparison of the CI needs a specification of the AUC. This allows to compute the CI for full or partial AUCs. The specification is defined by:
the “auc” field in the “roc” object if
reuse.auc
is set to TRUE
(default). It is naturally
inherited from any call to roc
and fits most cases.
passing the specification to auc
with ...
(arguments partial.auc
, partial.auc.correct
and
partial.auc.focus
). In this case, you must ensure either that
the roc
object do not contain an auc
field (if
you called roc
with auc=FALSE
), or set
reuse.auc=FALSE
.
If reuse.auc=FALSE
the auc
function will always
be called with ...
to determine the specification, even if
the “roc” object do contain an auc
field.
As well if the “roc” object do not contain an auc
field, the auc
function will always be called with
...
to determine the specification.
Warning: if the roc object passed to ci contains an auc
field and reuse.auc=TRUE
, auc is not called and
arguments such as partial.auc
are silently ignored.
If method="delong"
and the AUC specification specifies a
partial AUC, the warning “Using DeLong's test for partial AUC is
not supported. Using bootstrap test instead.” is issued. The
method
argument is ignored and “bootstrap” is used
instead.
If boot.stratified=FALSE
and the sample has a large imbalance between
cases and controls, it could happen that one or more of the replicates
contains no case or control observation, or that there are not enough
points for smoothing, producing a NA
area.
The warning “NA value(s) produced during bootstrap were ignored.”
will be issued and the observation will be ignored. If you have a large
imbalance in your sample, it could be safer to keep
boot.stratified=TRUE
.
If density.cases
and density.controls
were provided
for smoothing, the error “Cannot compute the statistic on ROC
curves smoothed with density.controls and density.cases.” is issued.
James Carpenter and John Bithell (2000) “Bootstrap condence intervals: when, which, what? A practical guide for medical statisticians”. Statistics in Medicine 19, 1141–1164. DOI: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/(SICI)10970258(20000515)19:9<1141::AIDSIM479>3.0.CO;2F")}.
Elisabeth R. DeLong, David M. DeLong and Daniel L. ClarkePearson (1988) “Comparing the areas under two or more correlated receiver operating characteristic curves: a nonparametric approach”. Biometrics 44, 837–845.
Xu Sun and Weichao Xu (2014) “Fast Implementation of DeLongs Algorithm for Comparing the Areas Under Correlated Receiver Operating Characteristic Curves”. IEEE Signal Processing Letters, 21, 1389–1393. DOI: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/LSP.2014.2337313")}.
Xavier Robin, Natacha Turck, Alexandre Hainard, et al. (2011) “pROC: an opensource package for R and S+ to analyze and compare ROC curves”. BMC Bioinformatics, 7, 77. DOI: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/147121051277")}.
Hadley Wickham (2011) “The SplitApplyCombine Strategy for Data Analysis”. Journal of Statistical Software, 40, 1–29. URL: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v040.i01")}.
roc
, auc
, ci
# Create a ROC curve:
data(aSAH)
roc1 < roc(aSAH$outcome, aSAH$s100b)
## Basic example ##
ci.auc(roc1)
# You can also write:
ci(roc1)
ci(auc(roc1))
## More options ##
# Partial AUC and customized bootstrap:
## Not run:
ci.auc(roc1,
conf.level=0.9,
partial.auc=c(1, .8), partial.auc.focus="se", partial.auc.correct=TRUE,
boot.n=10000, stratified=FALSE)
## End(Not run)
# Note that the following will NOT give a CI of the partial AUC:
## Not run:
ci.auc(roc1,
partial.auc=c(1, .8), partial.auc.focus="se", partial.auc.correct=FALSE)
## End(Not run)
# This is because rocobj$auc is not a partial AUC and reuse.auc = TRUE by default.
# You can overcome this problem by passing an AUC instead:
auc1 < auc(roc1, partial.auc=c(1, .8), partial.auc.focus="se",
partial.auc.correct=FALSE)
## Not run:
ci.auc(auc1)
## End(Not run)
## On smoothed ROC curves with bootstrap ##
## Not run:
ci.auc(smooth(roc1, method="density"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.