mem: Compute Moran's Eigenvector Maps from distance matrix

View source: R/mem.R

memR Documentation

Compute Moran's Eigenvector Maps from distance matrix

Description

Computes Moran's Eigenvector Maps (MEMs) from a distance matrix. Returns only eigenvectors with positive spatial autocorrelation, which capture broad to medium-scale spatial patterns.

Usage

mem(distance.matrix = NULL, distance.threshold = 0, colnames.prefix = "mem")

Arguments

distance.matrix

Numeric distance matrix between spatial locations.

distance.threshold

Numeric value specifying the maximum distance for spatial neighbors. Distances above this threshold are set to zero. Default: 0 (no thresholding).

colnames.prefix

Character string used as prefix for column names in the output. Default: "mem".

Details

Moran's Eigenvector Maps (MEMs) are spatial variables that represent spatial structures at different scales. The function creates MEMs through the following steps:

  1. Double-centers the distance matrix using double_center_distance_matrix()

  2. Computes eigenvectors and eigenvalues using base::eigen()

  3. Normalizes eigenvalues by dividing by the maximum absolute eigenvalue

  4. Selects only eigenvectors with positive normalized eigenvalues

Positive vs. negative eigenvalues:

Eigenvectors with positive eigenvalues represent positive spatial autocorrelation (nearby locations are similar), capturing broad to medium-scale spatial patterns. Eigenvectors with negative eigenvalues represent negative spatial autocorrelation (nearby locations are dissimilar) and are excluded. The returned MEMs are ordered by eigenvalue magnitude, with the first columns capturing the broadest spatial patterns.

These MEMs are used as spatial predictors in rf_spatial() to account for spatial autocorrelation in model residuals.

Value

Data frame where each column is a MEM (spatial predictor) representing a different scale of spatial pattern. Columns are named with the pattern ⁠<prefix>_<number>⁠ (e.g., "mem_1", "mem_2").

See Also

mem_multithreshold(), rf_spatial(), double_center_distance_matrix()

Other spatial_analysis: filter_spatial_predictors(), mem_multithreshold(), moran(), moran_multithreshold(), pca(), pca_multithreshold(), rank_spatial_predictors(), residuals_diagnostics(), residuals_test(), select_spatial_predictors_recursive(), select_spatial_predictors_sequential()

Examples

data(plants_distance)

# Compute MEMs from distance matrix
mems <- mem(distance.matrix = plants_distance)

# View structure
head(mems)
dim(mems)

# Check column names
colnames(mems)[1:5]


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

Related to mem in spatialRF...