weights_from_distance_matrix: Transforms a distance matrix into a matrix of weights

View source: R/weights_from_distance_matrix.R

weights_from_distance_matrixR Documentation

Transforms a distance matrix into a matrix of weights

Description

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.

Usage

weights_from_distance_matrix(
  distance.matrix = NULL,
  distance.threshold = 0
)

Arguments

distance.matrix

Distance matrix. Default: NULL.

distance.threshold

Numeric, positive, in the range of values of distance.matrix. Distances below this value in the distance matrix are set to 0., Default: 0.

Value

A weighted distance matrix.

See Also

Other preprocessing: auto_cor(), auto_vif(), case_weights(), default_distance_thresholds(), double_center_distance_matrix(), is_binary(), make_spatial_fold(), make_spatial_folds(), the_feature_engineer()

Examples


data(plants_distance)

y <- weights_from_distance_matrix(
  distance.matrix = plants_distance
)

y[1:5, 1:5]


spatialRF documentation built on Dec. 20, 2025, 1:07 a.m.