rmaha <-
function(x)
{
# Produces robust Mahalanobis distances (scaled for normal data).
p <- dim(x)[2]
out <- cov.mcd(x)
center <- out$center
cov <- out$cov
rd <- mahalanobis(x, center, cov)
const <- sqrt(qchisq(0.5, p))/median(rd)
return(const * sqrt(rd))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.