Skip to contents

Computes \(B = -\tfrac{1}{2} H D^{(2)} H\) with \(H = I - n^{-1}\mathbf{1}\mathbf{1}'\).

Usage

morie_spatial_voting_double_centering(D)

Arguments

D

Symmetric numeric distance matrix.

Value

The double-centered matrix \(B\).

References

Torgerson (1952); Armstrong et al. (2021), Section 3.

Examples

morie_spatial_voting_double_centering(as.matrix(dist(matrix(rnorm(20), 5))))
#>            [,1]       [,2]          [,3]          [,4]       [,5]
#> [1,]  6.5325502 -0.2495124 -3.1983485792  0.1790657085 -3.2637549
#> [2,] -0.2495124  3.3580525 -2.2612709429 -0.1143007217 -0.7329684
#> [3,] -3.1983486 -2.2612709  3.2636363972 -0.0003584998  2.1963416
#> [4,]  0.1790657 -0.1143007 -0.0003584998  2.5202873609 -2.5846938
#> [5,] -3.2637549 -0.7329684  2.1963416247 -2.5846938478  4.3850756