ROCc | R Documentation |
Computes the exact area under the ROC curve (AUROC), the Gini coefficient, and the Kolmogorov-Smirnov (KS) statistic for a binary classifier. Optionally, this function can plot the ROC curve, that is, the plot of the estimates of Sensitivity versus the estimates of 1-Specificity.
ROCc(object, plot.it = TRUE, verbose = TRUE, ...)
object |
a matrix with two columns: the first one is a numeric vector of 1's and 0's indicating whether each row is a "success" or a "failure"; the second one is a numeric vector of values indicating the probability (or propensity score) of each row to be a "success". Optionally, |
plot.it |
an (optional) logical switch indicating if the plot of the ROC curve is required or just the data matrix in which it is based. By default, |
verbose |
an (optional) logical switch indicating if should the report of results be printed. By default, |
... |
further arguments passed to or from other methods. For example, if |
A list which contains the following objects:
roc:
A matrix with the Cutoffs and the associated estimates of Sensitivity and Specificity.
auroc:
The exact area under the ROC curve.
gini:
The value of the Gini coefficient computed as 2(auroc
-0.5).
ks:
The value of the Kolmogorov-Smirnov statistic computed as the maximum value of |1-Sensitivity-Specificity|.
Hanley J.A., McNeil B.J. (1982) The Meaning and Use of the Area under a Receiver Operating Characteristic (ROC) Curve. Radiology 143, 29–36.
###### Example: Patients with burn injuries
burn1000 <- aplore3::burn1000
burn1000 <- within(burn1000, death2 <- ifelse(death=="Dead",1,0))
### splitting the sample: 70% for the training sample and 30% for the validation sample
train <- sample(1:nrow(burn1000),size=nrow(burn1000)*0.7)
traindata <- burn1000[train,]
testdata <- burn1000[-train,]
fit <- glm(death ~ age*inh_inj + tbsa*inh_inj, family=binomial("logit"), data=traindata)
probs <- predict(fit, newdata=testdata, type="response")
### ROC curve for the validation sample
ROCc(cbind(testdata[,"death2"],probs), col="red", col.lab="blue", col.axis="black",
col.main="black", family="mono")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.