View source: R/filter_spatial_predictors.R
| filter_spatial_predictors | R Documentation |
Removes spatial predictors that are highly correlated with other spatial predictors or with non-spatial predictors. Particularly useful when using multiple distance thresholds that produce correlated spatial predictors.
filter_spatial_predictors(
data = NULL,
predictor.variable.names = NULL,
spatial.predictors.df = NULL,
cor.threshold = 0.5
)
data |
Data frame containing the predictor variables. Default: |
predictor.variable.names |
Character vector of non-spatial predictor names. Must match column names in |
spatial.predictors.df |
Data frame of spatial predictors (e.g., from |
cor.threshold |
Numeric between 0 and 1 (recommended: 0.5 to 0.75). Maximum allowed absolute Pearson correlation. Default: |
Filtering is performed in two steps:
Remove spatial predictors correlated with each other (using auto_cor())
Remove spatial predictors correlated with non-spatial predictors
This two-step process ensures the retained spatial predictors are independent of both each other and the environmental predictors, improving model interpretability and reducing multicollinearity.
Data frame containing only spatial predictors with correlations below cor.threshold (both among themselves and with non-spatial predictors).
Other spatial_analysis:
mem(),
mem_multithreshold(),
moran(),
moran_multithreshold(),
pca(),
pca_multithreshold(),
rank_spatial_predictors(),
residuals_diagnostics(),
residuals_test(),
select_spatial_predictors_recursive(),
select_spatial_predictors_sequential()
data(
plants_df,
plants_predictors,
plants_distance
)
# Generate spatial predictors using multiple distance thresholds
mem.df <- mem_multithreshold(
distance.matrix = plants_distance,
distance.thresholds = c(0, 1000)
)
# Filter spatial predictors to remove redundancy
# Removes spatial predictors correlated > 0.50 with each other
# or with environmental predictors
spatial.predictors.filtered <- filter_spatial_predictors(
data = plants_df,
predictor.variable.names = plants_predictors,
spatial.predictors.df = mem.df,
cor.threshold = 0.50
)
# Check dimensions
ncol(mem.df) # original number
ncol(spatial.predictors.filtered) # after filtering
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.