Skip to contents

tda_mcent subtracts each column's mean – TDA's mcent, matching sweep(A, 2, colMeans(A)). tda_mstand additionally divides each column by its population standard deviation (denominator n, not base R's sd()'s n-1) – TDA's mstand. tda_mdcent double-centers a symmetric matrix – TDA's mdcent, the classical (Torgerson) transformation multidimensional scaling uses to turn a matrix of squared distances into one whose eigendecomposition gives point coordinates.

Usage

tda_mcent(A, dir = tempfile("tda"))

tda_mstand(A, dir = tempfile("tda"))

tda_mdcent(D, dir = tempfile("tda"))

Arguments

A, D

a numeric matrix (D, for tda_mdcent, should be symmetric – typically a distance matrix).

dir

working directory.

Value

A numeric matrix.

Examples

A <- matrix(c(1, 2, 6, 10, 30, 20), 3, 2)
tda_mcent(A)
#>      [,1] [,2]
#> [1,]   -2  -10
#> [2,]   -1   10
#> [3,]    3    0
tda_mstand(A)
#>            [,1]      [,2]
#> [1,] -0.9258201 -1.224745
#> [2,] -0.4629100  1.224745
#> [3,]  1.3887301  0.000000
D <- matrix(c(0, 3, 4, 3, 0, 5, 4, 5, 0), 3, 3)
tda_mdcent(D)
#>            [,1]       [,2]      [,3]
#> [1,]  2.7777778 -0.2222222 -2.555556
#> [2,] -0.2222222  5.7777778 -5.555556
#> [3,] -2.5555556 -5.5555556  8.111111