roc | R Documentation |
A receiver operating characteristic (ROC) curve shows the ability of a binary classifier. Here it is applied to compare two sets of values, stored as two FLQuant objects. The first is the result of aplying a logical comparison of a given state against a reference value, so it contains a binary (0, 1) label. The second, the score, contains an alternative metric that attempts to measure the absolute value of the first. The examples below compare an observation of stock status, SSB being less than a reference point, and an alternative metric, here the catch curve estimates of total mortality.
roc(label, ind, direction = c(">=", "<="))
auc(x = NULL, TPR = x$TPR, FPR = x$FPR)
data(ple4)
# OM 'reality' on stock status (fbar)
state <- fbar(ple4)[, ac(1960:2017)]
# Model estimates of F using catch curves
ind <- acc(catch.n(ple4)[, ac(1960:2017)])
# Compute TSS, returns data.frame
roc(state >= 0.22, ind)
# Needs ggplotFL
## Not run:
ggplot(roc(state >= 0.22, ind, direction='>='), aes(x=FPR, y=TPR)) +
geom_line() +
geom_abline(slope=1, intercept=0, colour="red", linetype=2)
## End(Not run)
# Computes auc using the output of roc()
with(roc(state >= 0.22, ind), auc(TPR=TPR, FPR=FPR))
auc(roc(state >= 0.22, ind))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.