R/calculate.empirical.AUC.R

Defines functions calculate.empirical.AUC

calculate.empirical.AUC <-
function(data, marker, status, tag.healthy) {
      marker.diseased = data[data[,status] != tag.healthy, marker]
    	n.diseased = length (marker.diseased)

    	marker.healthy = data[data[,status] == tag.healthy, marker]
    	n.healthy = length(marker.healthy)

    	marker.diseasedmat <- matrix(rep(marker.diseased,n.healthy), nrow = n.healthy, byrow = T)
    	marker.healthymat <- matrix(rep(marker.healthy,n.diseased), nrow = n.healthy, byrow = F)
    	diffmat <- marker.healthymat-marker.diseasedmat
    	AUC <- (length(diffmat[diffmat < 0])+0.5*length(diffmat[diffmat == 0]))/(n.diseased*n.healthy)
    	
    	res <- AUC
    	return(res)
}

Try the GsymPoint package in your browser

Any scripts or data that you put into this service are public.

GsymPoint documentation built on Nov. 2, 2023, 5:59 p.m.