plot_moran {spatialRF} | R Documentation |
Plots a Moran's I test of model residuals
Description
Plots the results of spatial autocorrelation tests for a variety of functions within the package. The x axis represents the Moran's I estimate, the y axis contains the values of the distance thresholds, the dot sizes represent the p-values of the Moran's I estimate, and the red dashed line represents the theoretical null value of the Moran's I estimate.
Usage
plot_moran(
model,
point.color = viridis::viridis(
100,
option = "F",
direction = -1
),
line.color = "gray30",
option = 1,
ncol = 1,
verbose = TRUE
)
Arguments
model |
A model fitted with |
point.color |
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. |
line.color |
Character string, color of the line produced by |
option |
Integer, type of plot. If |
ncol |
Number of columns of the plot. Only relevant when |
verbose |
Logical, if |
Value
A ggplot.
See Also
moran()
, moran_multithreshold()
Examples
if(interactive()){
#loading example data
data(plant_richness_df)
data(distance.matrix)
#fitting a random forest model
rf.model <- rf(
data = plant_richness_df,
dependent.variable.name = "richness_species_vascular",
predictor.variable.names = colnames(plant_richness_df)[5:21],
distance.matrix = distance_matrix,
distance.thresholds = c(0, 1000, 2000),
n.cores = 1,
verbose = FALSE
)
#Incremental/multiscale Moran's I
plot_moran(rf.model)
#Moran's scatterplot
plot_moran(rf.model, option = 2)
}