# smed: Calculating spherical medians In depth: Nonparametric Depth Functions for Multivariate Analysis

## Description

Computes the spherical median of a data set on the circle.

## Usage

 ```1 2``` ```smed(P, sort=FALSE, depths=NULL, alpha=NULL, method="Tukey", tracecontour=FALSE, tracepoints=FALSE) ```

## Arguments

 `P` The data as a vector, a matrix, a data frame or a list. `sort` Logical; TRUE indicates that the data in `P` is already sorted. `depths` For Tukey's method only; An optionnal vector of the same length as P that contains the Tukey depth of each data. The calculation of the depth is then skipped and the provided values are used instead. `alpha` For Tukey's method only; `alpha` is an optionnal numeric value between 0 and 1 to compute the median on a trimmed region rather than on the whole dataset. The trimming keeps only those points with a depth greater than or equal to `alpha`. The default value of `NULL` computes the median from the maximum depth trimmed region (i.e. no trimming). `method` Character string which determines the depth function used. `method` can be "Tukey" (the default) or "Circular". `tracecontour` Only if `method="Circular"`. Traces the plot of depth with respect to angular positions on the circle. `tracepoints` Only if `method="Circular"`. Draws the points and their median on the circle.

## Details

Calculates shperical medians for data on the circle only. The input must be a list of angles in radians between 0 and (polar coordinates). If `method="Tukey"`, the Tukey median is returned. If `method="Circular"`, the circular median (the point minimizing the average distance based on arccosine) is returned.

## Value

A numeric value between 0 and giving the median in polar coordinate.

Maxime Genest.

## References

Liu, R.Y., Parelius, J.M. and Singh, K. (1999), Multivariate analysis by data depth: Descriptive statistics, graphics and inference (with discussion), Ann. Statist., 27, 783–858.

Mardia, K.V. and Jupp, E.J. (1999). Directional Statistics, Wiley.

`sdepth` for calculation of the depth of a point, `scontour` for Tukey's spherical median.
 ```1 2 3``` ```## calculation of the Tukey spherical median for data on the circle set.seed(2011) smed(runif(30,min=0,max=2*pi)) ```