Returns the residuals of models fitted with rf(), rf_repeat(), or rf_spatial().
get_residuals(model)A model fitted with rf(), rf_repeat(), or rf_spatial().
A vector with model residuals, or the median of model residuals across repetitions if the model was fitted with rf_repeat().
if(interactive()){
#load example data
data(plant_richness_df)
#fit 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],
n.cores = 1,
verbose = FALSE
)
#getting vector with residuals
x <- get_residuals(rf.model)
x
}