View source: R/get_response_curves.R
| get_response_curves | R Documentation |
Extracts data for plotting partial dependence (response) curves showing how predictions vary with each predictor from models fitted with rf(), rf_repeat(), or rf_spatial().
get_response_curves(
model = NULL,
variables = NULL,
quantiles = c(0.1, 0.5, 0.9),
grid.resolution = 200,
verbose = TRUE
)
model |
Model object from |
variables |
Character vector of predictor names to plot. If |
quantiles |
Numeric vector of quantiles (0 to 1) at which to fix non-plotted predictors. Multiple quantiles show response variation under different scenarios. Default: |
grid.resolution |
Integer (20 to 500) specifying the number of points along the predictor axis. Higher values produce smoother curves. Default: |
verbose |
Logical. If |
Response curves (also called partial dependence plots) show how predicted values change as a focal predictor varies while holding other predictors constant at specified quantile values. This reveals the marginal effect of each predictor.
The function generates curves by:
Creating a grid of values for the focal predictor
Fixing non-plotted predictors at each quantile (e.g., 0.1, 0.5, 0.9)
Predicting responses across the grid
Repeating for each selected predictor and quantile combination
Multiple quantiles reveal whether the effect of a predictor is consistent across different environmental contexts (parallel curves) or varies depending on other conditions (non-parallel curves).
Data frame with the following columns:
response: Predicted response values.
predictor: Predictor values along the gradient.
quantile: Factor indicating which quantile was used to fix other predictors.
model: Model index (only for rf_repeat() models with multiple repetitions).
predictor.name: Character name of the focal predictor.
response.name: Character name of the response variable.
rf(), rf_repeat(), rf_spatial(), plot_response_curves(), get_importance()
Other model_info:
get_evaluation(),
get_importance(),
get_importance_local(),
get_moran(),
get_performance(),
get_predictions(),
get_residuals(),
get_spatial_predictors(),
print.rf(),
print_evaluation(),
print_importance(),
print_moran(),
print_performance()
data(plants_rf)
# Extract response curve data for plotting
curves <- get_response_curves(
model = plants_rf,
variables = NULL, # auto-select important variables
quantiles = c(0.1, 0.5, 0.9)
)
# View structure
head(curves)
str(curves)
# Check unique predictors included
unique(curves$predictor.name)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.