Outlier Detection using Local Outlier Factor

Outlier detection is an extremely useful tool. There are many ways to identify an outlier. This example will discuss one univariate approach and one multivariate approach. There are many uses for outlier detection. One use can be to inspect a dataset prior to analysis to ensure accurate analysis. It can also be used to validate data during data entry to help prevent data entry errors. If a researcher has a simple univariate dataset then something like the Grubbs test for outliers would work. The approach taken here to identify outliers is an approach known as Local Outlier Factor (LOF). In the R package it is known as lofactor and it replaces the dprep package. The lofactor can help identify multivariate outliers. The below dataset creates an artical outlier and can be seen in the multivariate k-means clustering. With the LOF, the density of a point is compared to each of its neighbors. This example uses two packes: the DMwR for the LOF function and the outlier package for the grubbs test for outliers.