MHD | R Documentation |
Metric halfspace depth for object data, generalizing Tukey's depth for Euclidean data. Implementing the method described in Dai and Lopez-Pintado (2022) \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2021.2011298")}.
Apply the metric halfspace depth algorithm (Dai and Lopez-Pintado (2022) <doi:10.1080/01621459.2021.2011298>) to calculate the metric halfspace depth at a set of evaluation points with respect to a data cloud. Also calculate the deepest points both in- and out-of-sample.
MHD(
mfd,
data,
anchors,
XEval,
theta0,
depthOnly = FALSE,
optGlo = list(),
optLoc = list(),
jiggle = 0,
jiggleQuantile = 0.01
)
mfd |
The manifold where the data is supported on. For example, the Euclidean space is generated using ‘manifold::createM(’Euclidean')‘, and the (hyper)sphere is 'manifold::createM(’Sphere')'. See 'manifold' package for more details. |
data |
A data frame giving the data points. Each row is an observation. |
anchors |
A data frame for the anchor points for evaluating the halfspace probabilities. If missing, default to the data points together with possibly the jiggled points. |
XEval |
A data frame for additional points at which the depth should be evaluated. Defaults to nothing. |
theta0 |
A vector for the initial value for searching for the deepest out-of-sample point. |
depthOnly |
Calculate the depth values only if 'TRUE', or both the depth values and the out-of-sample deepest point if 'FALSE' (default). The calculation of the deepest point can be time consuming. |
optGlo , optLoc |
Lists of user specified option for the global and the local optimization steps, respectively. Follows the specification of nloptr::nloptr. For a list of options, use ‘nloptr.print.options()', and for the list of algorithms see https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/ One should apply a derivative-free optimizers, and in particular one of 'c(’NLOPT_GN_DIRECT_NOSCAL', 'NLOPT_GN_DIRECT', 'NLOPT_GN_CRS2_LM', 'NLOPT_GN_MLSL_LDS')‘ in the global step and one of 'c(’NLOPT_LN_NELDERMEAD', 'NLOPT_LN_SBPLX')' for the local step. |
jiggle |
An interger. The number of jiggled points per data point to add into the dataset. This is for making the approximated MHD depth more precise. |
jiggleQuantile |
A numeric scalar. The amount of jiggling is determined by the 'jiggleQuantile' quantile of the nonzero pairwise distances between the data and the anchor points. |
A list containing the following fields:
sampDeepest |
The in-sample deepest point |
depthSamp |
The depth of the evaluation points |
depthDeepest |
The depth at the deepest out-of-sample point |
xDeepest |
The deepest out-of-sample point |
theta0 |
Initial value for the search of the deepest point |
optGlo |
Options used for the global search |
optLoc |
Options used for the local search |
nloptTime |
Time used by the optimization procedure |
Maintainer: Xiongtao Dai xiongtao.dai@hotmail.com
mfd <- manifold::createM('Euclidean')
n <- 100
d <- 4
data <- matrix(rnorm(n * d), n, d)
anchors <- matrix(rnorm(n * d), 2 * n, d)
# The default
depthObj1 <- MHD(mfd, data)
# more precise, but slower
depthObj2 <- MHD(mfd, data, anchors)
# Do not search for the deepest point. Faster
depthObj3 <- MHD(mfd, data, depthOnly=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.