Learn R Programming

GSE (version 4.2-1)

partial.mahalanobis: Partial Square Mahalanobis Distance

Description

Computes the partial square Mahalanobis distance for all observations in x. Let \(\mathbf{x} = (x_{i1},...,x_{ip})'\) be a p-dimensional random vector and \(\mathbf{u} = (u_{i1},...,u_{ip})'\) be a p-dimensional vectors of zeros and ones indicating which entry is missing: 0 as missing and 1 as observed. Then partial mahalanobis distance is given by:

\( d(\mathbf{x, u, m, \Sigma}) = (\mathbf{x^{(u)}} - \mathbf{m^{(u)}})' (\mathbf{\Sigma^{(u)}})^{-1}(\mathbf{x^{(u)}} - \mathbf{m^{(u)}})\).

With no missing data, this function is equivalent to mahalanobis distance.

Usage

partial.mahalanobis(x, mu, Sigma)

Value

An S4 object of class CovRobMiss-class. The output S4 object contains the following slots:

muEstimated location. Can be accessed via getLocation.
SEstimated scatter matrix. Can be accessed via getScatter.
pmdSquared partial Mahalanobis distances. Can be accessed via getDist.
pmd.adjAdjusted squared partial Mahalanobis distances. Can be accessed via getDistAdj.
puDimension of the observed entries for each case. Can be accessed via getDim.
callObject of class "language". Not meant to be accessed.
xInput data matrix. Not meant to be accessed.
pColumn dimension of input data matrix. Not meant to be accessed.
estimatorCharacter string of the name of the estimator used. Not meant to be accessed.

Arguments

x

a matrix or data frame. May contain missing values, but cannot contain columns with completely missing entries.

mu

location estimate

Sigma

scatter estimate. Must be positive definite

Author

Andy Leung andy.leung@stat.ubc.ca

Examples

Run this code
if (FALSE) {
## suppose we would like to compute pmd for an MLE
x <- matrix(rnorm(1000),100,10)
U <- matrix(rbinom(1000,1,0.1),100,10)
x <- x * ifelse(U==1,NA,1)
## compute MLE (i.e. EM in this case)
res <- CovEM(x)
## compute pmd
res.pmd <- partial.mahalanobis(x, mu=getLocation(res), S=getScatter(res))
summary(res.pmd)
plot(res.pmd, which="index")
}

Run the code above in your browser using DataLab