Creates a matrix of (pairwise) cohesion values from a matrix of pairwise
distances or a dist
object.
Arguments
- d
A matrix of pairwise distances or a
dist
object.
Details
Computes the matrix of (pairwise) cohesion values, C_xw, from a matrix of
pairwise distances or a dist
object. Cohesion is an interpretable probability
that reflects the strength of alignment of a point, w
, to another point, x
.
The rows of the cohesion matrix can be seen as providing neighborhood
weights. These values may be used for defining associated weighted graphs
(for the purpose of community analysis) as in Berenhaut, Moore, and
Melvin (2022).
Given an n x n distance matrix, the sum of the entries in the resulting
cohesion matrix is always equal to n/2.
Cohesion is partitioned local depth (see local_depths
) and thus the row
sums of the cohesion matrix provide a measure of local depth centrality.
If you have a matrix that is already a cohesion matrix and you would like to
add the class, see as_cohesion_matrix()
.
References
K. S. Berenhaut, K. E. Moore, R. L. Melvin, A social perspective on perceived distances reveals deep community structure. Proc. Natl. Acad. Sci., 119(4), 2022.
Examples
plot(exdata1)
text(exdata1 + .08, lab = 1:8)
D <- dist(exdata1)
C <- cohesion_matrix(D)
C
#> 1 2 3 4 5 6 7
#> 1 0.16581633 0.11989796 0.11989796 0.01785714 0.01785714 0.00000000 0.00000000
#> 2 0.13061224 0.17653061 0.01785714 0.11989796 0.00000000 0.00000000 0.02040816
#> 3 0.11870748 0.02040816 0.16462585 0.10544218 0.03826531 0.01785714 0.00000000
#> 4 0.01785714 0.10425170 0.10425170 0.17874150 0.06207483 0.09540816 0.06207483
#> 5 0.01785714 0.00000000 0.03571429 0.05612245 0.18707483 0.12159864 0.07993197
#> 6 0.00000000 0.00000000 0.02040816 0.07653061 0.15986395 0.20748299 0.15986395
#> 7 0.00000000 0.01785714 0.00000000 0.05952381 0.07993197 0.12159864 0.18707483
#> 8 0.00000000 0.07993197 0.00000000 0.00000000 0.00000000 0.01785714 0.03571429
#> 8
#> 1 0.00000000
#> 2 0.07653061
#> 3 0.00000000
#> 4 0.00000000
#> 5 0.00000000
#> 6 0.01785714
#> 7 0.03571429
#> 8 0.15136054
#> attr(,"class")
#> [1] "cohesion_matrix" "matrix" "array"
## neighbor weights (provided by cohesion) for the 8th point in exdata1
C[8, ]
#> 1 2 3 4 5 6 7
#> 0.00000000 0.07993197 0.00000000 0.00000000 0.00000000 0.01785714 0.03571429
#> 8
#> 0.15136054
localdepths <- rowSums(C)