Skip to contents

Returns a full NxN matrix of Mahalanobis distances among rows of X, using a shrunken inverse covariance. No block-based exclusion is performed.

Usage

# S3 method for class 'mahalanobis'
pairwise_dist(obj, X)

Arguments

obj

A distance function object of class c("mahalanobis", "distfun").

X

A numeric matrix (rows = observations, columns = variables).

Value

An N x N numeric matrix of pairwise Mahalanobis distances.

Details

Uses corpcor::invcov.shrink on X to estimate the inverse covariance matrix and then computes mahalanobis(...) for each row vs. each other row.

Examples

X <- matrix(rnorm(100), 10, 10)
dist_obj <- mahadist()
dist_matrix <- pairwise_dist(dist_obj, X)
#> Error in UseMethod("pairwise_dist"): no applicable method for 'pairwise_dist' applied to an object of class "c('mahalanobis', 'distfun')"