# trmean: Classical-like depth-based trimmed mean In depth: Nonparametric Depth Functions for Multivariate Analysis

## Description

Computes a sample trimmed mean based on the Tukey depth, the Liu depth or the Oja depth.

## Usage

 ```1 2 3``` ```trmean(x, alpha, W = function(dep, alpha){return(1)}, method = "Tukey", ndir = 1000, approx = FALSE, eps = 1e-8, ...) ```

## Arguments

 `x` The data as a matrix, data frame or list. If it is a matrix or data frame, then each row is viewed as one bivariate observation. If it is a list, all components must be numerical vectors of equal length (coordinates of observations). `alpha` Outer trimming fraction (0 to 0.5). Observations whose depth is less than `alpha` to be trimmed. `W` Nonnegative weight function defined on [0, 1] through its argument `dep`. Number of arguments can be greater than 2 but the trimming fraction has to be one argument. See examples. `method` Character string which determines the depth function used. `method` can be "Tukey" (the default), "Liu" or "Oja". `ndir` Positive integer. Number of random directions used when approximate Tukey depth is utilised. Used jointly with `approx = TRUE`. `approx` Logical. If dimension is 3, should approximate Tukey depth be used? Useful when sample size is large. `eps` Error tolerance to control the calculation. `...` Any additional arguments to the weight function.

## Details

Dimension 2 or higher when `method` is "Tukey" or "Oja"; dimension 2 only when `method` is "Liu". Exactness of calculation depends on `method`. See `depth`.

## Value

Multivariate depth-based trimmed mean

## Author(s)

Jean-Claude Masse and Jean-Francois Plante, based on Fortran code by Ruts and Rousseeuw from University of Antwerp.

## References

Masse, J.C and Plante, J.F. (2003), A Monte Carlo study of the accuracy and robustness of ten bivariate location estimators, Comput. Statist. Data Anal., 42, 1–26.

Masse, J.C. (2008), Multivariate Trimmed means based on the Tukey depth, J. Statist. Plann. Inference, in press.

Rousseeuw, P.J. and Ruts, I. (1996), Algorithm AS 307: Bivariate location depth, Appl. Stat.-J. Roy. St. C, 45, 516–526.

`med` for medians and `ctrmean` for a centroid trimmed mean.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27``` ```## exact trimmed mean with default constant weight function data(starsCYG, package = "robustbase") trmean(starsCYG, .1) ## another example with default constant weight function set.seed(159); library(MASS) mu1 <- c(0,0); mu2 <- c(6,0); sigma <- matrix(c(1,0,0,1), nc = 2) mixbivnorm <- rbind(mvrnorm(80, mu1, sigma), mvrnorm(20, mu2, sigma)) trmean(mixbivnorm, 0.3) ## trimmed mean with a non constant weight function W1 <-function(x,alpha,epsilon) { (2*(x-alpha)^2/epsilon^2)*(alpha<=x)*(x