auc: Area Under the Curve of the Reciever Operating Curve

Description Usage Arguments Value Author(s) See Also Examples

View source: R/auc.R

Description

auc estimates the AUC of the ROC using a Mann-Whitney U statistic.

Note: this method will exclude any missing data.

Usage

1
auc(obs, pred)

Arguments

obs

a vector of observed values which must be 0 for absences and 1 for occurrences

pred

a vector of the same length as obs representing the predicted values. Values must be between 0 & 1 representing a likelihood.

Value

Returns a single value represting the AUC value.

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

See Also

Kappa, omission, sensitivity, specificity, prop.correct, confusion.matrix, accuracy

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#create some data
obs = c(sample(c(0,1),20,replace=TRUE),NA)
pred = runif(length(obs),0,1)

#calculate AUC from the random data
auc(obs,pred)

#calculate an example 'perfect' AUC
obs = obs[order(obs)]
pred = pred[order(pred)]
auc(obs,pred)

Example output

[1] 0.5729167
Warning message:
In auc(obs, pred) : 1 data points removed due to missing data
[1] 1
Warning message:
In auc(obs, pred) : 1 data points removed due to missing data

SDMTools documentation built on Jan. 11, 2020, 9:23 a.m.

Related to auc in SDMTools...