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,]  1.3231288 -0.5204252  1.648349 -1.587743 -0.8633090
#> [2,] -0.5204252  4.3874354 -1.569852 -2.581674  0.2845156
#> [3,]  1.6483487 -1.5698519  3.369757 -1.396211 -2.0520424
#> [4,] -1.5877433 -2.5816740 -1.396211  4.474316  1.0913125
#> [5,] -0.8633090  0.2845156 -2.052042  1.091313  1.5395232