plotROC {PredictABEL} | R Documentation |
Function for a receiver operating characteristic curve (ROC) plot and area under the ROC curve (AUC) value.
Description
The function produces ROC curve and corresponding AUC value with 95% CI. The function can plot one or multiple ROC curves in a single plot.
Usage
plotROC(data, cOutcome, predrisk, labels, plottitle, xlabel, ylabel,
fileplot, plottype)
Arguments
data |
Data frame or matrix that includes the outcome and predictors variables. |
cOutcome |
Column number of the outcome variable. |
predrisk |
Vector of predicted risk. When multiple curves need to
be presented in one plot, specify multiple vectors of predicted
risks as |
labels |
Label(s) given to the ROC curve(s). Specification of |
plottitle |
Title of the plot. Specification of |
xlabel |
Label of x-axis. Specification of |
ylabel |
Label of y-axis. Specification of |
fileplot |
Name of the output file that contains the plot. The file is
saved in the working directory in the format specified under |
plottype |
The format in which the plot is saved. Available formats are
wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps,
eps or pdf. For example, |
Details
The function requirs predicted risks or risk scores and the outcome of
interest for all individuals.
Predicted risks can be obtained using the functions
fitLogRegModel
and predRisk
or be imported from other methods or packages.
Value
The function creates ROC plot and returns AUC value with 95% CI.
References
Hanley JA, McNeil BJ. The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology 1982;143:29-36.
Tobias Sing, Oliver Sander, Niko Beerenwinkel, Thomas Lengauer. ROCR: visualizing classifier performance in R. Bioinformatics 2005;21(20):3940-3941.
See Also
predRisk
, plotRiskDistribution
Examples
# specify the arguments in the function to produce ROC plot
# specify dataset with outcome and predictor variables
data(ExampleData)
# specify column number of the outcome variable
cOutcome <- 2
# fit logistic regression models
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel1 <- ExampleModels()$riskModel1
riskmodel2 <- ExampleModels()$riskModel2
# obtain predicted risks
predRisk1 <- predRisk(riskmodel1)
predRisk2 <- predRisk(riskmodel2)
# specify label of the ROC curve
labels <- c("without genetic factors", "with genetic factors")
# produce ROC curve
plotROC(data=ExampleData, cOutcome=cOutcome,
predrisk=cbind(predRisk1,predRisk2), labels=labels)