# depth.Mahalanobis: Calculate Mahalanobis Depth In ddalpha: Depth-Based Classification and Calculation of Data Depth

## Description

Calculates the Mahalanobis depth of points w.r.t. a multivariate data set.

## Usage

 `1` ```depth.Mahalanobis(x, data, mah.estimate = "moment", mah.parMcd = 0.75) ```

## Arguments

 `x` Matrix of objects (numerical vector as one object) whose depth is to be calculated; each row contains a d-variate point. Should have the same dimension as `data`. `data` Matrix of data where each row contains a d-variate point, w.r.t. which the depth is to be calculated. `mah.estimate` is a character string specifying which estimates to use when calculating the Mahalanobis depth; can be `"moment"` or `"MCD"`, determining whether traditional moment or Minimum Covariance Determinant (MCD) (see `covMcd`) estimates for mean and covariance are used. By default `"moment"` is used. `mah.parMcd` is the value of the argument `alpha` for the function `covMcd`; is used when `mah.estimate =` `"MCD"`.

## Details

Calculates Mahalanobis depth. Mahalanobis depth is based on an outlyingness measure (Zuo & Serfling, 2000), viz. the Mahalanobis distance between the given point and the center of the data (Mahalanobis, 1936).

Moment estimates may be used i.e. traditional mean and covariance matrix, the corresponding depth may be sensitive to outliers. A more robust depth is obtained with minimum volume ellipsoid (MVE) or minimum covariance determinant (MCD) estimators, see Rousseeuw & Leroy (1987) and Lopuhaa & Rousseeuw (1991).

## Value

Numerical vector of depths, one for each row in `x`; or one depth value if `x` is a numerical vector.

## References

Mahalanobis, P. (1936). On the generalized distance in statistics. Proceedings of the National Academy India 12 49–55.

Liu, R.Y. (1992). Data depth and multivariate rank tests. In: Dodge, Y. (ed.), L1-Statistics and Related Methods, North-Holland (Amsterdam), 279–294.

Lopuhaa, H.P. and Rousseeuw, P.J. (1991). Breakdown points of affine equivariant estimators of multivariate location and covariance matrices. The Annals of Statistics 19 229–248.

Rousseeuw, P.J. and Leroy, A.M. (1987). Robust Regression and Outlier Detection. John Wiley & Sons (New York).

Zuo, Y.J. and Serfling, R. (2000). General notions of statistical depth function. The Annals of Statistics 28 461–482.

`depth.halfspace` for calculation of the Tukey 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.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```# 5-dimensional normal distribution data <- mvrnorm(1000, rep(0, 5), matrix(c(1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1), nrow = 5)) x <- mvrnorm(10, rep(1, 5), matrix(c(1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), nrow = 5)) depths <- depth.Mahalanobis(x, data) cat("Depths moment: ", depths, "\n") depths <- depth.Mahalanobis(x, data, mah.estimate = "MCD", mah.parMcd = 0.75) cat("Depths MCD: ", depths, "\n") ```

### Example output

```Loading required package: MASS