outliers_mahalanobis: mahalanobis function to detect outliers

Description Usage Arguments Value Examples

Description

Detecting multivariate outliers using the Mahalanobis distance

Usage

1
outliers_mahalanobis(x, alpha, na.rm)

Arguments

x

matrix of bivariate values from which we want to compute outliers

alpha

nominal type I error probability (by default .01)

na.rm

set whether Missing Values should be excluded (na.rm = TRUE) or not (na.rm = FALSE) - defaults to TRUE

Value

Returns Call, Max distance, number of outliers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#### Run outliers_mahalanobis
data(Attacks)
SOC <- rowMeans(Attacks[,c("soc1r","soc2r","soc3r","soc4","soc5","soc6","soc7r",
"soc8","soc9","soc10r","soc11","soc12","soc13")])
HSC <- rowMeans(Attacks[,22:46])
res <- outliers_mahalanobis(x = cbind(SOC,HSC), na.rm = TRUE)
# A list of elements can be extracted from the function,
# such as the position of outliers in the dataset
# and the coordinates of outliers
res$outliers_pos
res$outliers_val

Example output

 [1]    5  105  235  365  408  635  640  648  667  679  718  779 1147 1245 1259
[16] 1260 1401 1523 1705 1908 1910 1911 1937 1938 2036 2073
         X1   X2
1  5.846154 3.04
2  4.384615 3.32
3  4.538462 3.44
4  4.230769 3.32
5  3.307692 1.16
6  4.307692 3.28
7  3.692308 3.68
8  3.846154 3.48
9  3.538462 3.96
10 2.384615 3.88
11 6.384615 2.24
12 3.769231 3.56
13 4.307692 3.44
14 4.307692 3.32
15 4.846154 3.28
16 4.846154 3.28
17 3.461538 1.00
18 5.923077 2.60
19 3.153846 3.64
20 1.615385 2.44
21 2.307692 1.76
22 2.000000 2.52
23 1.769231 2.56
24 1.692308 3.08
25 3.307692 3.56
26 1.000000 3.52

Routliers documentation built on May 23, 2019, 9:03 a.m.