% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diss_methods.R
\name{diss_mahalanobis}
\alias{diss_mahalanobis}
\title{Mahalanobis dissimilarity method constructor}
\usage{
diss_mahalanobis(center = TRUE, scale = FALSE)
}
\arguments{
\item{center}{Logical. Center the data before computing distances?
Applied jointly to \code{Xr} and \code{Xu} if both are provided.
Default \code{TRUE}.}

\item{scale}{Logical. Scale the data before computing distances?
Applied jointly to \code{Xr} and \code{Xu} if both are provided.
Default \code{FALSE}.}
}
\value{
An object of class \code{c("diss_mahalanobis", "diss_method")}.
}
\description{
Creates a configuration object for computing Mahalanobis dissimilarity.
Pass the result to \code{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
\eqn{M^{-1} = W^{T}W} (using SVD), then applying Euclidean distance in
that transformed space:

\deqn{d(x_i, x_j) = \sqrt{\frac{1}{p}(x_i - x_j)M^{-1}(x_i - x_j)^T}}
}
\section{Important limitations}{

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 \code{diss_euclidean()} on
PCA scores instead.
}

\examples{
m <- diss_mahalanobis()
m <- diss_mahalanobis(center = TRUE, scale = TRUE)
}
\seealso{
\code{\link{dissimilarity}}, \code{\link{diss_euclidean}},
\code{\link{diss_cosine}}
}
\author{
\href{https://orcid.org/0000-0002-5369-5120}{Leonardo Ramirez-Lopez}
}
