Library: | stats |
See also: | median |
Quantlet: | simdep | |
Description: | Computes the simplicial depth estimate of location |
Usage: | {med,depths} = simdep(x{, mem}) | |
Input: | ||
x | n x p matrix (n observations of dimension p) | |
mem | optional parameter that affects the amount of memory used by the routine; the values belongs to interval (0,1), where 0 represents the minimal memory requirements and the lowest speed of computation, and 1 the maximal memory requirements and highest speed. Default value is 1. The higher is the dimension of observations (p), the bigger is the effect of the maximal memory setting (mem = 1). | |
Output: | ||
med | p x 1 vector containing the estimate of location | |
depth | n x 1 vector containing for every observation the number of simpleces covering it |
library("stats") ; ; simulate data ; randomize(101) x = uniform(100) ; ; estimate the location by simdep ; {med,d} = simdep(x) med ; ; estimate the location by median ; median(x)
There are two results confirming that the simplicial depth estimator is equivalent to median for one dimensional data: Contents of med [1,] 0.48251 Contents of med [1,] 0.48251
library("stats") library("xplore") ; ; simulate data ; randomize(10) x = uniform(30,2) ; ; estimate the location by simdep ; {med,dep} = simdep(x) med ; ; draw a depth graph and median ; d = createdisplay(1,1) dat = x col = round(5*dep/max(dep)) setmaskp(dat, col, 3, 8) median = med' setmaskp(median,4,12,15) ; median is red big star show(d, 1, 1, dat, median) setgopt(d, 1, 1, "title", "Simplicial depth")
There are two types of output. First, in the output window, the following estimate appears: Contents of med [1,] 0.53705 [2,] 0.33484 Second, there is also a graph showing the estimate as a big read star and all data points as circles of different colors. The color is given to every point according to its depth, i.e., the number of simpleces that covers it. So, points with the lowest depths are green, points with higher depths are blue, and so on.