DepthProc project consist of a set of statistical procedures based on so called statistical depth functions. The project involves free available R package and its description.
DepthProc is avaiable on CRAN:
install.packages("DepthProc")
You can also install it from GitHub with devtools package:
library(devtools)
# install_github("zzawadz/DepthProc")
install.packages("DepthProc", repos = c('https://zzawadz.r-universe.dev', 'https://cloud.r-project.org'))
Most of the code is written in C++ for additional efficiency. We also
use OpenMP to speedup computations with multithreading. The speedup is
close to linear in the number of cores — the timings below were knitted
on a 4-core machine, so restricting depth() to one thread costs
roughly 4x the elapsed time, and to two threads roughly 2x:
library(DepthProc)
set.seed(123)
d <- 10
x <- MASS::mvrnorm(2000, rep(0, d), diag(d))
# Default - utilize as many threads as possible
system.time(depth(x, x, method = "LP"))
#> user system elapsed
#> 1.864 0.001 0.473
# Only single thread - compare the elapsed column:
system.time(depth(x, x, method = "LP", threads = 1))
#> user system elapsed
#> 1.769 0.000 1.772
# Two threads:
system.time(depth(x, x, method = "LP", threads = 2))
#> user system elapsed
#> 1.803 0.000 0.904
x <- MASS::mvrnorm(100, c(0, 0), diag(2))
depthEuclid(x, x)
depthMah(x, x)
depthLP(x, x)
depthProjection(x, x)
depthLocal(x, x)
depthTukey(x, x)
## Base function to call others:
depth(x, x, method = "Projection")
depth(x, x, method = "Local", depth_params1 = list(method = "LP"))
## Get median
depthMedian(x,
depth_params = list(
method = "Local",
depth_params1 = list(method = "LP")))
library(mvtnorm)
y <- rmvt(n = 200, sigma = diag(2), df = 4, delta = c(3, 5))
depthContour(y, points = TRUE, graph_params = list(lwd = 2))

depthPersp(y, depth_params = list(method = "Mahalanobis"))

There are two functional depths implemented - modified band depth (MBD), and Frainman-Muniz depth (FM):
x <- matrix(rnorm(60), nc = 20)
fncDepth(x, method = "MBD")
fncDepth(x, method = "FM", dep1d_params = list(method = "Mahalanobis"))
x <- matrix(rnorm(2000), ncol = 100)
fncBoxPlot(x, bands = c(0, 0.5, 1), method = "FM")
