Learn R Programming

robustmatrix (version 0.1.3)

matrixShapley: Outlier explanation based on Shapley values for matrix-variate data

Description

matrixShapley decomposes the squared matrix Mahalanobis distance (mmd) into additive outlyingness contributions of the rows, columns, or cell of a matrix mayrhofer2023multivariate,mayrhofer2024robustmatrix.

Usage

matrixShapley(X, mu = NULL, cov_row, cov_col, inverted = FALSE, type = "cell")

Value

Rowwise, columnwise, or cellwise Shapley value(s).

Arguments

X

a 3d array of dimension \((p,q,n)\), containing \(n\) matrix-variate samples of \(p\) rows and \(q\) columns in each slice.

mu

a \(p \times q\) matrix containing the means.

cov_row

a \(p \times p\) positive-definite symmetric matrix specifying the rowwise covariance matrix

cov_col

a \(q \times q\) positive-definite symmetric matrix specifying the columnwise covariance matrix

inverted

Logical. FALSE by default. If TRUE cov_row and cov_col are supposed to contain the inverted rowwise and columnwise covariance matrices, respectively.

type

Character. Either "row", "col", or "cell" (default) to compute rowwise, columnwise, or cellwise Shapley values.

References

See Also

mmd.

Examples

Run this code
n = 1000; p = 2; q = 3
mu = matrix(rep(0, p*q), nrow = p, ncol = q)
cov_row = matrix(c(5,2,2,4), 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)
distances <- mmd(X, mu, cov_row, cov_col)

Run the code above in your browser using DataLab