Computes the Multivariate Median of the distribution provided in data
(depth computations rely on the packages
depth
,
OjaNP
and
ddalpha
,
while convex body minizers "MCD" and "MVE" use the package
MASS
).
median_mv(data, method = "Projection", sampleMedian = TRUE, warnings = FALSE)
data | Matrix of numerical values containing the observations (one per row, with two columns for X and Y coordinates) |
---|---|
method | Method to use. Valid options are "CW", "MCD", "MVE", "L2", "Lui", "Mahalanobis", "Oja", "Projection" (default), "Spatial" and "Tukey" |
sampleMedian | Logical value. If |
warnings | Logical value, to display the warnings and error caught by the underlying functions |
Coordinates of the Multivariate Median
# Illustrative data XY <- rbind( mvtnorm::rmvnorm(200, c(0, 0), diag(2)), mvtnorm::rmvnorm(100, c(15, 20), diag(2) * 3 - 1), mvtnorm::rmvnorm(150, c(-10, 15), diag(2) * 2 - 0.5), mvtnorm::rmvnorm(100, c(5, 5), diag(2) * 200) ) # Compute median m <- median_mv(XY, method = "L2", warnings = TRUE) # Plot results plot(XY, asp = 1, xlab = "X", ylab = "Y")## Others examples of medians if (FALSE) { median_mv(XY, method = "Oja") median_mv(XY, method = "Tukey", sampleMedian = TRUE) median_mv(XY, method = "Tukey", sampleMedian = FALSE) }