Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Aug 19, 2008

Area under the ROC curve

The area under the ROC curve is a good measure of predictive accuracy for a binary event. Given a dataset with observed (0/1) and predicted values (probabilities), the function roc will calculate for a series of cutpoints the sensitivity, specificity, likelihood ratios and the area under the ROC curve. This function will also produce three plots.

data(Ionosphere)
model <- glm(Class ~ ., data=Ionosphere[,15:35], family=binomial)
roc(predict(model,type="response"), Ionosphere$Class=="good")


cp sens espe
[1,] 0.00 1.00000000 0.0000000
[2,] 0.05 1.00000000 0.2380952
[3,] 0.10 0.99555556 0.3412698
[4,] 0.15 0.99555556 0.3809524
[5,] 0.20 0.99555556 0.4206349
[6,] 0.25 0.99111111 0.4365079
[7,] 0.30 0.99111111 0.4603175
[8,] 0.35 0.98222222 0.5000000
[9,] 0.40 0.97777778 0.5317460
[10,] 0.45 0.97333333 0.5634921
[11,] 0.50 0.96444444 0.6111111
[12,] 0.55 0.94222222 0.6507937
[13,] 0.60 0.92000000 0.7301587
[14,] 0.65 0.85333333 0.7777778
[15,] 0.70 0.77333333 0.7936508
[16,] 0.75 0.69333333 0.8174603
[17,] 0.80 0.59555556 0.8412698
[18,] 0.85 0.40888889 0.8888889
[19,] 0.90 0.20000000 0.9285714
[20,] 0.95 0.01777778 0.9603175
[21,] 1.00 0.00000000 1.0000000