Learn R Programming

energy (version 1.7-12)

centering distance matrices: Double centering and U-centering

Description

Stand-alone double centering and U-centering functions that are applied in unbiased distance covariance, bias corrected distance correlation, and partial distance correlation.

Usage

Dcenter(x)
Ucenter(x)
U_center(Dx)
D_center(Dx)

Value

All functions return a square symmetric matrix.

Dcenter returns a matrix

$$A_{ij}=a_{ij} - \bar a_{i.} - \bar a_{.j} + \bar a_{..}$$

as in classical multidimensional scaling. Ucenter

returns a matrix

$$\tilde A_{ij}=a_{ij} - \frac{a_{i.}}{n-2} - \frac{a_{.j}}{n-2} + \frac{a_{..}}{(n-1)(n-2)},\quad i \neq j,$$

with zero diagonal, and this is the double centering applied in pdcov and

pdcor as well as the unbiased dCov and bias corrected dCor statistics.

Arguments

x

dist object or data matrix

Dx

distance or dissimilarity matrix

Author

Maria L. Rizzo mrizzo@bgsu.edu and Gabor J. Szekely

Details

In Dcenter and Ucenter, x must be a dist object or a data matrix. Both functions return a doubly centered distance matrix.

Note that pdcor, etc. functions include the centering operations (in C), so that these stand alone versions of centering functions are not needed except in case one wants to compute just a double-centered or U-centered matrix.

U_center is the Rcpp export of the cpp function. D_center is the Rcpp export of the cpp function.

References

Szekely, G.J. and Rizzo, M.L. (2014), Partial Distance Correlation with Methods for Dissimilarities, Annals of Statistics, Vol. 42, No. 6, pp. 2382-2412.

Examples

Run this code
 x <- iris[1:10, 1:4]
 dx <- dist(x)
 Dx <- as.matrix(dx)
 M <- U_center(Dx)

 all.equal(M, U_center(M))     #idempotence
 all.equal(M, D_center(M))     #invariance

Run the code above in your browser using DataLab