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

View source: R/depth.halfspace.r

depth.space.halfspaceR Documentation

Calculate Depth Space using Halfspace Depth

Description

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

Usage

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\alpha-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

# 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)

ddalpha documentation built on Oct. 1, 2024, 1:07 a.m.