Learn R Programming

OutlierDetection (version 0.1.1)

nn: Outlier detection using k Nearest Neighbours Distance method

Description

Takes a dataset and finds its outliers using distance-based method

Usage

nn(x, k = 0.05 * nrow(x), cutoff = 0.95, Method = "euclidean",
  rnames = FALSE, boottimes = 100)

Arguments

x

dataset for which outliers are to be found

k

No. of nearest neighbours to be used, default value is 0.05*nrow(x)

cutoff

Percentile threshold used for distance, default value is 0.95

Method

Distance method, default is Euclidean

rnames

Logical value indicating whether the dataset has rownames, default value is False

boottimes

Number of bootsrap samples to find the cutoff, default is 100 samples

Value

Outlier Observations: A matrix of outlier observations

Location of Outlier: Vector of Sr. no. of outliers

Outlier probability: Vector of proportion of times an outlier exceeds local bootstrap cutoff

Details

nn computes average knn distance of observation and based on the bootstrapped cutoff, labels an observation as outlier. Outlierliness of the labelled 'Outlier' is also reported and it is the bootstrap estimate of probability of the observation being an outlier. For bivariate data, it also shows the scatterplot of the data with labelled outliers.

References

Hautamaki, V., Karkkainen, I., and Franti, P. 2004. Outlier detection using k-nearest neighbour graph. In Proc. IEEE Int. Conf. on Pattern Recognition (ICPR), Cambridge, UK.

Examples

Run this code
# NOT RUN {
#Create dataset
X=iris[,1:4]
#Outlier detection
nn(X,k=4)
# }

Run the code above in your browser using DataLab