R/youden.R

Defines functions youden

Documented in youden

#'  Youden statistic
#'  (max deviation from diagonal)

youden <- function(X, sign=c("positive", "absolute", "negative")) {
  verifyclass(X, "roc")
  sign <- match.arg(sign)
  ## choose meaningful columns
  wanted <- setdiff(fvnames(X, "."), "null")
  ## compute difference from null
  df <- as.data.frame(X)
  differ <- df[, wanted, drop=FALSE] - df[,"null"]
  ## calculate max deviation
  deviation <- switch(sign,
                      positive = differ,
                      absolute = abs(differ),
                      negative = -differ)
  y <- apply(deviation, 2, max)
  return(pmax(y,0))
}

Try the spatstat.explore package in your browser

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

spatstat.explore documentation built on Aug. 8, 2025, 7:36 p.m.