gmdepth: Generalized Mahalanobis Depth and Distance

Description Usage Arguments Value Author(s) References Examples

View source: R/gmdepth.R

Description

This function allows you to compute the Generalized Kernel Mahalanobis depth measure as stated in Hernandez et al (2018, submitted) and the Generalized Mahalanobis distance in Martos et al (2014).

Usage

1
gmdepth(A,b,resol,k.neighbor) 

Arguments

A

data matrix where variables in columns, observations in rows.

b

a new point in the support of the distribution to evaluate the depth. If omitted, the function compute the distances and depth between all points in the sample.

resol

resolution level, i.e. number of density level sets to consider.

k.neighbor

number of local neighbours to estimate the support.

Value

depth

the generalized Mahalanobis depth measure.

distance

the generalized Mahalanobis distance measure.

Author(s)

Hernandez and Martos

References

Hernandez N. et al (2018). Generalized Mahalanobis depth functions (submitted). Martos, G. et al (2014). Generalizing the Mahalanobis distance via density kernels. Inteligent Data Anal.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require(MASS)
set.seed(1)
A=mvrnorm(450,c(0,0),Sigma=diag(2))
b=mvrnorm(50,c(10,10),Sigma=diag(c(0.1,0.1)))
C=rbind(A,b)
plot(C, pch=20, col=c(rep('black',450),rep('red',50)),
                      xlab='x1',ylab='x2')

gmd.fit = gmdepth(A=C)
depth    = gmd.fit$depth
distance = gmd.fit$distance
plot(depth,distance, pch=20, 
           col=c(rep('black',450),rep('red',50)))
gmdepth(A=A,b=mvrnorm(1,c(0,0),Sigma=diag(2))) 

bigdatadist documentation built on May 2, 2019, 11:06 a.m.