Learn R Programming

pROC (version 1.3.1)

ci.thresholds: Compute the confidence interval of thresholds

Description

This function computes the confidence interval (CI) of the sensitivity and specificity of the thresholds given in argument. By default, the 95% CI are computed with 2000 stratified bootstrap replicates.

Usage

ci.thresholds(...)
## S3 method for class 'roc':
ci.thresholds(roc, conf.level=0.95, boot.n=2000,
boot.stratified=TRUE, thresholds = "local maximas",
progress=getOption("pROCProgress")$name, ...) 
## S3 method for class 'formula':
ci.thresholds(formula, data, ...)
## S3 method for class 'smooth.roc':
ci.thresholds(smooth.roc, ...)
## S3 method for class 'default':
ci.thresholds(response, predictor, ...)

Arguments

roc
a roc object from the roc function.
smooth.roc
not available for smoothed ROC curves, available only to catch the error and provide a clear error message.
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.
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.
thresholds
on which thresholds to evaluate the CI. Either the numeric values of the thresholds, a logical vector (as index of roc$thresholds) or a character all, local maximas or best.
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 ci.thresholds.roc when calling ci.thresholds.default or ci.thresholds.formula.

Value

  • A list of length 2 and class ci.thresholds, with the confidence intervals of the CI and the following items:
  • specificitya matrix of CI for the specificity. Row (names) are the thresholds, the first column the lower bound, the 2nd column the median and the 3rd column the upper bound.
  • sensitivitysame than specificity.
  • Additionally, the list has the following attributes:
  • conf.levelthe width of the CI, in fraction.
  • boot.nthe number of bootstrap replicates.
  • boot.stratifiedwhether or not the bootstrapping was stratified.
  • thresholdsthe thresholds, as given in argument.
  • rocthe object of class roc that was used to compute the CI.

encoding

UTF-8

Warnings

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, 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.

Details

ci.thresholds.formula and ci.thresholds.default are convenience methods that build the ROC curve (with the roc function) before calling ci.thresholds.roc. You can pass them arguments for both roc and ci.thresholds.roc. Simply use ci.thresholds that will dispatch to the correct method.

This function creates boot.n bootstrap replicate of the ROC curve, and evaluates the sensitivity and specificity at thresholds given by the thresholds argument. Then it computes the confidence interval as the percentiles given by conf.level.

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.

References

Tom Fawcett (2006) ``An introduction to ROC analysis''. Pattern Recognition Letters 27, 861--874. DOI: 10.1016/j.patrec.2005.10.010.

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, ci

Examples

Run this code
data(aSAH)

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

# With a roc object:
rocobj <- roc(aSAH$outcome, aSAH$s100b)
ci.thresholds(rocobj)

# Customized bootstrap and specific thresholds:
ci.thresholds(aSAH$outcome, aSAH$s100b,
              boot.n=500, conf.level=0.9, stratified=FALSE,
              thresholds=c(0.5, 1, 2))

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

# Plotting the CI
plot(rocobj)
plot(rocobj$ci)

Run the code above in your browser using DataLab