# Compute a location estimate of a two-dimensional dataset.
if (requireNamespace("robustbase", quietly = TRUE)) {
BivData <- log(robustbase::Animals2)
} else {
BivData <- matrix(rnorm(120), ncol = 2)
BivData <- rbind(BivData, matrix(c(6, 6, 6, -2), ncol = 2))
}
result <- projmedian(x = BivData)
plot(BivData, pch = 16)
points(result$max, col = "red", pch = 18, cex = 1.5)
points(result$Huber, col = "blue", pch = 3, cex = 1.5)
# Options for the underlying projdepth routine may be passed
# using the options argument.
result <- projmedian(x = BivData,
options = list(type = "Rotation",
ndir = 100,
stand = "unimcd",
h = 0.75*nrow(BivData)))
plot(BivData, pch = 16)
points(result$max, col = "red", pch = 18, cex = 1.5)
points(result$Huber, col = "blue", pch = 3, cex = 1.5)
# One may also compute the depth values of the observations in the data
# separately. This avoids having to recompute them when computing the median.
depth.result <- projdepth(x = BivData)
result <- projmedian(x = BivData,
projection.depths = depth.result$depthX)
Run the code above in your browser using DataLab