Learn R Programming

pROC (version 1.3.1)

ci.auc: Compute the confidence interval of the AUC

Description

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.

Usage

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, ...)
## 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, ...)
## S3 method for class 'auc':
ci.auc(auc, ...)
## S3 method for class 'formula':
ci.auc(formula, data, ...)
## S3 method for class 'default':
ci.auc(response, predictor, ...)

Arguments

roc, smooth.roc
a roc object from the roc function, or a smooth.roc object from the smooth.roc function.
auc
an auc object from the auc 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.
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 TRUE (default) and the roc object contains an auc field, re-use these specifications for the test. If false, use optional ... arguments to auc
progress
the name of progress bar to display. Typically none, win, tk or text (see the name argument to create_progress_b
...
further arguments passed to or from other methods, especially arguments for roc and roc.test.roc when calling roc.test.default or roc.test.formula. Arguments f

Value

  • A numeric vector of length 3 and class ci.auc, with the lower bound, the median and the upper bound of the CI, and the following attributes:
  • conf.levelthe width of the CI, in fraction.
  • methodthe method employed.
  • boot.nthe number of bootstrap replicates.
  • boot.stratifiedwhether or not the bootstrapping was stratified.
  • aucan 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.

encoding

UTF-8

AUC specification

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:
  1. theaucfield in therocobject ifreuse.aucis set toTRUE(default). It is naturally inherited from any call torocand fits most cases.
  2. passing the specification toaucwith...(argumentspartial.auc,partial.auc.correctandpartial.auc.focus). In this case, you must ensure either that therocobject do not contain anaucfield (if you calledrocwithauc=FALSE), or setreuse.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.

Warnings

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.

Errors

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.

Details

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.

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 in pROC (with smoothed ROCs, method is ignored, otherwise for pAUC a warning is produced and bootstrap is employed instead).

With method="bootstrap", the function calls auc boot.n times, according to the method described by Carpenter and Bithell (2000). boot.n bootstrap replicates are drawn. Stratification of bootstrap can be controlled with boot.stratified. In stratified bootstrap, each replicate contains the same number of cases and controls than the original sample. Stratification is especially useful if one group has only little observations, or if groups are not balanced. Higher numbers of boot.n will give a more precise estimate of the CI, but take more time to compute. 2000 is recommanded by Carpenter and Bithell.

For smoothed ROC curves, smoothing is performed again at each bootstrap replicate with the parameters originally provided. If a density smoothing was performed with user-provided 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) and the CI is deduced with qnorm.

References

Elisabeth R. DeLong, David M. DeLong and Daniel L. Clarke-Pearson (1988) ``Comparing the areas under two or more correlated receiver operating characteristic curves: a nonparametric approach''. Biometrics 44, 837--845.

James Carpenter and John Bithell (2000) ``Bootstrap condence intervals: when, which, what? A practical guide for medical statisticians''. Statistics in Medicine 19, 1141--1164.

See Also

roc, auc, ci

Examples

Run this code
data(aSAH)

# Syntax (response, predictor):
ci.auc(aSAH$outcome, aSAH$s100b)

# With a roc object:
rocobj <- roc(aSAH$outcome, aSAH$s100b)
# default values
ci.auc(rocobj)
ci(rocobj)
ci(auc(rocobj))
ci(rocobj$auc)
ci(rocobj$auc, method="delong")

# Partial AUC and customized bootstrap:
ci.auc(aSAH$outcome, aSAH$s100b,
       boot.n=100, conf.level=0.9, stratified=FALSE, partial.auc=c(1, .8),
       partial.auc.focus="se", partial.auc.correct=TRUE)

# Note that the following will NOT give a CI of the partial AUC:
ci.auc(rocobj, boot.n=500, conf.level=0.9, stratified=FALSE,
       partial.auc=c(1, .8), partial.auc.focus="se", partial.auc.correct=TRUE)
# This is because rocobj$auc is not a partial AUC.
# You can overcome this problem with reuse.auc:
ci.auc(rocobj, boot.n=500, conf.level=0.9, stratified=FALSE,
       partial.auc=c(1, .8), partial.auc.focus="se", partial.auc.correct=TRUE,
       reuse.auc=FALSE)

# Alternatively, you can get the CI directly from roc():
rocobj <- roc(aSAH$outcome, aSAH$s100b, ci=TRUE, of="auc")
rocobj$ci

# On a smoothed ROC, the CI is re-computed automatically
smooth(rocobj)
# Or you can compute a new one:
ci.auc(smooth(rocobj, method="density", reuse.ci=FALSE), boot.n=100)

Run the code above in your browser using DataLab