get_response_curves {spatialRF} | R Documentation |
Gets data to allow custom plotting of response curves
Description
Generates and returns the data required to plot the response curves of a model fitted with rf()
, rf_repeat()
, or rf_spatial()
.
Usage
get_response_curves(
model = NULL,
variables = NULL,
quantiles = c(0.1, 0.5, 0.9),
grid.resolution = 200,
verbose = TRUE
)
Arguments
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: |
Details
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.
Value
A data frame with the following columns:
-
response
: Predicted values of the response, obtained withstats::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 withrf_repeat()
. -
predictor.name
: Grouping variable, name of the predictor. -
response.name
: Grouping variable, name of the response variable.
See Also
Examples
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)
}