double_center_distance_matrix: Double-center a distance matrix

View source: R/double_center_distance_matrix.R

double_center_distance_matrixR Documentation

Double-center a distance matrix

Description

Double-centers a distance matrix by converting it to weights and centering to zero row and column means. Required for computing Moran's Eigenvector Maps.

Usage

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

Arguments

distance.matrix

Numeric distance matrix. Default: NULL.

distance.threshold

Numeric distance threshold for weight calculation. Distances above this threshold are set to 0 during weighting. Default: 0.

Details

Double-centering is performed in two steps:

  1. Convert distances to weights using weights_from_distance_matrix()

  2. Center the matrix: subtract row means, subtract column means, and add the grand mean

The resulting matrix is symmetric with zero row and column means, suitable for Moran's Eigenvector Maps computation.

Value

Double-centered numeric matrix with the same dimensions as distance.matrix. The matrix has row means and column means of zero.

See Also

weights_from_distance_matrix(), mem(), mem_multithreshold()

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

Examples

data(plants_distance)

# Double-center the distance matrix
centered <- double_center_distance_matrix(
  distance.matrix = plants_distance
)

# Verify row means are zero
head(rowMeans(centered))

# Verify column means are zero
head(colMeans(centered))


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