depth.wm | R Documentation |
Computes the Tukey depth weighted and/or trimmed for a given depth level or for a given number of deepest points.
depth.wm(data, depth.level = 1/nrow(data), weighted = TRUE,
break.ties = "atRandom", ...)
data |
data set for which the weighted mean should be computed, a matrix having > 2 columns and more rows than columns. |
depth.level |
either Tukey depth level for trimming (a numeric between 1/(number of rows in |
weighted |
whether the trimmed mean should be weighted by depth, logical, |
break.ties |
the way to break ties if the number of deepest points is given, character. If |
... |
further agruments passed to function |
After having computed the Tukey depth of each point in data
the function operates in two possible modes. If depth.level
lies between 0 and 1 then the function computes trimmed (weighted if specified by flag weighted
) mean of all points having at least given depth level. If depth.level
specifies the number of points (an integer between 1 and number of rows in data
) then the trimmed (weighted) mean of depth.level
deepest points are calculated breaking ties due to argument break.ties
(ties can occur due to discrete nature of the Tukey depth). This follows the idea of Donoho and Gasko (1992), also see this article for the breakdown point.
Depth of points is calculated by means of external function depth.halfspace
from package ddalpha
, whose arguments can be specified as well. In particular, argument exact
specifies whether Tukey depth is computed exactly (TRUE
) or approximated (FALSE
) by random projections; for the latter case argument num.directions
specifies the number of random directions to use. For further details about the algorithm see Dyckerhoff and Mozharovskyi (2016).
The function returns the weighted and/or trimmed mean, a point in the d
-variate Euclidean space (d
is the number of columns in data
), a numeric vector.
Pavlo Mozharovskyi <pavlo.mozharovskyi@ensai.fr>
Donoho, D.L. and Gasko, M (1992). Breakdown properties of location estimates based on halfspace depth and projected outlyingness. The Annals of Statistics, 20(4), 1803-1827.
Dyckerhoff, R. and Mozharovskyi, P. (2016). Exact computation of the halfspace depth. Computational Statistics and Data Analysis, 98, 19-30.
TukeyMedian
# Load required packages
require(TukeyRegion)
require(bfp)
# Generate data
set.seed(1)
X <- bfp:::rmvt(150, diag(3), rep(0, 3), 1)
# Compute arithmetic mean
T.mean <- colMeans(X)
(T.mean)
# Compute Tukey depth trimmed weighted mean (approximate depth)
T.approx1 <- depth.wm(X, 0.25)
(T.approx1)
T.approx2 <- depth.wm(X, 25)
(T.approx2)
# Compute Tukey depth trimmed weighted mean (exact depth)
T.exact1 <- depth.wm(X, 0.25, exact = TRUE)
(T.exact1)
T.exact2 <- depth.wm(X, 25, exact = TRUE)
(T.exact2)
# Compute Tukey median
Tm <- TukeyMedian(X)
(Tm$barycenter)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.