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

set.seed(1)
morie_spatial_voting_double_centering(as.matrix(dist(matrix(rnorm(20), 5))))
#>           [,1]       [,2]       [,3]       [,4]       [,5]
#> [1,]  3.910487  0.3805910 -1.0632038 -5.0313276  1.8034537
#> [2,]  0.380591  0.4771192 -0.3022715 -0.7294745  0.1740358
#> [3,] -1.063204 -0.3022715  1.9641431  0.5118082 -1.1104761
#> [4,] -5.031328 -0.7294745  0.5118082  7.5493612 -2.3003673
#> [5,]  1.803454  0.1740358 -1.1104761 -2.3003673  1.4333539