View source: R/get_response_curves.R
get_response_curves | R Documentation |
Generates and returns the data required to plot the response curves of a model 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 |
A model fitted with |
variables |
Character vector, names of predictors to plot. If |
quantiles |
Numeric vector with values between 0 and 1, argument |
grid.resolution |
Integer between 20 and 500. Resolution of the plotted curve Default: |
verbose |
Logical, if TRUE the plot is printed. Default: |
All variables that are not plotted in a particular response curve are set to the values of their respective quantiles, and the response curve for each one of these quantiles is shown in the plot.
A data frame with the following columns:
response
: Predicted values of the response, obtained with stats::predict()
.
predictor
: Values of the given predictor.
quantile
: Grouping column, values of the quantiles at which the other predictors are set to generate the response curve.
model
: Model number, only relevant if the model was produced with rf_repeat()
.
predictor.name
: Grouping variable, name of the predictor.
response.name
: Grouping variable, name of the response variable.
plot_response_curves()
if(interactive()){ #loading example data data(plant_richness_df) #fitting random forest model out <- 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 data frame with response curves p <- get_response_curves(out) head(p) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.