# Classical-like depth-based trimmed mean

### Description

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

### Usage

1 2 3 |

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

`W` |
Nonnegative weight function defined on [0, 1] through its argument |

`method` |
Character string which determines the depth function used. |

`ndir` |
Positive integer. Number of random directions used when approximate Tukey depth is utilised. Used jointly with |

`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.

### See Also

`med`

for medians and `ctrmean`

for a centroid trimmed mean.

### Examples

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 28 29 30 31 32 | ```
## 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)
## example with a large data set
set.seed(345)
x <- matrix(rnorm(2100), nc = 3)
trmean(x, .1, approx = TRUE)
## trimmed mean with a non constant weight function
W1 <-function(x,alpha,epsilon) {
(2*(x-alpha)^2/epsilon^2)*(alpha<=x)*(x<alpha+epsilon/2)+
(-2*(x-alpha)^2/epsilon^2+4*(x-alpha)/epsilon-1)*
(alpha+epsilon/2<=x)*(x<alpha+epsilon)+(alpha+epsilon<=x)
}
set.seed(345)
x <- matrix(rnorm(210), nc = 3)
trmean(x, .1, W = W1, epsilon = .05)
## two other examples of weighted trimmed mean
set.seed(345)
x <- matrix(rnorm(210), nc = 3)
W2 <- function(x, alpha) {x^(.25)}
trmean(x, .1, W = W2)
W3 <- function(x, alpha, beta){1-sqrt(x)+x^2/beta}
trmean(x, .1, W = W3, beta = 1)
``` |