R/util_hubert.R

Defines functions util_hubert

Documented in util_hubert

#' utility function for the outliers rule of Hubert and Vandervieren 2008
#'
#' function to calculate outliers according to the rule of Huber et al. This
#' function requires the package `robustbase`
#'
#' @param x [numeric] data to check for outliers
#'
#' @return binary vector
#'
#' @family outlier_functions
#' @concept outlier
#' @keywords internal

util_hubert <- function(x) {
  lth <- robustbase::adjboxStats(x, doScale = FALSE)$stats[1]
  uth <- robustbase::adjboxStats(x, doScale = FALSE)$stats[5]
  xbin <- ifelse(x < lth | x > uth, 1, 0)
  return(xbin)
}

Try the dataquieR package in your browser

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

dataquieR documentation built on May 29, 2024, 7:18 a.m.