depth.space.halfspace: Calculate Depth Space using Halfspace Depth

Description Usage Arguments Details Value References See Also Examples

View source: R/depth.halfspace.r

Description

Calculates the representation of the training classes in depth space using the halfspace depth.

Usage

1
depth.space.halfspace(data, cardinalities, exact, method, num.directions = 1000, seed = 0)

Arguments

data

Matrix containing training sample where each row is a d-dimensional object, and objects of each class are kept together so that the matrix can be thought of as containing blocks of objects representing classes.

cardinalities

Numerical vector of cardinalities of each class in data, each entry corresponds to one class.

exact

The type of the used method. The default is exact=F, which leads to approximate computation of the halfspace depth. For exact=F, method="Sunif.1D" is used by default. If exact=T, the halfspace depth is computed exactly, with method="recursive" by default.

method

For exact=F, if method="Sunif.1D" (by default), the halfspace depth is computed approximately by being minimized over univariate projections (see details).

For exact=T, the halfspace depth is calculated as the minimum over all combinations of k points from data (see details). In this case parameter method specifies k, with possible values 1 for method="recursive" (by default), d-2 for method="plane", d-1 for method="line".

The name of the method may be given as well as just parameter exact, in which case the default method will be used.

num.directions

Number of random directions to be generated. As the same direction set is used for all observations, the algorithmic complexity of calculating the depth of each single point in data is logarithmic in the number of observations in data, given the number of directions, see Mozharovskyi et al. (2015), Section 2.3 for discussion.

seed

The random seed. The default value seed=0 makes no changes.

Details

The depth representation is calculated in the same way as in depth.halfspace, see References below for more information and details.

Value

Matrix of objects, each object (row) is represented via its depths (columns) w.r.t. each of the classes of the training sample; order of the classes in columns corresponds to the one in the argument cardinalities.

References

Cuesta-Albertos, J.A. and Nieto-Reyes, A. (2008). The random Tukey depth. Computational Statistics and Data Analysis 52 4979–4988.

Dyckerhoff, R. and Mozharovskyi, P. (2016). Exact computation of the halfspace depth. Computational Statistics and Data Analysis 98 19–30.

Mozharovskyi, P., Mosler, K., and Lange, T. (2015). Classifying real-world data with the DDα-procedure. Advances in Data Analysis and Classification 9 287–314.

Rousseeuw, P.J. and Ruts, I. (1996). Algorithm AS 307: Bivariate location depth. Journal of the Royal Statistical Society. Series C (Applied Statistics) 45 516–526.

Tukey, J.W. (1974). Mathematics and the picturing of data. In: Proceeding of the International Congress of Mathematicians, Vancouver, 523–531.

See Also

ddalpha.train and ddalpha.classify for application, depth.halfspace for calculation of the Tukey depth.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Generate a bivariate normal location-shift classification task
# containing 20 training objects
class1 <- mvrnorm(10, c(0,0), 
                  matrix(c(1,1,1,4), nrow = 2, ncol = 2, byrow = TRUE))
class2 <- mvrnorm(10, c(1,1), 
                  matrix(c(1,1,1,4), nrow = 2, ncol = 2, byrow = TRUE))
data <- rbind(class1, class2)
plot(data, col = c(rep(1,10), rep(2,10)))
# Get depth space using the random Tukey depth
dhA = depth.space.halfspace(data, c(10, 10))
(dhA)

# Get depth space using default exact method - "recursive"
dhE = depth.space.halfspace(data, c(10, 10), exact = TRUE)
(dhE)

data <- getdata("hemophilia")
cardinalities = c(sum(data$gr == "normal"), sum(data$gr == "carrier"))
depth.space.halfspace(data[,1:2], cardinalities)

Example output

Loading required package: MASS
Loading required package: class
Loading required package: robustbase
Loading required package: sfsmisc
Loading required package: geometry
Loading required package: magic
Loading required package: abind
      [,1] [,2]
 [1,]  0.1  0.0
 [2,]  0.1  0.0
 [3,]  0.2  0.0
 [4,]  0.4  0.0
 [5,]  0.2  0.1
 [6,]  0.1  0.1
 [7,]  0.1  0.0
 [8,]  0.1  0.0
 [9,]  0.2  0.0
[10,]  0.1  0.3
[11,]  0.2  0.1
[12,]  0.0  0.2
[13,]  0.0  0.1
[14,]  0.0  0.1
[15,]  0.0  0.2
[16,]  0.1  0.2
[17,]  0.0  0.1
[18,]  0.0  0.1
[19,]  0.0  0.1
[20,]  0.0  0.4
      [,1] [,2]
 [1,]  0.1  0.0
 [2,]  0.1  0.0
 [3,]  0.2  0.0
 [4,]  0.4  0.0
 [5,]  0.2  0.1
 [6,]  0.1  0.1
 [7,]  0.1  0.0
 [8,]  0.1  0.0
 [9,]  0.2  0.0
[10,]  0.1  0.3
[11,]  0.2  0.1
[12,]  0.0  0.2
[13,]  0.0  0.1
[14,]  0.0  0.1
[15,]  0.0  0.2
[16,]  0.1  0.2
[17,]  0.0  0.1
[18,]  0.0  0.1
[19,]  0.0  0.1
[20,]  0.0  0.4
            [,1]       [,2]
 [1,] 0.03333333 0.00000000
 [2,] 0.20000000 0.00000000
 [3,] 0.06666667 0.08888889
 [4,] 0.26666667 0.00000000
 [5,] 0.03333333 0.15555556
 [6,] 0.23333333 0.00000000
 [7,] 0.06666667 0.15555556
 [8,] 0.13333333 0.02222222
 [9,] 0.13333333 0.00000000
[10,] 0.20000000 0.00000000
[11,] 0.03333333 0.00000000
[12,] 0.16666667 0.02222222
[13,] 0.13333333 0.00000000
[14,] 0.10000000 0.00000000
[15,] 0.26666667 0.00000000
[16,] 0.03333333 0.00000000
[17,] 0.03333333 0.00000000
[18,] 0.33333333 0.00000000
[19,] 0.06666667 0.00000000
[20,] 0.10000000 0.08888889
[21,] 0.06666667 0.00000000
[22,] 0.03333333 0.00000000
[23,] 0.43333333 0.00000000
[24,] 0.26666667 0.00000000
[25,] 0.23333333 0.00000000
[26,] 0.10000000 0.00000000
[27,] 0.13333333 0.00000000
[28,] 0.30000000 0.00000000
[29,] 0.16666667 0.06666667
[30,] 0.26666667 0.00000000
[31,] 0.00000000 0.13333333
[32,] 0.03333333 0.08888889
[33,] 0.00000000 0.08888889
[34,] 0.00000000 0.02222222
[35,] 0.06666667 0.06666667
[36,] 0.00000000 0.02222222
[37,] 0.00000000 0.08888889
[38,] 0.00000000 0.08888889
[39,] 0.03333333 0.11111111
[40,] 0.00000000 0.17777778
[41,] 0.00000000 0.13333333
[42,] 0.00000000 0.37777778
[43,] 0.00000000 0.06666667
[44,] 0.00000000 0.17777778
[45,] 0.00000000 0.35555556
[46,] 0.00000000 0.02222222
[47,] 0.00000000 0.11111111
[48,] 0.00000000 0.06666667
[49,] 0.00000000 0.04444444
[50,] 0.00000000 0.06666667
[51,] 0.03333333 0.22222222
[52,] 0.00000000 0.24444444
[53,] 0.00000000 0.02222222
[54,] 0.03333333 0.22222222
[55,] 0.06666667 0.17777778
[56,] 0.00000000 0.33333333
[57,] 0.03333333 0.22222222
[58,] 0.06666667 0.02222222
[59,] 0.00000000 0.24444444
[60,] 0.00000000 0.06666667
[61,] 0.00000000 0.17777778
[62,] 0.00000000 0.02222222
[63,] 0.00000000 0.04444444
[64,] 0.26666667 0.02222222
[65,] 0.00000000 0.11111111
[66,] 0.00000000 0.17777778
[67,] 0.06666667 0.06666667
[68,] 0.00000000 0.31111111
[69,] 0.06666667 0.02222222
[70,] 0.00000000 0.22222222
[71,] 0.00000000 0.04444444
[72,] 0.00000000 0.08888889
[73,] 0.03333333 0.04444444
[74,] 0.00000000 0.13333333
[75,] 0.00000000 0.04444444

ddalpha documentation built on Jan. 9, 2020, 5:09 p.m.