R/mahalanobis_scale.R

#' @title Perform Mahalanobis transformation.
#'
#' @description
#' This function performs the Mahalanobis transformation on a data matrix.
#'
#' @param X A data matrix.
#'
#' @return The transformed data matrix.
#'
#' @examples
#' data(heptathlon)
#' mahalanobis_scale(heptathlon)
#'
#' @export
mahalanobis_scale = function(X) {
  W = scale(X, scale=F)
  decomp = svd(W)
  return(decomp$u %*% t(decomp$v) * sqrt(nrow(X)-1))
}

Try the MAS3907 package in your browser

Any scripts or data that you put into this service are public.

MAS3907 documentation built on May 2, 2019, 4:47 p.m.