Skip to contents

Outlier detection based on turkey's fences. Tukey’s fences is a technique used in box plots. The non-outlier range is defined as Q1−k(Q3−Q1), Q3+k(Q3−Q1), where Q1 and Q3 are the lower and upper quartiles respectively and k - some non-negative constant (popular choice is 1.5).

Usage

is_outlier_turkey(x, threshold = 1.5, na.rm = TRUE)

Arguments

x

A vector of numeric values.

threshold

Multiplier for the IQR to set outlier boundaries. Higher values widen the range; default is 1.5.

na.rm

if TRUE, removes NA values before calculations. Default is TRUE.

Value

A logical vector.

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)

is_outlier_turkey(x)
#>  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE