projmedian: Location estimates based on projection depth

View source: R/projmedian.R

projmedianR Documentation

Location estimates based on projection depth

Description

Computes a projection depth based location estimate of a p-dimensional dataset x.

Usage

projmedian(x, projection.depths = NULL, options = NULL)

Arguments

x

An n by p data matrix with observations in the rows and variables in the columns.

projection.depths

Vector containing the projection depth of the observations in x.

options

A list of options to pass to the projdepth routine. See projdepth for more details.

Details

The algorithm depends on the function projdepth to compute the projection depth of the observations in x. If these depth values have already been computed, they can be passed as an optional argument to save computing time. If not, the projection depth values will be computed and the user can pass a list with options to the projdepth function.

It is first checked whether the data lie in a subspace of dimension smaller than p. If so, a warning is given, as well as the dimension of the subspace and a direction which is orthogonal to it.

Value

A list with components:

max

The point of x with maximal projection depth. If multiple points have maximum depth, their center of gravity is returned.

Huber

A weighted center of gravity of all observations. The weights are defined by the Huber function with parameter alpha = 1 / (1+sqrt(qchisq(0.95, p))) Observations for which the projection depth is more than alpha receive weight 1, other points receive weight ( sqrt(qchisq(0.95, p)) / outlyingness )^2.

Author(s)

P. Segaert

References

Maronna, R.A., Yohai, V.J. (1995). The behavior of the Stahel-Donoho robust multivariate estimator. Journal of the American Statistical Association, 90, 330–341.

See Also

outlyingness, projdepth, adjOutl, dirOutl

Examples

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

mrfDepth documentation built on May 29, 2024, 5:04 a.m.