Learn R Programming

blockingChallenge (version 1.0)

smahal: Calculates robust, rank based, Mahalanobis distance matrix.

Description

This is a variation of a common function in the literature of matching. It takes as input a numeric data matrix of n rows and outputs a n by n matrix of pairwise distance of points. The distances satisfy triangle inequality.

Usage

smahal(X)

Arguments

X

A numeric data matrix.

Value

A n by n matrix of pairwise distances of the units.

Details

A call to this function will create a distance matrix which can be used as an input of the main function makeblocks. For more specialized use see the examples of makeblocks.

The robust Mahalanobis distance uses ranks of covariates rather than the covariates themselves, but the variances of the ranks are not adjusted for ties, so ties do not make a variable more important.

The returned matrix is the (entry wise) squared root of the rank based Mahalanobis distance matrix.

Any positive linear combination of outputs of multiple calls to this function gives a valid distance matrix.

References

Rosenbaum, P. R. (2010). Design of Observational Studies. New York: Springer.

Examples

Run this code
# NOT RUN {
# See examples of 'makeblocks'.
# }

Run the code above in your browser using DataLab