med(x, method = "Tukey", approx = FALSE, eps = 1e-8, maxit = 200, mustdith = FALSE, maxdith = 50, dithfactor = 10, factor = 0.8, nstp = NULL, ntry = NULL, nalt = NULL, ndir = 1000)method can be "Tukey" (the default), "Liu", "Oja", "Spatial" or "CWmed".method is "Spatial".NULL, the default value is taken to be the largest integer not greater than $5 n^{0.3}p$, where $n$ is the number of observations and $p$ the dimension.NULL, the default value is taken to be $10(p+1)$, where $p$ is the dimension.NULL, the default value is taken to be $4(p+1)$, where $p$ is the dimension.method is "Spatial" or "CWmed")method "Tukey" computes the Tukey median. Calculation is exact
in dimensions 1 and 2, and approximate in higher dimensions. The bivariate case
utilises algorithm HALFMED by Rousseeuw and Ruts (1998) as well as an algorithm
from Rousseeuw et al. (1999). Argument factor determines which
algorithm to use. If $n$ is the number of observations, contours of depth
$\le$ factor $n/2$ are derived from algorithm HALFMED, while the remaining contours are obtained from the second algorithm. The higher dimensional case is covered by Fortran code from Struyf and Rousseeuw (2000).When method is "Tukey", data must be in general position. If not, in dimension 2 dithering can be used in the sense that random noise is added to each component of each observation. Random noise takes the form eps times dithfactor times U for the horizontal component and eps times dithfactor times V for the vertical component, where U, V are independent uniform on [-.5, 5.]. This is done in a number of consecutive steps applying independent U's and V's.
method "Liu" computes the Liu median. It is based on Fortran code from Rousseeuw and Ruts (1996) and restricted to two-dimensional data.
method "Oja" computes the Oja median. It is based on Fortran code by Niinimaa et al. (1992) and restricted to two-dimensional data.
method "Spatial" computes the spatial median or mediancentre. It is based on Fortran code by Gower (1974), and Bedall and Zimmermann (1979).
method "CWmed" computes the coordinatewise median.
Bedall, F.K. and Zimmermann, H. (1979), AS 143: The Mediancentre, Appl. Stat., 28, 325--328.
Niinimaa, A, Oja, H., Nyblom, J. (1992), AS 277 : The Oja Bivariate Median, Appl. Stat., 41, 611--617.
Rousseeuw, P.J. and Ruts, I. (1996), Algorithm AS 307: Bivariate location depth, Appl. Stat.-J. Roy. St. C, 45, 516--526.
Rousseeuw, P.J. and Ruts, I. (1998), Constructing the bivariate Tukey median, Stat. Sinica, 8, 828--839.
Rousseeuw, P.J., Ruts, I., and Tukey, J.W. (1999), The Bagplot: A Bivariate Boxplot, The Am. Stat., 53, 382--387.
Small, C.G. (1990), A survey of multidimensional medians, Int. Statist. Rev., 58, 263--277.
Struyf, A. and Rousseeuw, P.J. (2000), High-dimensional computation of the deepest location, Comput. Statist. Data Anal., 34, 415--436.
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.
trmean and ctrmean for trimmed means## exact Tukey median for a mixture of bivariate normals
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))
med(mixbivnorm)
## approximate Tukey median of a four-dimensional data set
set.seed(601)
zz <- matrix(rnorm(96), nc = 4)
med(zz)
## data set not in general position
data(starsCYG, package = "robustbase")
med(starsCYG, method = "Liu")
## use of dithering for the Tukey median
med(starsCYG, mustdith = TRUE)
Run the code above in your browser using DataLab