View source: R/rank_spatial_predictors.R
| rank_spatial_predictors | R Documentation |
Ranks spatial predictors generated by mem_multithreshold() or pca_multithreshold() by their effect in reducing the Moran's I of the model residuals (ranking.method = "effect"), or by their own Moran's I (ranking.method = "moran").
In the former case, one model of the type y ~ predictors + spatial_predictor_X is fitted per spatial predictor, and the Moran's I of this model's residuals is compared with the one of the model without spatial predictors (y ~ predictors), to finally rank the spatial predictor from maximum to minimum difference in Moran's I.
In the latter case, the spatial predictors are ordered by their Moran's I alone (this is the faster option).
In both cases, spatial predictors that are redundant with others at a Pearson correlation > 0.5 and spatial predictors with no effect (no reduction of Moran's I or Moran's I of the spatial predictor equal or lower than 0) are removed.
This function has been designed to be used internally by rf_spatial() rather than directly by a user.
rank_spatial_predictors(
data = NULL,
dependent.variable.name = NULL,
predictor.variable.names = NULL,
distance.matrix = NULL,
distance.thresholds = NULL,
ranger.arguments = NULL,
spatial.predictors.df = NULL,
ranking.method = c("moran", "effect"),
reference.moran.i = 1,
verbose = FALSE,
n.cores = parallel::detectCores() - 1,
cluster = NULL
)
data |
Data frame with a response variable and a set of predictors. Default: |
dependent.variable.name |
Character string with the name of the response variable. Must be in the column names of |
predictor.variable.names |
Character vector with the names of the predictive variables. Every element of this vector must be in the column names of |
distance.matrix |
Squared matrix with the distances among the records in |
distance.thresholds |
Numeric vector with neighborhood distances. All distances in the distance matrix below each value in |
ranger.arguments |
List with ranger arguments. See rf or rf_repeat for further details. |
spatial.predictors.df |
Data frame of spatial predictors. |
ranking.method |
Character, method used by to rank spatial predictors. The method "effect" ranks spatial predictors according how much each predictor reduces Moran's I of the model residuals, while the method "moran" ranks them by their own Moran's I. Default: |
reference.moran.i |
Moran's I of the residuals of the model without spatial predictors. Default: |
verbose |
Logical, ff |
n.cores |
Integer, number of cores to use for parallel execution. Creates a socket cluster with |
cluster |
A cluster definition generated with |
A list with four slots:
method: Character, name of the method used to rank the spatial predictors.
criteria: Data frame with two different configurations depending on the ranking method. If ranking.method = "effect", the columns contain the names of the spatial predictors, the r-squared of the model, the Moran's I of the model residuals, the difference between the Moran's I of the model including the given spatial predictor, and the Moran's I of the model fitted without spatial predictors, and the interpretation of the Moran's I value. If ranking.method = "moran", only the name of the spatial predictor and it's Moran's I are in the output data frame.
ranking: Ordered character vector with the names of the spatial predictors selected.
spatial.predictors.df: data frame with the selected spatial predictors in the order of the ranking.
Other spatial_analysis:
filter_spatial_predictors(),
mem(),
mem_multithreshold(),
moran(),
moran_multithreshold(),
pca(),
pca_multithreshold(),
residuals_diagnostics(),
residuals_test(),
select_spatial_predictors_recursive(),
select_spatial_predictors_sequential()
if(interactive()){
data(
plants_df,
plants_response,
plants_distance
)
#subset to speed up example
idx <- 50:90
plants_distance_sub <- plants_distance[idx, idx]
y <- mem(
distance.matrix = plants_distance_sub,
distance.threshold = 1000
)
#rank spatial predictors by Moran's I
y_rank <- rank_spatial_predictors(
distance.matrix = plants_distance_sub,
distance.thresholds = 1000,
spatial.predictors.df = y,
ranking.method = "moran",
n.cores = 1
)
y_rank$criteria
y_rank$ranking
#rank spatial predictors by association with response
y_rank <- rank_spatial_predictors(
data = plants_df[idx, ],
dependent.variable.name = plants_response,
distance.matrix = plants_distance_sub,
distance.thresholds = 1000,
spatial.predictors.df = y,
ranking.method = "effect",
n.cores = 1
)
y_rank$criteria
y_rank$ranking
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.