depthContour | R Documentation |
Computes the vertices of depth contours of multivariate data. The contours can be
computed based on halfspace depth, projection depth, skewness-adjusted projection
depth or directional projection depth. To make the actual plot for bivariate data,
the function plotContours
needs to be called on the result of depthContour
.
depthContour(x, alpha = NULL, type = "hdepth", directions = NULL, options = NULL)
x |
An |
alpha |
A vector containing the depth values of which the depth contours have to be computed. |
type |
The depth used in the computation of the contours:
|
directions |
An |
options |
A list of options to pass to
|
Depth contours of level \alpha
(or \alpha
-depth contours) are the boundaries of depth regions. Depth regions of level \alpha
are defined as regions in space containing the multivariate points whose depth value is at least \alpha
.
For bivariate data halfspace depth contours can be computed exactly following the algorithm in Ruts and Rousseeuw (1996). When the data are not in general position (i.e. when there is a line containing more than two observations) dithering is performed by adding random Gaussian noise to the data.
In all other cases an approximated method is performed using a bisection algorithm. Intersections with the depth contours are searched on lines originating from the depth median. The user can specify a set of directions corresponding to these lines. By default a random set of 250p
directions is considered. On each direction a point is searched having depth \alpha
. Starting limits are obtained by projecting the data on the direction and considering the data point with univariate depth \alpha
. By definition the multivariate depth of this point has to be lower or equal to \alpha
. A second limit is obtained by considering the deepest location estimate. The maximum number of iterations bisecting the current search interval can be specified through the options argument max.iter
. Note that this method is only affine or rotation equivariant if the chosen directions are affine or rotation equivariant.
It is first checked whether the data is found to lie in a subspace of
dimension lower than p
. If so, the routine will give a warning, giving
back the dimension of the subspace together with a direction describing a
hyperplane containing this subspace.
The output consists of a list. Each element of the list contains the following elements for each value \alpha
specified in the argument alpha
.
depth |
The depth of the depth contour of level |
vertices |
The coordinates of the vertices of the depth contour. |
empty |
Logical indicating whether the corresponding depth region is empty. |
dithered |
Logical indicating whether dithering has been applied in the exact bivariate algorithm based on halfspace depth. |
converged |
A vector of length |
type |
Same as input parameter type. |
dimension |
If the data are lying in a lower dimensional subspace, the dimension of this subspace. |
hyperplane |
If the data are lying in a lower dimensional subspace, a direction orthogonal to this subspace. |
P. Segaert based on Fortran code by P.J. Rousseeuw, I. Ruts and A. Struyf
Ruts I., Rousseeuw P.J. (1996). Computing depth contours of bivariate point clouds. Computational Statistics & Data Analysis, 23, 153–168.
plotContours
, bagdistance
# Compute and plot some halfspace depth contours of a two-dimensional dataset.
# The returned object is a ggplot2 object that may be edited
# using standard ggplot2 commands.
# One may consider different depth functions such as projection depth
# by changing the input parameter 'type'.
# By default the halfspace depth is used.
data(bloodfat)
Result <- depthContour(x = bloodfat,
alpha = c(0.03, 0.125, 0.25))
plotContours(x = bloodfat, depthContour = Result)
# Other options are projection depth, skewness-adjusted projection depth
# and directional projection depth
# they can be used by specifying type to be
# "projdepth", "sprojdepth" or "dprojdepth" respectively.
# When there is skewness in the data projection depth
# is less appropriate.
Result <- depthContour(x = bloodfat,
alpha = c(0.25, 0.35, 0.45),
type = "projdepth")
plotContours(x = bloodfat, depthContour = Result)
# The skewness-adjusted projection depth and directional projection depth
# better reflect the skewness in the data.
Result <- depthContour(x = bloodfat,
alpha = c(0.35, 0.45, 0.55),
type = "sprojdepth")
plotContours(x = bloodfat, depthContour = Result)
Result <- depthContour(x = bloodfat,
alpha = c(0.25, 0.35, 0.45),
type = "dprojdepth")
plotContours(x = bloodfat, depthContour = Result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.