projdepth | R Documentation |
Computes the projection depth of p
-dimensional points z
relative to a p
-dimensional dataset x
.
projdepth(x, z = NULL, options = list())
x |
An |
z |
An optional |
options |
A list of options to pass to the underlying |
Projection depth is based on the Stahel-Donoho outlyingness (SDO) and is computed as 1/(1+SDO)
. It is mostly suited to measure the degree of outlyingness of multivariate points with respect to a data cloud from an elliptical distribution.
It is first checked whether the data lie in a subspace of dimension smaller than p
. If so, a warning is given, as well as the dimension of the subspace and a direction which is orthogonal to it.
See outlyingness
for more details on the computation of the SDO. To visualize the depth of bivariate data one can apply the mrainbowplot
function. It plots the data colored according to their depth.
The output values of this function are based on the output of the outlyingness
function. More details can be found there.
A list with components:
depthX |
Vector of length |
depthZ |
Vector of length |
cutoff |
Points whose projection depth is smaller than this cutoff can be considered as outliers. Equivalently the outliers are those points whose Stahel-Donoho outlyingness exceed the corresponding cutoff. |
flagX |
Observations of |
flagZ |
Points of |
singularSubsets |
When the input parameter type is equal to |
dimension |
When the data |
hyperplane |
When the data |
inSubspace |
When a direction |
P. Segaert
Zuo Y. (2003). Projection-based depth functions and associated medians. The Annals of Statistics, 31, 1460–1490.
outlyingness
, projmedian
, mrainbowplot
, adjOutl
, dirOutl
# Compute the projection depth of a simple two-dimensional dataset.
# Outliers are plotted in red.
if (requireNamespace("robustbase", quietly = TRUE)) {
BivData <- log(robustbase::Animals2)
} else {
BivData <- matrix(rnorm(120), ncol = 2)
BivData <- rbind(BivData, matrix(c(6,6, 6, -2), ncol = 2))
}
Result <- projdepth(x = BivData)
IndOutliers <- which(!Result$flagX)
plot(BivData)
points(BivData[IndOutliers,], col = "red")
# A multivariate rainbowplot may be obtained using mrainbowplot.
plot.options = list(legend.title = "PD")
mrainbowplot(x = BivData,
depths = Result$depthX, plot.options = plot.options)
# Options for the underlying outlyingness routine may be passed
# using the options argument.
Result <- projdepth(x = BivData,
options = list(type = "Affine",
ndir = 1000,
stand = "MedMad",
h = nrow(BivData)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.