R/compute.threshold.cROC.R

Defines functions compute.threshold.cROC

Documented in compute.threshold.cROC

compute.threshold.cROC <-
function(object, criterion = c("FPF", "TPF", "YI"), FPF, TPF, newdata, ci.level = 0.95, parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL) {
	object.class <- class(object)[1]
	if (!(object.class %in% c("cROC.bnp", "cROC.kernel", "cROC.sp"))) {
		stop(paste0("This function can not be used for this object class: ", class(object)[1]))
	}

	criterion <- match.arg(criterion)
	if(criterion == "FPF" & missing(FPF)) {
		stop(paste0("The vector of FPF at which to calculate the threshold values should be specified"))	
	}
	if(criterion == "TPF" & missing(TPF)) {
		stop(paste0("The vector of TPF at which to calculate the threshold values should be specified"))	
	}

	if(ci.level <= 0 || ci.level >= 1) {
        stop("The ci.level should be between 0 and 1")
    }
	method <- paste0("compute.threshold.", criterion, ".", object.class)
	if(criterion == "YI") {
		res <- eval(parse(text = method))(object = object, newdata = newdata, ci.level = ci.level, parallel = parallel, ncpus = ncpus, cl = cl)
	} else if(criterion == "FPF") { 
		res <- eval(parse(text = method))(object = object, FPF = FPF, newdata = newdata, ci.level = ci.level, parallel = parallel, ncpus = ncpus, cl = cl)
	} else {
		res <- eval(parse(text = method))(object = object, TPF = TPF, newdata = newdata, ci.level = ci.level, parallel = parallel, ncpus = ncpus, cl = cl)
	}
	res$call <- match.call()
	res
}

Try the ROCnReg package in your browser

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

ROCnReg documentation built on March 31, 2023, 5:42 p.m.