mahalDistC | R Documentation |
For N points, in M dimensions, get squared Mahalanobis distances to center.
mahalDistC( m, scale = TRUE, use = "complete.obs", center = c("mean", "median"), ... )
m |
A data.frame or matrix. Observations in rows. |
scale |
If TRUE, scale variables before getting mahalanobis distances. |
use |
Observations to use in computing covariance matrix. Gets
passed to |
center |
Type of univariate center for each variable in |
... |
additional arguments passed to
|
For each of N points in M dimensions, get squared Mahalanobis distances to distribution centroid. This is useful for checking for outliers in a multivariate distribution. The squared Mahalanobis distances to center for an MV normal distribution with N dimensions will follow the chi square distribution with DF equal to N.
This function is a convenience wrapper around
mahalanobis
, which see. Variables are
optionally scaled before distances are computed. Incomplete
observations will return NA.
A list with additional class "mahalDist" containing elements:
D2: A vector of squared Mahalanobis distances for
observations (rows) in m
. Incomplete observations return
NA.
vars: A character vector with the column names from
m
.
dim: The number of columns of m
.
Dave Braze davebraze@gmail.com
mahalanobis
cov
solve
m <- matrix(rnorm(400, m=.8, s=.05), nrow=100) md <- mahalDistC(m) md$D2 hist(md$D2) rug(md$D2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.