This function computes the numeric value of area under the ROC curve
(AUC) with the trapezoidal rule. Two syntaxes are possible: one object of class “roc”, or either
two vectors (response, predictor) or a formula (response~predictor) as
By default, the total AUC is computed, but a portion of the ROC curve
can be specified with
1 2 3 4 5 6 7 8 9 10 11 12 13
auc(...) ## S3 method for class 'roc' auc(roc, partial.auc=FALSE, partial.auc.focus=c("specificity", "sensitivity"), partial.auc.correct=FALSE, allow.invalid.partial.auc.correct = FALSE, ...) ## S3 method for class 'smooth.roc' auc(smooth.roc, ...) ## S3 method for class 'multiclass.roc' auc(multiclass.roc, ...) ## S3 method for class 'formula' auc(formula, data, ...) ## Default S3 method: auc(response, predictor, ...)
a “roc” object from the
arguments for the
a formula (and possibly a data object) of type response~predictor for the
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
logical indicating if
the correction must return
further arguments passed to or from other methods,
especially arguments for
This function is typically called from
(default). It is also used by
ci. When it is called with
two vectors (response, predictor) or a formula (response~predictor)
roc function is called and only the AUC is
By default the total area under the curve is computed, but a partial AUC (pAUC)
specified with the
partial.auc argument. It specifies the bounds of
specificity or sensitivity (depending on
which the AUC will be computed. As it specifies specificities or
sensitivities, you must adapt it in relation to the 'percent'
specification (see details in
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. It is recommended to
plot the ROC curve with
auc.polygon=TRUE in order to
make sure the specification is correct.
If a pAUC is defined, it can be standardized (corrected). This correction is
controled by the
partial.auc.correct argument. If
the correction by McClish will be applied:
where auc is the uncorrected pAUC computed in the region defined by
min is the value of the non-discriminant AUC (with an AUC of 0.5 or 50
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. This correction is fully compatible with
Note that this correction is undefined for curves below the diagonal (auc < min). Attempting
to correct such an AUC will return
NA with a warning.
The numeric AUC value, of class
c("auc", "numeric") (or
c("multiclass.auc", "numeric") or
if a “multiclass.roc” was supplied), in
fraction of the area or in percent if
percent=TRUE, with the
if the AUC is full (FALSE) or partial (and in this case the bounds), as defined in argument.
only for a partial AUC, if the bound specifies the sensitivity or specificity, as defined in argument.
only for a partial AUC, was it corrected? As defined in argument.
whether the AUC is given in percent or fraction.
the original ROC curve, as a “roc”, “smooth.roc” or “multiclass.roc” object.
There is no difference in the computation of the area under a smoothed
ROC curve, except for curves smoothed with
method="binomial". In this case
and only if a full AUC is requested, the classical binormal AUC formula is applied:
If the ROC curve is smoothed with any other
method or if a partial AUC
is requested, the empirical AUC described in the previous section is applied.
With an object of class “multiclass.roc”, a multi-class AUC is computed as an average AUC as defined by Hand and Till (equation 7).
2/(count * (count - 1))*sum(aucs)
with aucs all the pairwise roc curves.
Tom Fawcett (2006) “An introduction to ROC analysis”. Pattern Recognition Letters 27, 861–874. DOI: doi: 10.1016/j.patrec.2005.10.010.
David J. Hand and Robert J. Till (2001). A Simple Generalisation of the Area Under the ROC Curve for Multiple Class Classification Problems. Machine Learning 45(2), p. 171–186. DOI: doi: 10.1023/A:1010920819831.
Donna Katzman McClish (1989) “Analyzing a Portion of the ROC Curve”. Medical Decision Making 9(3), 190–195. DOI: doi: 10.1177/0272989X8900900307.
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: doi: 10.1186/1471-2105-12-77.
1 2 3 4 5 6 7 8 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.