Skip to contents

This function is suited to find outliers in asymetric distributions (in contrast to the standard mad() function which works for symetric distributions only). The function splits the values along the median and returns the distance for every value from the median, relative to the left or right side MAD. https://eurekastatistics.com/using-the-median-absolute-deviation-to-find-outliers/

Usage

double_mad_from_median(x, zero_mad_action = NULL)

Arguments

x

A vector of numeric values.

zero_mad_action

Determines the action in the event of an MAD of zero. Defaults to NULL. The options are:

  • NULL: process runs with no warning

  • "warn": a warning will be displayed

  • "stop": process is stopped

Value

A numeric vector of length length(x).

Examples


x <- c(1, 2, 3, 3, 4, 4, 4, 5, 5.5, 6, 6, 6.5, 7, 7, 7.5, 8, 9, 12, 52, 90)

double_mad_from_median(x)
#>  [1]  2.5000000  2.0000000  1.5000000  1.5000000  1.0000000  1.0000000
#>  [7]  1.0000000  0.5000000  0.2500000  0.0000000  0.0000000  0.3333333
#> [13]  0.6666667  0.6666667  1.0000000  1.3333333  2.0000000  4.0000000
#> [19] 30.6666667 56.0000000