Computes PCA factors of a distance matrix over different distance thresholds to generate spatial predictors for a model fitted with rf_spatial().

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

Arguments

distance.matrix

Distance matrix. Default: NULL

distance.thresholds

Numeric vector with distance thresholds defining neighborhood in the distance matrix, Default: 0

max.spatial.predictors

Integer, maximum number of spatial predictors to generate. Only useful when the distance matrix x is very large. Default: NULL

Value

A data frame with the PCA factors of the thresholded matrix. The data frame columns are named "spatial_predictor_DISTANCE_COLUMN", where DISTANCE is the given distance threshold, and COLUMN is the column index of the given predictor.

Details

The distance matrix is converted into weights with weights_from_distance_matrix() before computing the PCA. This produces more meaningful spatial predictors than using the distance matrix as is.

See also

Examples

if(interactive()){

 #loading example distance matrix
 load(distance_matrix)

 #PCA factors of the distance matrix for two reference distances
 x <- pca_multithreshold(
   distance.matrix = distance_matrix,
   distance.thresholds = c(0, 1000)
   )
 head(x)

}