mmd {robustmatrix} | R Documentation |
Matrix Mahalanobis distance
Description
Matrix Mahalanobis distance
Usage
mmd(X, mu, cov_row, cov_col, inverted = FALSE)
Arguments
X |
a 3d array of dimension |
mu |
a |
cov_row |
a |
cov_col |
a |
inverted |
Logical. FALSE by default.
If TRUE |
Value
Squared Mahalanobis distance(s) of observation(s) in X
.
Examples
n = 1000; p = 2; q = 3
mu = matrix(rep(0, p*q), nrow = p, ncol = q)
cov_row = matrix(c(1,0.5,0.5,1), nrow = p, ncol = p)
cov_col = matrix(c(3,2,1,2,3,2,1,2,3), nrow = q, ncol = q)
X <- rmatnorm(n = 1000, mu, cov_row, cov_col)
ind <- sample(1:n, 0.3*n)
X[,,ind] <- rmatnorm(n = length(ind), matrix(rep(10, p*q), nrow = p, ncol = q), cov_row, cov_col)
distances <- mmd(X, mu, cov_row, cov_col)
plot(distances)
abline(h = qchisq(0.99, p*q), lty = 2, col = "red")
[Package robustmatrix version 0.1.2 Index]