Using R to compute A (aprime) and b diagnostics in Zhang, J., & Mueller, S. T. (2005) for evaluating ROC diagnostics nonparametrically
(Copied from the https://sites.google.com/a/mtu.edu/whynotaprime/ weblink)
A <-function(h,f)
{
if(f<=.5 & h>=.5)
{
a <- .75 + (h-f)/4 - f*(1-h)
} else if(f<=h & h<=.5)
{
a <- .75 + (h-f)/4 - f/(4*h)
} else {
a <- .75 + (h-f)/4 - (1-h)/(4 * (1-f))
}
return(a)
}
b <- function(h,f)
{
if(f<=.5 & h>=.5)
{
b <-(5-4*h)/(1+4*f)
} else if(f<=h & h<=.5)
{
b <-(h^2+h)/(h^2+f)
} else {
b <- ((1-f)^2 + (1-h))/((1-f)^2 + (1-f))
}
return(b)
}Reference
Zhang, J., & Mueller, S. T. (2005). A note on ROC analysis and non-parametric estimate of sensitivity. Psychometrika, 70(1), 203–212. doi:10.1007/s11336-003-1119-8
