View source: R/depth.halfspace.r
depth.halfspace | R Documentation |
Calculates the exact or random Tukey (=halfspace, location) depth (Tukey, 1975) of points w.r.t. a multivariate data set.
depth.halfspace(x, data, exact, method, num.directions = 1000, seed = 0)
x |
Matrix of objects (numerical vector as one object) whose depth is to be calculated; each row contains a |
data |
Matrix of data where each row contains a |
exact |
The type of the used method. The default is |
method |
For For The name of the method may be given as well as just parameter |
num.directions |
Number of random directions to be generated (for |
seed |
The random seed. The default value |
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"
).
Numerical vector of depths, one for each row in x
; or one depth value if x
is a numerical vector.
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.
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.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.