Learn R Programming

spatialRF (version 1.1.5)

double_center_distance_matrix: 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)

Value

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

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.

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

Run this code
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))

Run the code above in your browser using DataLab