Plots the response curves of models fitted with `rf()`

, `rf_repeat()`

, or `rf_spatial()`

.

plot_response_curves( model = NULL, variables = NULL, quantiles = c(0.1, 0.5, 0.9), grid.resolution = 200, line.color = viridis::viridis(length(quantiles), option = "F", end = 0.9), ncol = 2, show.data = FALSE, 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: |

line.color | Character vector with colors, or function to generate colors for the lines representing |

ncol | Integer, argument of wrap_plots. Defaults to the rounded squared root of the number of plots. Default: |

show.data | Logical, if |

verbose | Logical, if TRUE the plot is printed. Default: |

A list with slots named after the selected `variables`

, with one ggplot each.

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. When the input model was fitted with `rf_repeat()`

with `keep.models = TRUE`

, then the plot shows the median of all model runs, and each model run separately as a thinner line. The output list can be plotted all at once with `patchwork::wrap_plots(p)`

or `cowplot::plot_grid(plotlist = p)`

, or one by one by extracting each plot from the list.

if(interactive()){ #loading example data data(plant_richness_df) #fitting a random forest model m <- 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 ) #response curves of most important predictors plot_response_curves(model = m) }