This function allows identifying the indexes and positions of outliers in a numeric vector.
ueda_index(x, smax = 5)
x | A numeric vector |
---|---|
smax | The maximum number of outliers to be detected. By default, smax = 3. |
A list with 2 components:
index Boolean (TRUE/FALSE) indicating whether each observation is an outlier.
position The position of the outliers in the data.
Marmolejo-Ramos, F., Vélez, J.I. & Romão, X. Automatic detection of discordant outliers via the Ueda’s method. J Stat Distrib App 2, 8 (2015). https://doi.org/10.1186/s40488-015-0031-y
# random seed for reproducibility set.seed(13) # introduce 5 outliers x <- c(rnorm(25, 300, 10), rnorm(5, 400, 5)) # shuffle the data x <- sample(x) # find indexes ueda_index(x, smax = 5) #> $indexes #> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE #> [13] TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE TRUE FALSE #> [25] FALSE FALSE FALSE FALSE FALSE FALSE #> #> $positions #> [1] 12 13 19 21 23 #>