roc {BDgraph}R Documentation

Build a ROC curve

Description

This function builds a ROC curve specifically for graph structure learning and returns a “roc” object, a list of class “roc”. This object can be printed, plotted, or passed to the functions pROC::roc(), pROC::ci(), pROC::smooth.roc() and pROC::coords(). Additionally, two roc objects can be compared with pROC::roc.test(). This function is based on the roc function of R package pROC.

Usage

 
roc( pred, actual, auc = TRUE, smooth = FALSE, plot = FALSE, quiet = TRUE, ... )

Arguments

pred

adjacency matrix (or a vector) corresponding to an estimated graph. It can be an object with S3 class "bdgraph" from function bdgraph. It can be an object of S3 class "ssgraph", from the function ssgraph::ssgraph() of R package ssgraph::ssgraph(). It can be a numeric or ordered vector of the same length than actual, containing the predicted value of each observation.

actual

adjacency matrix (or a vector) corresponding to the actual graph structure in which a_{ij}=1 if there is a link between notes i and j, otherwise a_{ij}=0. It can be an object with S3 class "sim" from function bdgraph.sim. It can be an object with S3 class "graph" from function graph.sim. It can be a factor, numeric or character vector of responses (true class), typically encoded with 0 (controls) and 1 (cases). Only two classes can be used in a ROC curve.

smooth

if TRUE, the ROC curve is passed to smooth to be smoothed.

auc

compute the area under the curve (AUC)? If TRUE (default), additional arguments can be passed to pROC::auc().

plot

plot the ROC curve? If TRUE, additional arguments can be passed to pROC::plot.roc().

quiet

if TRUE, turn off messages when direction and levels are auto-detected.

...

further arguments to be passed to pROC::roc().

Value

If the data contained any NA value and na.rm=FALSE, NA is returned. Otherwise, if smooth=FALSE, a list of class “roc” with the following fields:

auc

if called with auc=TRUE, a numeric of class “auc” as defined in pROC::auc().

ci

if called with ci=TRUE, a numeric of class “ci” as defined in pROC::ci().

response

the response vector. Patients whose response is not %in% levels are discarded. If NA values were removed, a na.action attribute similar to na.omit stores the row numbers.

predictor

predictor vector converted to numeric as used to build the ROC curve. Patients whose response is not %in% levels are discarded. If NA values were removed, a na.action attribute similar to na.omit stores the row numbers.

original.predictor, original.response

response and predictor vectors as passed in argument.

levels

levels of the response as defined in argument.

controls

predictor values for the control observations.

cases

predictor values for the cases.

percent

if the sensitivities, specificities and AUC are reported in percent, as defined in argument.

direction

direction of the comparison, as defined in argument.

fun.sesp

function used to compute sensitivities and specificities. Will be re-used in bootstrap operations.

sensitivities

sensitivities defining the ROC curve.

specificities

specificities defining the ROC curve.

thresholds

thresholds at which the sensitivities and specificities were computed. See below for details.

call

how the function was called. See match.call for more details.

If smooth=TRUE a list of class “smooth.roc” as returned by pROC::smooth(), with or without additional elements auc and ci (according to the call).

Author(s)

Reza Mohammadi a.mohammadi@uva.nl; Lucas Vogels l.f.o.vogels@uva.nl

References

Tom Fawcett (2006) “An introduction to ROC analysis”. Pattern Recognition Letters 27, 861–874, doi:10.1016/j.patrec.2005.10.010

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.

See Also

plotroc, pROC::plot.roc(), pROC::auc(), pROC::print.roc(), bdgraph, bdgraph.mpl, compare

Examples

## Not run: 
set.seed( 5 )

# Generating multivariate normal data from a 'scale-free' graph
data.sim = bdgraph.sim( n = 200, p = 15, graph = "scale-free", vis = TRUE )

# Running BDMCMC algorithm 
sample.bdmcmc = bdgraph( data = data.sim, algorithm = "bdmcmc", iter = 10000 )

# ROC curve for BDMCMC algorithm 
roc.bdmcmc = BDgraph::roc( pred = sample.bdmcmc, actual = data.sim, plot = TRUE )

# Running RJMCMC algorithm
sample.rjmcmc = bdgraph( data = data.sim, algorithm = "rjmcmc", iter = 10000 )

# ROC curve for RJMCMC algorithm
roc.rjmcmc = BDgraph::roc( pred = sample.rjmcmc, actual = data.sim, plot = TRUE )

# ROC curve for both BDMCMC and RJMCMC algorithms
pROC::ggroc( list( BDMCMC = roc.bdmcmc, RJMCMC = roc.rjmcmc ) )

## End(Not run)

[Package BDgraph version 2.72 Index]