auc.roc.plot {PresenceAbsence} | R Documentation |
AUC ROC Plot
Description
auc.roc.plot
creates a ROC plot for one dataset and one or more model predictions. Prints AUC for each model as part of the legend. auc.roc.plot
also includes an option to mark several types of optimal thresholds along each ROC plot.
Usage
auc.roc.plot(DATA, threshold = 101, find.auc = TRUE,
which.model = (1:(ncol(DATA) - 2)), na.rm = FALSE,
xlab = "1-Specificity (false positives)",
ylab = "Sensitivity (true positives)", main = "ROC Plot",
model.names = NULL, color = NULL, line.type = NULL, lwd = 1,
mark = 0, mark.numbers = TRUE, mark.color = NULL,
opt.thresholds = NULL, opt.methods = NULL, req.sens,
req.spec, obs.prev = NULL, smoothing = 1, add.legend = TRUE,
legend.text = model.names, legend.cex = 0.8, add.opt.legend = TRUE,
opt.legend.text = NULL, opt.legend.cex = 0.7,
counter.diagonal = FALSE, pch = NULL, FPC, FNC, cost.line = FALSE)
Arguments
DATA |
a matrix or dataframe of observed and predicted values where each row represents one plot and where columns are:
| |||||||||||||||||||||||||||||||||
threshold |
cutoff values between zero and one used for translating predicted probabilities into 0 /1 values, defaults to 0.5. It can be a single value between zero and one, a vector of values between zero and one, or a positive integer representing the number of evenly spaced thresholds to calculate. | |||||||||||||||||||||||||||||||||
find.auc |
a logical indicating if area under the curve should be calculated | |||||||||||||||||||||||||||||||||
which.model |
a number indicating which model from | |||||||||||||||||||||||||||||||||
na.rm |
a logical indicating whether missing values should be removed | |||||||||||||||||||||||||||||||||
xlab |
a title for the x axis | |||||||||||||||||||||||||||||||||
ylab |
a title for the y axis | |||||||||||||||||||||||||||||||||
main |
an overall title for the plot | |||||||||||||||||||||||||||||||||
model.names |
a vector of the names of each model included in | |||||||||||||||||||||||||||||||||
color |
should each model be plotted in a different color. It can be a logical value (where | |||||||||||||||||||||||||||||||||
line.type |
should each model be plotted in a different line type. It can be a logical value (where | |||||||||||||||||||||||||||||||||
lwd |
line width | |||||||||||||||||||||||||||||||||
mark |
particular thresholds to mark along each roc plot, given in same format as | |||||||||||||||||||||||||||||||||
mark.numbers |
a logical indication if the threshold values of each marked point along the ROC curved should be labeled next to the points | |||||||||||||||||||||||||||||||||
mark.color |
should the marked thresholds be plotted in a different color for each model. A logical value where | |||||||||||||||||||||||||||||||||
opt.thresholds |
logical indicating whether the optimal thresholds should be calculated and plotted, or a vector specifying thresholds to plot | |||||||||||||||||||||||||||||||||
opt.methods |
what methods should be used to optimize thresholds. Argument can be given either as a vector of method names or method numbers. Possible values are:
| |||||||||||||||||||||||||||||||||
req.sens |
a value between zero and one giving the user defined required sensitivity. Only used if | |||||||||||||||||||||||||||||||||
req.spec |
a value between zero and one giving the user defined required sspecificity. Only used if | |||||||||||||||||||||||||||||||||
obs.prev |
observed prevalence for | |||||||||||||||||||||||||||||||||
smoothing |
smoothing factor for maximizing/minimizing. Only used if | |||||||||||||||||||||||||||||||||
add.legend |
a logical indicating if a legend for AUC lines should be added to plot | |||||||||||||||||||||||||||||||||
legend.text |
a two item vector of text for presence/absence legend. Defaults to 'model.names'. | |||||||||||||||||||||||||||||||||
legend.cex |
cex for AUC legend | |||||||||||||||||||||||||||||||||
add.opt.legend |
logical indicating if a legend for optimal threshold criteria should be included on the plot | |||||||||||||||||||||||||||||||||
opt.legend.text |
a vector of text for optimimal threshold criteria legend. Defaults to text corresponding to 'opt.methods'. | |||||||||||||||||||||||||||||||||
opt.legend.cex |
cex for optimization criteria legend | |||||||||||||||||||||||||||||||||
counter.diagonal |
should a counter-diagonal line be plotted. Note: each ROC plot crosses this line at the point where sensitivity equals specificity for that model. | |||||||||||||||||||||||||||||||||
pch |
plotting "character", i.e., symbol to use for the thresholds specified in | |||||||||||||||||||||||||||||||||
FPC |
False Positive Costs, or for C/B ratio C = 'net costs of treating nondiseased individuals'. | |||||||||||||||||||||||||||||||||
FNC |
False Negative Costs, or for C/B ratio B = 'net benefits of treating diseased individuals'. | |||||||||||||||||||||||||||||||||
cost.line |
a logical indicating if the line representing the realtive cost ratio should be added to the plot. |
Details
Receiver Operating Curves (ROC plots) provide a threshold independent method of evaluating the performance of presence/absence models. In a ROC plot the true positive rate (sensitivity) is plotted against the false positive rate (1.0-specificity) as the threshold varies from 0 to 1. A good model will achieve a high true positive rate while the false positive rate is still relatively small; thus the ROC plot will rise steeply at the origin, and then level off at a value near the maximum of 1. The ROC plot for a poor model (whose predictive ability is the equivalent of random assignment) will lie near the diagonal, where the true positive rate equals the false positive rate for all thresholds. Thus the area under the ROC curve (AUC) is a good measure of overall model performance, with good models having an AUC near 1, while poor models have an AUC near 0.5.
mark
can be used to mark particular thresholds along each ROC plot, alternativly, if optimal.thresholds
= TRUE
the function will find optimal thresholds by several criteria and plot them along each ROC curve.
See optimal.thresholds for more details on the optimization methods, and on the arguments ReqSens
, ReqSpec
, obs.prev
smoothing
, FPC
, FNC
, and cost.line
.
Note: if too many methods are included in opt.methods
, the graph will get very crowded.
Value
creates a graphical plot
Author(s)
Elizabeth Freeman eafreeman@fs.fed.us
See Also
optimal.thresholds,presence.absence.accuracy, roc.plot.calculate, error.threshold.plot, presence.absence.summary
Examples
data(SIM3DATA)
auc.roc.plot(SIM3DATA)
auc.roc.plot( SIM3DATA,
opt.thresholds=TRUE,
opt.methods=c("Default","Sens=Spec","MinROCdist"))
auc.roc.plot( SIM3DATA,
threshold=101,
which.model=c(2,3),
model.names=c("model a","model b","model c"),
na.rm=TRUE,
xlab="1-Specificity (false positives)",
ylab="Sensitivity (true positives)",
main="ROC Plot",
color=TRUE,
line.type=TRUE,
lwd=1,
mark=0,
mark.numbers=TRUE,
opt.thresholds=TRUE,
opt.methods=c(1,2,4),
req.sens=0.85,
req.spec=0.85,
obs.prev=NULL,
add.legend=TRUE,
legend.text=NULL,
legend.cex=0.8,
add.opt.legend=TRUE,
opt.legend.text=NULL,
opt.legend.cex=0.7,
counter.diagonal=TRUE,
pch=NULL)