R/weights_from_distance_matrix.R
weights_from_distance_matrix.Rd
Transforms a distance matrix into weights (1/distance.matrix) normalized by the row sums. Used to compute Moran's I values and Moran's Eigenvector Maps. Allows to apply a threshold to the distance matrix before computing the weights.
weights_from_distance_matrix(
distance.matrix = NULL,
distance.threshold = 0
)
Distance matrix. Default: NULL
.
Numeric, positive, in the range of values of distance.matrix
. Distances below this value in the distance matrix are set to 0., Default: 0
.
A weighted distance matrix.
if(interactive()){
#loading example distance matrix
data(distance_matrix)
#computing matrix of weights
distance.matrix.weights <- weights_from_distance_matrix(
distance.matrix = distance_matrix
)
distance.matrix.weights
}