roc function.
By default, the total AUC is computed, but a portion of the ROC curve
can be specified with partial.auc.
auc(...)
"auc"(roc, partial.auc=FALSE, partial.auc.focus=c("specificity",
"sensitivity"), partial.auc.correct=FALSE,
allow.invalid.partial.auc.correct = FALSE, ...)
"auc"(smooth.roc, ...)
"auc"(multiclass.roc, ...)
"auc"(formula, data, ...)
"auc"(response, predictor, ...)roc function, a smooth.roc object from the
smooth function, or a multiclass.roc from the
multiclass.roc function.
roc function.roc function.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 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. Ignored if partial.auc=FALSE.
partial.auc
defined. Ignored if partial.auc=FALSE. Default: FALSE.
NA (with a warning)
when attempting to correct a pAUC below the diagonal.
Set to TRUE to return a (probably invalid) corrected AUC.
This is useful especially to avoid introducing a bias against low
pAUCs in bootstrap operations.c("auc", "numeric") (or
c("multiclass.auc", "numeric") if a multiclass.roc was supplied), in
fraction of the area or in percent if percent=TRUE, with the
following attributes:
method="binomial". In this case
and only if a full AUC is requested, the classical binormal AUC formula is applied: $$auc=\phi\frac{a}{\sqrt{1 + b^2}}.$$ 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.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 a partial AUC (pAUC)
can be
specified 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 in relation 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. 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 partial.auc.correct=TRUE,
the correction by McClish will be applied:
$$\frac{1+\frac{auc-min}{max-min}}{2}$$
where auc is the uncorrected pAUC computed in the region defined by partial.auc,
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 percent.
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.
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: 10.1023/A:1010920819831.
Donna Katzman McClish (1989) ``Analyzing a Portion of the ROC Curve''. Medical Decision Making 9(3), 190--195. 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: 10.1186/1471-2105-12-77.
roc, ci.auc
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