pROC (version 1.3.1)

auc: Compute the area under the ROC curve

Description

This function computes the numeric value of area under the ROC curve (AUC). Two syntaxes are possible: one object of class roc, or either two vectors (response, predictor) or a formula (response~predictor) as in the roc function. By default, the total AUC is computed, but a portion of the ROC curve can be specified with partial.auc.

Usage

auc(...)
## S3 method for class 'roc':
auc(roc, partial.auc=FALSE, partial.auc.focus=c("specificity",
"sensitivity"), partial.auc.correct=FALSE, ...)
## S3 method for class 'smooth.roc':
auc(smooth.roc, ...)
## S3 method for class 'formula':
auc(formula, data, ...)
## S3 method for class 'default':
auc(response, predictor, ...)

Arguments

roc, smooth.roc
a roc object from the roc function, or a smooth.roc object from the smooth.roc 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.
partial.auc
either FALSE (default: consider total area) or a numeric vector of length 2: boundaries of the AUC to consider in [0,1] (or [0,100] if percent is TRUE).
partial.auc.focus
if partial.auc is not FALSE and a partial AUC is computed, specifies if partial.auc specifies the bounds in terms of specificity (default) or sensitivity. Can be shortened to spec/sens or even sp/se. Igno
partial.auc.correct
logical indicating if the correction of AUC must be applied in order to have a maximal AUC of 1.0 and a non-discriminant AUC of 0.5 whatever the partial.auc defined. Ignored if partial.auc=FALSE. Default: FALSE<
...
further arguments passed to or from other methods, especially arguments for roc when calling auc.default or auc.formula. Note that the auc argument of

Value

  • The numeric AUC value, of class auc, in fraction of the area in percent if percent=TRUE, with the following attributes:
  • partial.aucif the AUC is full (FALSE) or partial (and in this case the bounds), as defined in argument.
  • partial.auc.focusonly for a partial AUC, if the bound specifies the sensitivity or specificity, as defined in argument.
  • partial.auc.correctonly for a partial AUC, was it corrected? As defined in argument.
  • percentwhether the AUC is given in percent or fraction.
  • rocthe original ROC curve, as a roc object.

encoding

UTF-8

Details

This function is typically called from roc when auc=TRUE (default). It is also used by ci. When it is called with two vectors (response, predictor) or a formula (response~predictor) arguments, the roc function is called and only the AUC is returned.

By default, the total area under the curve is computed, but you can specify a partial AUC with the partial.auc argument. It specifies the bounds of specificity or sensitivity (depending on partial.auc.focus) between which the AUC will be computed. As it specifies specificities or sensitivities, you must adapt it accordingly to the 'percent' specification (see details in roc). partial.auc.focus is ignored if partial.auc=FALSE (default). If a partial AUC is computed, partial.auc.focus specifies if the bounds specified in partial.auc must be interpreted as sensitivity or specificity. Any other value will produce an error. partial.auc.correct is ignored if partial.auc=FALSE (default). If TRUE, the correction by McClish will be applied: $$\frac{1+\frac{auc-min}{max-min}}{2}$$ where min is the value of the non-discriminant AUC in the region and max is the maximum possible AUC in the region. With this correction, the AUC will be 0.5 if non discriminant and 1.0 if maximal, whatever the region defined. Fully compatible with percent.

There is no difference in the computation of the area under a smoothed ROC curve.

References

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

Donna Katzman McClish (1989) ``Analyzing a Portion of the ROC Curve''. Medical Decision Making 9(3), 190--195. DOI: 10.1177/0272989X8900900307

See Also

roc, ci.auc

Examples

Run this code
data(aSAH)

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

# With a roc object:
rocobj <- roc(aSAH$outcome, aSAH$s100b)
# Full AUC:
auc(rocobj)
# Partial AUC:
auc(rocobj, partial.auc=c(1, .8), partial.auc.focus="se", partial.auc.correct=TRUE)

# Alternatively, you can get the AUC directly from roc():
roc(aSAH$outcome, aSAH$s100b)$auc
roc(aSAH$outcome, aSAH$s100b,
    partial.auc=c(1, .8), partial.auc.focus="se",
    partial.auc.correct=TRUE)$auc

Run the code above in your browser using DataLab