| centering distance matrices | R Documentation |
Stand-alone double centering and U-centering functions that are applied in unbiased distance covariance, bias corrected distance correlation, and partial distance correlation.
Dcenter(x)
Ucenter(x)
U_center(Dx)
D_center(Dx)
x |
dist object or data matrix |
Dx |
distance or dissimilarity matrix |
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.
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.
The c++ versions D_center and U_center should typically
be faster. R versions are retained for historical reasons.
Maria L. Rizzo mrizzo@bgsu.edu and Gabor J. Szekely
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.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.