compute_depth: Compute Depth

View source: R/depth_object.R

compute_depthR Documentation

Compute Depth

Description

Computes the statistical depth of every row of data with respect to the empirical distribution of data, returning a depth object from which medians, outliers, ranks, and other derived quantities can be extracted cheaply without recomputing depth.

Usage

compute_depth(data, depth_fn = mahalanobis_depth, ...)

Arguments

data

Numeric matrix (n x d) or data frame. Rows are observations, columns are variables.

depth_fn

Depth function to use. Must have signature f(x, data, ...) and return a numeric vector of length nrow(x). Defaults to mahalanobis_depth.

...

Additional arguments forwarded to depth_fn.

Value

An object of class "depth" with components:

depths

Numeric vector of length n — depth of each observation.

data

The original data matrix.

depth_fn

The depth function used.

n

Number of observations.

d

Dimension.

call

The matched call.

Examples


set.seed(42)
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
dd   <- compute_depth(data, depth_fn = mahalanobis_depth)

median(dd)
rank(dd)
outliers(dd)
summary(dd)
plot(dd)



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