# roc: Build a ROC curve In BDgraph: Bayesian Structure Learning in Graphical Models using Birth-Death MCMC

## 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

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

## Arguments

 pred An adjacency matrix 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 An adjacency matrix 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(). ... 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 the 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 the response and predictor vectors as passed in argument. levels the levels of the response as defined in argument. controls the predictor values for the control observations. cases the predictor values for the cases. percent if the sensitivities, specificities and AUC are reported in percent, as defined in argument. direction the direction of the comparison, as defined in argument. fun.sesp the function used to compute sensitivities and specificities. Will be re-used in bootstrap operations. sensitivities the sensitivities defining the ROC curve. specificities the specificities defining the ROC curve. thresholds the 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).

## References

Tom Fawcett (2006) “An introduction to ROC analysis”. Pattern Recognition Letters 27, 861–874. DOI: 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: doi: 10.1186/1471-2105-12-77.