rocperf {alternativeROC} | R Documentation |
ROC curve performances
Description
Range of statistics associated with a ROC curve with confidence interval where applicable. This function is faster than the alternatives provided by the package pROC.
Usage
rocperf(
x,
y,
sensitivities = NULL,
specificities = NULL,
conf.level = 0.95,
fun = NULL,
seed = 1,
boot.n = 2000,
median = FALSE,
attr = FALSE,
parallel = FALSE,
simplify = TRUE,
...
)
Arguments
x |
Numeric vector containing the predicted value for each observation. |
y |
Factor, numeric, logical or character vector encoding the response. |
sensitivities |
Vector of sensitivity thresholds. Default NULL. |
specificities |
Vector of specificity thresholds. Default NULL. |
conf.level |
Width of the confidence interval. Default: 0.95 (i.e., 95% CI). |
fun |
Function to compute additional statistics. Default NULL. |
seed |
Random seed for bootstrapping. Default 1. |
boot.n |
Number of bootstrap samples. Default 2e3. |
median |
If TRUE, return median bootstrap sensitivities and specificities, otherwise return observed values, otherwise the observe value is provided. Default FALSE. |
attr |
Return bootstrap results and ROC curve as attributes. Default FALSE. |
parallel |
Parallelise bootstrap. Default FALSE. |
simplify |
If TRUE, return only median for results of the function |
... |
Additional arguments passed to |
Details
This function computes the area under the ROC curve (AUC) and its confidence interval, the Mann-Whitney U test p-value, and the p-value for the null hypothesis that the AUC is equal to 0.5 (DeLong et al. 1988).
The function also computes the sensitivity at specified specificities and the specificity at specified sensitivities, with confidence intervals and interquartile ranges if bootstrapping is performed.
The function uses the pROC
package to compute the ROC curve and
confidence intervals, and it can handle parallel processing for bootstrapping.
The function returns a data frame with the computed statistics, including:
Number of control and case patients
Mann Whitney U test p-value
AUC and its confidence intervals
Sensitivity at specified specificities and their confidence intervals
Specificity at specified sensitivities and their confidence intervals
The function fun
must take the following arguments:
-
controls
: vector of control values -
cases
: vector of case values -
thresholds
: vector of thresholds used for the ROC curve -
sensitivities
: vector of sensitivities -
specificities
: vector of specificities -
...
: additional arguments
and return a named vector of values.
Value
A data frame with the following columns:
n.control
: Number of control patientsn.case
: Number of case patientsMannWhitney.pvalue
: Mann Whitney U test p-valueAUC.pvalue
: p-value for the null hypothesis that AUC=0.5AUC
: Area under the ROC curve (point estimate)AUC.lCI
: Lower limit of 95% confidence interval for AUCAUC.uCI
: Upper limit of 95% confidence interval for AUCAUC.lQuart
: Lower limit of 50% confidence interval for AUCAUC.uQuart
: Upper limit of 50% confidence interval for AUCSe@SpX
: Sensitivity at X% specificitySe@SpX.lCI
: Lower limit of 95% confidence interval for sensitivity at X% specificitySe@SpX.uCI
: Upper limit of 95% confidence interval for sensitivity at X% specificitySe@SpX.lQuart
: Lower limit of 95% confidence interval for sensitivity at X% specificitySe@SpX.uQuart
: Upper limit of 95% confidence interval for sensitivity at X% specificitySp@SeX
: Specificity at X% sensitivitySp@SeX.lCI
: Lower limit of 95% confidence interval for specificity at X% sensitivitySp@SeX.uCI
: Upper limit of 95% confidence interval for specificity at X% sensitivitySp@SeX.lQuart
: Lower limit of 50% confidence interval for specificity at X% sensitivitySp@SeX.uQuart
: Upper limit of 50% confidence interval for specificity at X% sensitivityAdditional columns for statistics computed by the function
fun
if provided
data.frame
with one row with computed statistics in columns.
Examples
fu <- function(controls,cases,thr,se,sp,...) {
r <- pROC::roc(c(rep(0,length(controls)),
rep(1,length(cases))),
c(controls,cases),
quiet=TRUE)
c(AUC_fun=r$auc)
}
set.seed(1)
n <- 123
y <- runif(n)<.5
x <- rnorm(n)+y*1
ans <- rocperf(x,y,fun=fu)
ans <- rocperf(x,y,fun=fu,
senitivities=c(.5,.75,.9),
specificities=c(.5,.75,.9))