R/compute.threshold.FPF.AROC.bnp.R

Defines functions compute.threshold.FPF.AROC.bnp

compute.threshold.FPF.AROC.bnp <-
function(object, newdata, FPF = 0.5, ci.level = 0.95, parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL) {
    if(class(object)[1] != "AROC.bnp") {
        stop(paste0("This function cannot be used for this object class: ", class(object)[1]))
    }
    
    # Newdata
    # names.cov <- all.vars(object$fit$formula)[-1]
    names.cov <- get_vars_formula(object$fit$formula)
    if(!missing(newdata) && !inherits(newdata, "data.frame"))
        stop("Newdata must be a data frame")
    if(!missing(newdata) && length(names.cov) != 0 && sum(is.na(match(names.cov, names(newdata)))))
        stop("Not all needed variables are supplied in newdata")
    
    if(missing(newdata)) {
        newdata <- cROCData(object$data, names.cov, object$group)
    } else {
        newdata <- as.data.frame(newdata)
        newdata <- na.omit(newdata[,names.cov, drop = FALSE])
    }
    
    thresholds <- compute.threshold.FPF.bnp(object_h = object$fit, newdata = newdata, FPF = FPF, ci.level = ci.level, parallel = parallel, ncpus = ncpus, cl = cl)
    
    res <- list()
    res$newdata <- newdata
    res$thresholds <- thresholds$thresholds
    res$FPF <- FPF
    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.