Learn R Programming

spatialRF (version 1.1.5)

mem_multithreshold: Compute Moran's Eigenvector Maps across multiple distance thresholds

Description

Computes Moran's Eigenvector Maps (MEMs) using mem() at multiple distance thresholds and combines them into a single data frame. This creates spatial predictors capturing patterns at different spatial scales.

Usage

mem_multithreshold(
  distance.matrix = NULL,
  distance.thresholds = NULL,
  max.spatial.predictors = NULL
)

Value

Data frame with one row per observation (matching distance.matrix dimensions) and columns representing MEMs at different distance thresholds. Column names follow the pattern spatial_predictor_<threshold>_<number> (e.g., "spatial_predictor_0_1", "spatial_predictor_1000_2").

Arguments

distance.matrix

Numeric distance matrix between spatial locations.

distance.thresholds

Numeric vector of distance thresholds. Each threshold defines the maximum distance for spatial neighbors at that scale. Default: NULL (automatically computed with default_distance_thresholds()).

max.spatial.predictors

Integer specifying the maximum number of spatial predictors to return. If the total number of MEMs exceeds this value, only the first max.spatial.predictors columns are returned. Default: NULL (no limit).

Details

This function generates spatial predictors at multiple spatial scales by computing MEMs at different distance thresholds. Different thresholds capture spatial patterns at different scales:

  • Smaller thresholds (e.g., 0) capture fine-scale spatial patterns

  • Larger thresholds capture broad-scale spatial patterns

Algorithm:

  1. For each distance threshold, calls mem() to compute MEMs

  2. Each mem() call applies the threshold, double-centers the matrix, and extracts positive eigenvectors

  3. Combines all MEMs into a single data frame

  4. Optionally limits the total number of predictors with max.spatial.predictors

The resulting MEMs are used as spatial predictors in rf_spatial() to model spatial autocorrelation at multiple scales simultaneously.

See Also

mem(), rf_spatial(), default_distance_thresholds(), double_center_distance_matrix()

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

Examples

Run this code
data(plants_distance)

# Compute MEMs for multiple distance thresholds
mems <- mem_multithreshold(
  distance.matrix = plants_distance,
  distance.thresholds = c(0, 1000, 5000)
)

# View structure
head(mems)
dim(mems)

# Check column names showing threshold and predictor number
colnames(mems)[1:6]

# Limit number of spatial predictors
mems_limited <- mem_multithreshold(
  distance.matrix = plants_distance,
  distance.thresholds = c(0, 1000, 5000),
  max.spatial.predictors = 20
)
dim(mems_limited)

Run the code above in your browser using DataLab