designMD {fit.models}R Documentation

Design Matrix Mahalanobis Distance

Description

Returns the squared Mahalanobis distance of all rows in the design (model) matrix X and the sample mean vector μ of the columns of X with respect to the sample covariance matrix Σ. This is (for vector x' a row of X) defined as

d^{2} = (x - μ)' Σ^{-1} (x - μ)

where

μ = colMeans(X)

and

Σ = cov(X).

Usage

designMD(object, ...)

Arguments

object

a fitted model object with a model.matrix method.

...

additional arguments are ignored.

Value

a numeric vector containing the squared Mahalanobis distances.

Examples

stack.lm <- lm(stack.loss ~ ., data = stackloss)

# Mahalanobis distance (not squared)
sqrt(designMD(stack.lm))

[Package fit.models version 0.5-14 Index]