A generic function to remove outliers in a numeric vector using Ueda's method.
ueda_remove(x, smax = 3)
x | A numeric vector |
---|---|
smax | The maximum number of outliers to be detected. By default, smax = 3. |
The numeric vector `x` with no outliers. When no outliers are detected, the function returns the input numeric vector `x`.
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) # removes up to 5 outliers ueda_remove(x, smax = 5) #> [1] 281.4397 286.3902 289.0641 289.5459 295.6014 296.3462 297.1973 298.0605 #> [9] 298.8556 301.0066 301.8732 302.3668 302.6254 303.5740 304.1553 304.6187 #> [17] 305.5433 306.2018 307.0223 311.0514 311.4253 312.2951 313.9643 317.7516 #> [25] 318.3616