R/util_hubert.R

Defines functions util_hubert

Documented in util_hubert

#' utility function for the outliers rule of Huber et al.
#'
#' 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
#'
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 July 26, 2023, 6:10 p.m.