View source: R/get_residuals.R
| get_residuals | R Documentation |
Extracts residuals (observed - predicted values) from models fitted with rf(), rf_repeat(), or rf_spatial().
get_residuals(model)
model |
Model object from |
Residuals are calculated as observed minus predicted values. They can be used to assess model fit, check assumptions, and diagnose patterns such as spatial autocorrelation (see get_moran()). Ideally, residuals should be randomly distributed with no systematic patterns.
Numeric vector of residuals with length equal to the number of training observations. For rf_repeat() models, returns the median residual across repetitions.
rf(), rf_repeat(), rf_spatial(), get_predictions(), get_moran(), plot_residuals_diagnostics()
Other model_info:
get_evaluation(),
get_importance(),
get_importance_local(),
get_moran(),
get_performance(),
get_predictions(),
get_response_curves(),
get_spatial_predictors(),
print.rf(),
print_evaluation(),
print_importance(),
print_moran(),
print_performance()
data(plants_rf)
# Extract residuals
residuals <- get_residuals(plants_rf)
head(residuals)
# Check basic statistics
summary(residuals)
# Plot distribution to check for patterns
hist(residuals, main = "Residual Distribution", xlab = "Residuals")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.