projection_depth: Projection Depth

View source: R/projection_depth.R

projection_depthR Documentation

Projection Depth

Description

Computes the projection depth of one or more query points with respect to a reference distribution estimated from data, using an adaptive random projection approximation with parallel computation.

Usage

projection_depth(
  x,
  data,
  tol = 0.01,
  batch_size = 100L,
  min_batches = 5L,
  patience = 3L,
  seed = 42L
)

Arguments

x

Numeric matrix of query points (m x d), or a numeric vector of length d for a single point.

data

Numeric matrix of reference data (n x d).

tol

Convergence tolerance for the adaptive stopping rule. Default 0.01.

batch_size

Number of random projections per batch. Default 100.

min_batches

Minimum batches before checking convergence. Default 5.

patience

Consecutive stable batches to declare convergence. Default 3.

seed

Integer random seed for reproducibility. Default 42.

Details

Projection depth is defined via the Stahel-Donoho outlyingness — the supremum over all directions of the robust univariate Z-score of the projected point, using median and MAD as location and scale. This makes it fully robust with a high breakdown point, and affine invariant.

The deepest point under projection depth is a genuine robust estimator of multivariate location.

Value

Numeric vector of depth values in (0, 1], one per query point.

References

Zuo, Y. & Serfling, R. (2000). General notions of statistical depth function. Annals of Statistics, 28(2), 461–482.

Examples


set.seed(42)
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
x    <- matrix(rnorm(25),  nrow = 5,   ncol = 5)

projection_depth(x, data)

dd <- compute_depth(data, depth_fn = projection_depth)
median(dd)
outliers(dd)



depthR documentation built on June 26, 2026, 5:07 p.m.