R/uncertainty.R

Defines functions uncertainty

Documented in uncertainty

uncertainty <- function(index, tocd){ 
  
  thist <- hist(unique(index), breaks = c(sort(tocd$Threshold)), plot = FALSE)
  tocd$counts <- c(0, thist$counts[length(thist$counts):1], 0)
  
  # calculate uncertainty
  uncertain <- 0
  for (i in 2:(nrow(tocd) - 2)){
    if(tocd[i, "counts"] > 1) {
      area <- (tocd[i, "falseAlarms1"] - tocd[i - 1, "falseAlarms1"])*(tocd[i, "Model1"] - tocd[i - 1, "Model1"])
      uncertain <- uncertain + area
    }
  }
  
  i <- i + 1
  if(tocd[i, "counts"] > 2) {
    area <- (tocd[i, "falseAlarms1"] - tocd[i - 1, "falseAlarms1"])*(tocd[i, "Model1"] - tocd[i - 1, "Model1"])
    uncertain <- uncertain + area
  }
  
  return(uncertain)
}

Try the TOC package in your browser

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

TOC documentation built on Feb. 16, 2023, 7:10 p.m.