R/pca_multithreshold.R
pca_multithreshold.Rd
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
)
Distance matrix. Default: NULL
Numeric vector with distance thresholds defining neighborhood in the distance matrix, Default: 0
Integer, maximum number of spatial predictors to generate. Only useful when the distance matrix x
is very large. Default: NULL
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.
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.
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)
}