R/find_ueda_outliers.R
find_ueda_outliers.Rd
A function to calculate all components of Ueda's method.
find_ueda_outliers(x, smax = 5)
x | A numeric vector |
---|---|
smax | The maximum number of outliers to be detected. By default, smax = 3. |
A list of 4 components:
1. The Ut matrix.
2. The label matrix.
3. The input numeric vector.
4. The input vector with no outliers.
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 find_ueda_outliers(x, smax = 5) #> $Ut #> none X30 X29 X28 X27 X26 #> none -0.509 0.452 0.888 0.113 -3.256 -17.821 #> X1 2.946 3.896 4.323 3.542 0.122 -15.879 #> X2 6.411 7.358 7.789 7.028 3.638 -13.298 #> X3 9.819 10.760 11.197 10.466 7.137 -10.555 #> X4 13.106 14.038 14.475 13.766 10.489 -8.291 #> X5 16.398 17.323 17.766 17.101 13.950 -4.802 #> #> $label #> none X30 X29 X28 X27 X26 #> none -0.509 0.452 0.888 0.113 -3.256 -17.821* #> X1 2.946 3.896 4.323 3.542 0.122 -15.879 #> X2 6.411 7.358 7.789 7.028 3.638 -13.298 #> X3 9.819 10.76 11.197 10.466 7.137 -10.555 #> X4 13.106 14.038 14.475 13.766 10.489 -8.291 #> X5 16.398 17.323 17.766 17.101 13.95 -4.802 #> #> $x #> [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 389.8648 392.7034 394.7152 396.3593 400.7468 #> #> $x_new #> [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 #>