| diss_mahalanobis | R Documentation |
Creates a configuration object for computing Mahalanobis dissimilarity.
Pass the result to dissimilarity() to compute the dissimilarity
matrix.
The Mahalanobis distance is computed by first transforming the data into
Mahalanobis space via a factorization of the inverse covariance matrix
M^{-1} = W^{T}W (using SVD), then applying Euclidean distance in
that transformed space:
d(x_i, x_j) = \sqrt{\frac{1}{p}(x_i - x_j)M^{-1}(x_i - x_j)^T}
diss_mahalanobis(center = TRUE, scale = FALSE)
center |
Logical. Center the data before computing distances?
Applied jointly to |
scale |
Logical. Scale the data before computing distances?
Applied jointly to |
An object of class c("diss_mahalanobis", "diss_method").
The covariance matrix will be singular — and the distance therefore
uncomputable — when the number of observations is smaller than the number
of variables, or when variables are perfectly collinear. This is common
with raw spectral data; consider using diss_euclidean() on
PCA scores instead.
dissimilarity, diss_euclidean,
diss_cosine
m <- diss_mahalanobis()
m <- diss_mahalanobis(center = TRUE, scale = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.