Compute local outlier factors using k nearest neighbours. A local
outlier factor is a measure of how anomalous each observation is based on
the density of neighbouring points.
The function uses dbscan::lof
to do the calculation.
Arguments
- y
Numerical matrix or vector of data
- k
Number of neighbours to include. Default: 5.
- ...
Additional arguments passed to
dbscan::lof
See also
dbscan::lof
Examples
y <- c(rnorm(49), 5)
lof_scores(y)
#> [1] 1.0955266 1.3574208 0.9696143 1.1475907 3.5454478 1.1233799 1.0004632
#> [8] 0.9643146 1.0277538 3.3031776 1.1992162 0.9866341 5.3386595 0.9715848
#> [15] 1.1045910 1.0021149 0.9524208 0.9809341 0.9731295 0.9665192 1.1985913
#> [22] 1.0082528 0.9727545 0.9818846 1.0261673 1.0450118 1.1541490 1.1614945
#> [29] 1.1836568 0.9938886 1.1619525 1.0490273 0.9886596 0.9806469 1.1797346
#> [36] 2.9499290 1.0032971 0.9789979 0.9821030 2.9462327 1.0340114 0.9996365
#> [43] 1.1322514 1.0005447 1.1764123 3.4474268 1.1951352 1.4531626 1.0213928
#> [50] 8.4933360