moutlier_lof.Rd
Performs multivariate outlier detection using Local Outlier Factor algorithm.
moutlier_lof( xs, mask = !Reduce("|", lapply(xs, is.na)), threshold = c(1.5, 2), return.score = FALSE, ... )
xs | A dataframe or list of vectors (which will be coerced to a numeric matrix). |
---|---|
mask | A logical vector that defines which values in |
threshold | A length-two vector identifying thresholds for "mild" and "extreme" outliers. |
return.score | if |
... | Additional arguments to |
the values of threshold
identify mild and extreme
outliers based on the LOF score. Scores significantly larger
than 1 indicate outliers. Default values are 1.5 for "mild"
outliers and 2.0 for "extreme" outliers.
x = seq(0, 34, by = 0.25)*pi noise = rlnorm(length(x), meanlog = 1, sdlog = 3) y=sin(x) + noise mask = noise < 1 if (requireNamespace("dbscan", quietly = TRUE)) { moutlier_lof(list(y)) moutlier_lof(list(x, y), mask) moutlier_lof(list(x, y), mask, threshold = c(1, 2)) moutlier_lof(list(x, y), return.score = TRUE) }#> [1] 1.1102370 0.9894070 1.0421169 1.0242588 0.9117285 0.9646395 #> [7] 1.5603264 1.0703319 1.4045858 0.9874825 1.0218778 0.9951101 #> [13] 0.9667388 1.1211882 1.0315683 1.7765690 1.0385748 0.8938647 #> [19] 1.0519223 1.0283698 1.0278727 1.0586029 1.2214534 1.0012392 #> [25] 1.0731106 1.8450394 1.0391902 0.9819887 1.1428110 0.9341395 #> [31] 0.9897880 0.9747605 1.0825141 1.0792026 1.0659316 1.1794647 #> [37] 1.6916414 1.2361147 1.2585646 1.2917501 1.3266333 1.2067087 #> [43] 1.3885000 1.1251200 1.0481770 1.1033491 1.2943416 0.9593992 #> [49] 0.9207858 1.0348624 0.9720867 1.4583952 0.9709516 4.2874870 #> [55] 1.3266333 1.0118947 1.2240822 1.0093848 0.9907633 1.0123552 #> [61] 1.1183636 1.4008203 0.9453512 1.2933537 1.0331664 1.1239986 #> [67] 1.0568333 1.0261892 1.0014351 1.0299433 1.8973056 1.1059878 #> [73] 0.9494949 1.0174133 1.0636362 1.0423481 1.0081456 1.0423481 #> [79] 1.3560630 1.0307544 1.2240822 0.9222959 1.1386487 0.9440730 #> [85] 1.0280171 1.0673240 1.0617177 1.0036693 1.0036693 1.0221464 #> [91] 1.0121623 1.0328419 1.3897752 1.1703000 1.0137100 33.8592759 #> [97] 1.4260662 1.0231841 1.0095072 0.9448149 1.6040756 0.9219252 #> [103] 1.1642059 1.0839400 1.1831537 1.4568276 1.0998328 1.0769281 #> [109] 1.0719208 1.3683496 1.6868222 1.0719208 1.0505132 1.4258804 #> [115] 0.9753882 6.6359821 1.0408877 0.9895000 1.6868222 0.9425270 #> [121] 0.9920550 1.1082407 1.7134208 0.9672459 1.0434735 1.9620654 #> [127] 1.1492859 1.0904811 1.6868222 1.2843468 1.6868222 0.9995745 #> [133] 1.0109641 0.9937494 0.9937494 1.0021245 2.2583921