R: Calculate Halfspace Depth

depth.halfspace {ddalpha} | R Documentation

## Calculate Halfspace Depth

### Description

Calculates the exact or random Tukey (=halfspace, location) depth (Tukey, 1975) of points w.r.t. a multivariate data set.

### Usage

    depth.halfspace(x, data, exact, method, num.directions = 1000, seed = 0)

### Arguments

`x` | Matrix of objects (numerical vector as one object) whose depth is to be calculated; each row contains a d-variate point. Should have the same dimension as `data`.
`data` | Matrix of data where each row contains a d-variate point, w.r.t. which the depth is to be calculated.
`exact` | The type of the used method. The default is `exact=F`, which leads to approximate computation of the Tukey depth. For `exact=F`, `method="Sunif.1D"` is used by default. If `exact=T`, the Tukey depth is computed exactly, with `method="recursive"` by default.
`method` | For `exact=F`, if `method="Sunif.1D"` (by default), the Tukey depth is computed approximately by being minimized over univariate projections (see Details below). For `exact=T`, the Tukey depth is calculated as the minimum over all combinations of k points from `data` (see Details below). 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 (for `method="Sunif.1D"`). The algorithmic complexity is linear in the number of observations in `data`, given the number of directions.
`seed` | The random seed. The default value `seed=0` makes no changes (for `method="Sunif.1D"`).

### Details

For `exact=F`, if `method="Sunif.1D"`, the Tukey depth is computed approximately using the random Tukey depth method proposed by Cuesta-Albertos and Nieto-Reyes (2008). Here the depth is determined as the minimum univariate Tukey depth of the - on lines in several directions - projected data. The directions are distributed uniformly on the (d-1)-sphere; the same direction set is used for all points.

For `exact=T`, the Tukey depth is computed exactly as the minimum of the sum of the depths in two orthogonal complementary affine subspaces, which dimensions add to d: one of the subspaces (combinatorial) is the k-dimensional hyperplane through (a point from) `x` and k points from `data`, another one is its orthogonal complement (see Dyckerhoff and Mozharovskyi, 2016 for the detailed description of the algorithmic framework). The algorithm then minimizes the depth over all combinations of k points, in which the depth in the orthogonal complements is computed using an exact algorithm. In this case, parameter `method` specifies the dimensionality k of the combinatorial space. The implemented (reasonable) algorithms (and corresponding names) are: k=1 (or `method="recursive"`), k=d-2 (or `method="plane"`), and k=d-1 (or `method="line"`).

### Value

Numerical vector of depths, one for each row in `x`; or one depth value if `x` is a numerical vector.

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

Rousseeuw, P.J. and Ruts, I. (1996). Algorithm AS 307: Bivariate location depth. Journal of the Royal Statistical Society. Seriec 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

`depth.Mahalanobis` for calculation of Mahalanobis depth.

`depth.projection` for calculation of projection depth.

`depth.simplicial` for calculation of simplicial depth.

`depth.simplicialVolume` for calculation of simplicial volume depth.

`depth.spatial` for calculation of spatial depth.

`depth.zonoid` for calculation of zonoid depth.

`depth.potential` for calculation of data potential.

### Examples

    # 3-dimensional normal distribution
    data <- mvrnorm(200, rep(0, 3),
                    matrix(c(1, 0, 0,
                             0, 2, 0,
                             0, 0, 1),
                    nrow = 3))
    x <- mvrnorm(10, rep(1, 3),
                 matrix(c(1, 0, 0,
                          0, 1, 0,
                          0, 0, 1),
                 nrow = 3))

    # default - random Tukey depth
    depths <- depth.halfspace(x, data)
    cat("Depths: ", depths, "\n")

    # default exact method - "recursive"
    depths <- depth.halfspace(x, data, exact = TRUE)
    cat("Depths: ", depths, "\n")

    # method "line"
    depths <- depth.halfspace(x, data, method = "line")
    cat("Depths: ", depths, "\n")

[Package ddalpha version 1.3.11 Index]