pROC v1.16.2
Monthly downloads
Display and Analyze ROC Curves
Tools for visualizing, smoothing and comparing receiver operating characteristic (ROC curves). (Partial) area under the curve (AUC) can be compared with statistical tests based on U-statistics or bootstrap. Confidence intervals can be computed for (p)AUC or ROC curves.
Readme
pROC
An R package to display and analyze ROC curves.
For more information, see:
- 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
- The official web page on ExPaSy
- The CRAN page
- My blog
- The FAQ
Stable
The latest stable version is best installed from the CRAN:
install.packages("pROC")
Getting started
If you don't want to read the manual first, try the following:
Loading
library(pROC)
data(aSAH)
Basic ROC / AUC analysis
roc(aSAH$outcome, aSAH$s100b)
roc(outcome ~ s100b, aSAH)
Smoothing
roc(outcome ~ s100b, aSAH, smooth=TRUE)
more options, CI and plotting
roc1 <- roc(aSAH$outcome,
aSAH$s100b, percent=TRUE,
# arguments for auc
partial.auc=c(100, 90), partial.auc.correct=TRUE,
partial.auc.focus="sens",
# arguments for ci
ci=TRUE, boot.n=100, ci.alpha=0.9, stratified=FALSE,
# arguments for plot
plot=TRUE, auc.polygon=TRUE, max.auc.polygon=TRUE, grid=TRUE,
print.auc=TRUE, show.thres=TRUE)
# Add to an existing plot. Beware of 'percent' specification!
roc2 <- roc(aSAH$outcome, aSAH$wfns,
plot=TRUE, add=TRUE, percent=roc1$percent)
Coordinates of the curve
coords(roc1, "best", ret=c("threshold", "specificity", "1-npv"))
coords(roc2, "local maximas", ret=c("threshold", "sens", "spec", "ppv", "npv"))
Confidence intervals
# Of the AUC
ci(roc2)
# Of the curve
sens.ci <- ci.se(roc1, specificities=seq(0, 100, 5))
plot(sens.ci, type="shape", col="lightblue")
plot(sens.ci, type="bars")
# need to re-add roc2 over the shape
plot(roc2, add=TRUE)
# CI of thresholds
plot(ci.thresholds(roc2))
Comparisons
# Test on the whole AUC
roc.test(roc1, roc2, reuse.auc=FALSE)
# Test on a portion of the whole AUC
roc.test(roc1, roc2, reuse.auc=FALSE, partial.auc=c(100, 90),
partial.auc.focus="se", partial.auc.correct=TRUE)
# With modified bootstrap parameters
roc.test(roc1, roc2, reuse.auc=FALSE, partial.auc=c(100, 90),
partial.auc.correct=TRUE, boot.n=1000, boot.stratified=FALSE)
Sample size
# Two ROC curves
power.roc.test(roc1, roc2, reuse.auc=FALSE)
power.roc.test(roc1, roc2, power=0.9, reuse.auc=FALSE)
# One ROC curve
power.roc.test(auc=0.8, ncases=41, ncontrols=72)
power.roc.test(auc=0.8, power=0.9)
power.roc.test(auc=0.8, ncases=41, ncontrols=72, sig.level=0.01)
power.roc.test(ncases=41, ncontrols=72, power=0.9)
Getting Help
- Type
?pROC
on the R command line - Make sure you've read the FAQ
- Search for questions tagged with pROC-R-package on Stack Overflow
If you still can't find an answer, you can:
- Ask a question on Stack Overflow with the pROC-r-package tag
- Bug reports should be submitted to the GitHub issue tracker
Development
Installing the development version
Download the source code from git, unzip it if necessary, and then type R CMD INSTALL pROC
. Alternatively, you can use the devtools package by Hadley Wickham to automate the process (make sure you follow the full instructions to get started):
if (! requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("xrobin/pROC")
Check
To run all automated tests, including slow tests:
cd .. # Run from parent directory
VERSION=$(grep Version pROC/DESCRIPTION | sed "s/.\+ //")
R CMD build pROC
RUN_SLOW_TESTS=true R CMD check pROC_$VERSION.tar.gz
vdiffr
The vdiffr package is used for visual tests of plots.
To run all the test cases (incl. slow ones) from the command line:
run_slow_tests <- TRUE
vdiffr::manage_cases()
To run the checks upon R CMD check, set environment variable NOT_CRAN=1
:
NOT_CRAN=1 RUN_SLOW_TESTS=true R CMD check pROC_$VERSION.tar.gz
Release steps
- Get new version to release:
VERSION=$(grep Version pROC/DESCRIPTION | sed "s/.\+ //") && echo $VERSION
- Build & check package:
R CMD build pROC && R CMD check --as-cran pROC_$VERSION.tar.gz
- Check with slow tests:
NOT_CRAN=1 RUN_SLOW_TESTS=true R CMD check pROC_$VERSION.tar.gz
- Check with R-devel:
rhub::check_with_rdevel()
- Check reverse dependencies:
revdepcheck::revdep_check(num_workers=8, timeout = as.difftime(60, units = "mins"))
- Update
Version
andDate
inDESCRIPTION
- Update version and date in
NEWS
- Create a tag:
git tag v$VERSION && git push --tags
- Submit to CRAN
Functions in pROC
Name | Description | |
auc | Compute the area under the ROC curve | |
are.paired | Are two ROC curves paired? | |
aSAH | Subarachnoid hemorrhage data | |
ci.se | Compute the confidence interval of sensitivities at given specificities | |
ci.auc | Compute the confidence interval of the AUC | |
ci.coords | Compute the confidence interval of arbitrary coordinates | |
ggroc.roc | Plot a ROC curve with ggplot2 | |
ci.thresholds | Compute the confidence interval of thresholds | |
coords_transpose | Transposing the output of coords | |
coords | Coordinates of a ROC curve | |
plot.ci | Plot confidence intervals | |
ci | Compute the confidence interval of a ROC curve | |
ci.sp | Compute the confidence interval of specificities at given sensitivities | |
lines.roc | Add a ROC line to a ROC plot | |
groupGeneric | pROC Group Generic Functions | |
pROC-package | pROC | |
roc | Build a ROC curve | |
Print a ROC curve object | ||
has.partial.auc | Does the ROC curve have a partial AUC? | |
cov.roc | Covariance of two paired ROC curves | |
roc.test | Compare the AUC of two ROC curves | |
multiclass.roc | Multi-class AUC | |
plot.roc | Plot a ROC curve | |
smooth | Smooth a ROC curve | |
power.roc.test | Sample size and power computation for ROC curves | |
var.roc | Variance of a ROC curve | |
No Results! |
Last month downloads
Details
Type | Package |
Date | 2020-03-19 |
Encoding | UTF-8 |
LinkingTo | Rcpp |
License | GPL (>= 3) |
URL | http://expasy.org/tools/pROC/ |
BugReports | https://github.com/xrobin/pROC/issues |
LazyData | yes |
NeedsCompilation | yes |
Packaged | 2020-03-19 16:18:27 UTC; xavier |
Repository | CRAN |
Date/Publication | 2020-03-19 17:30:07 UTC |
suggests | doParallel , ggplot2 , logcondens , MASS , microbenchmark , tcltk , testthat , vdiffr |
imports | methods , plyr , Rcpp (>= 0.11.1) |
depends | R (>= 2.14) |
Contributors | Stefan Siegert, Natacha Turck, Alexandre Hainard, Natalia Tiberti, Jean-Charles Sanchez, Fr<c3><a9>d<c3><a9>rique Lisacek, Markus M<c3><bc>ller, Matthias Doering |
Include our badge in your README
[](http://www.rdocumentation.org/packages/pROC)