outliers_mcd: MCD function to detect outliers

Description Usage Arguments Value Examples

Description

Detecting multivariate outliers using the Minimum Covariance Determinant approach

Usage

1
outliers_mcd(x, h, alpha, na.rm)

Arguments

x

matrix of bivariate values from which we want to compute outliers

h

proportion of dataset to use in order to compute sample means and covariances

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
12
13
14
15
16
#### Run outliers_mcd
# The default is to use 75% of the datasets in order to compute sample means and covariances
# This proportion equals 1-breakdown points (i.e. h = .75 <--> breakdown points = .25)
# This breakdown points is encouraged by Leys et al. (2018)
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_mcd(x = cbind(SOC,HSC), h = .75)
res

# Moreover, 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

Call:
outliers_mcd.default(x = cbind(SOC, HSC), h = 0.75)

Limit distance of acceptable values from the centroid :
[1] 9.21034

Number of detected outliers:
total 
   54 
 [1]    5   98  105  126  166  234  235  241  287  327  365  408  452  469  513
[16]  544  586  635  640  648  667  679  718  727  779 1147 1186 1242 1245 1250
[31] 1259 1260 1401 1504 1505 1509 1523 1687 1705 1757 1815 1891 1908 1910 1911
[46] 1912 1913 1923 1937 1938 1992 2021 2036 2073
         X1   X2
1  5.846154 3.04
2  4.461538 3.04
3  4.384615 3.32
4  4.461538 3.20
5  3.384615 3.36
6  4.230769 3.24
7  4.538462 3.44
8  4.000000 3.32
9  2.615385 3.40
10 2.538462 3.32
11 4.230769 3.32
12 3.307692 1.16
13 4.461538 3.08
14 4.153846 3.20
15 3.538462 3.28
16 2.461538 3.40
17 3.230769 3.48
18 4.307692 3.28
19 3.692308 3.68
20 3.846154 3.48
21 3.538462 3.96
22 2.384615 3.88
23 6.384615 2.24
24 6.538462 1.92
25 3.769231 3.56
26 4.307692 3.44
27 2.000000 2.72
28 3.615385 3.32
29 4.307692 3.32
30 2.076923 2.92
31 4.846154 3.28
32 4.846154 3.28
33 3.461538 1.00
34 2.076923 3.20
35 2.461538 3.28
36 2.153846 3.32
37 5.923077 2.60
38 2.461538 3.52
39 3.153846 3.64
40 4.769231 3.04
41 3.461538 3.28
42 2.230769 3.36
43 1.615385 2.44
44 2.307692 1.76
45 2.000000 2.52
46 2.000000 3.12
47 2.230769 3.16
48 2.769231 3.32
49 1.769231 2.56
50 1.692308 3.08
51 2.307692 2.16
52 3.307692 3.36
53 3.307692 3.56
54 1.000000 3.52

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