R/plot_optimization.R
plot_optimization.Rd
Plots optimization data frames produced by select_spatial_predictors_sequential()
and select_spatial_predictors_recursive()
.
plot_optimization(
model,
point.color = viridis::viridis(
100,
option = "F",
direction = -1
),
verbose = TRUE
)
A model produced by rf_spatial()
, or an optimization data frame produced by select_spatial_predictors_sequential()
or select_spatial_predictors_recursive()
.
Colors of the plotted points. Can be a single color name (e.g. "red4"), a character vector with hexadecimal codes (e.g. "#440154FF" "#21908CFF" "#FDE725FF"), or function generating a palette (e.g. viridis::viridis(100)
). Default: viridis::viridis(100, option = "F", direction = -1)
Logical, if TRUE
the plot is printed. Default: TRUE
A ggplot.
If the method used to fit a model with rf_spatial()
is "hengl", the function returns nothing, as this method does not require optimization.
if(interactive()){
#loading example data
data(distance_matrix)
data(plant_richness_df)
#names of the response and predictors
dependent.variable.name <- "richness_species_vascular"
predictor.variable.names <- colnames(plant_richness_df)[5:21]
#spatial model
model <- rf_spatial(
data = plant_richness_df,
dependent.variable.name = dependent.variable.name,
predictor.variable.names = predictor.variable.names,
distance.matrix = distance_matrix,
distance.thresholds = 0,
method = "mem.moran.sequential",
n.cores = 1,
seed = 1
)
#plotting selection of spatial predictors
plot_optimization(model = model)
}