View source: R/response_curves.R
| response_curve | R Documentation |
Plot variable responses for fitted models. Responses based on single or multiple models can be plotted.
# Single variable response curves
response_curve(models, variable, modelID = NULL, n = 100,
show_variability = FALSE, show_lines = FALSE, data = NULL,
new_data = NULL, averages_from = "pr_bg", extrapolate = TRUE,
extrapolation_factor = 0.1, add_points = FALSE, p_col = NULL,
l_limit = NULL, u_limit = NULL, xlab = NULL,
ylab = "Suitability", col = "darkblue", ...)
# Response curves for all variables in all or individual models
all_response_curves(models, modelID = NULL, n = 100, show_variability = FALSE,
show_lines = FALSE, data = NULL, new_data = NULL,
averages_from = "pr_bg", extrapolate = TRUE,
extrapolation_factor = 0.1, add_points = FALSE,
p_col = NULL, l_limit = NULL, u_limit = NULL,
xlab = NULL, ylab = "Suitability", col = "darkblue",
ylim = NULL, mfrow = NULL, ...)
models |
an object of class |
variable |
(character) name of the variable to be plotted. |
modelID |
(character) ModelID(s) to be considered. By default all IDs
in |
n |
(numeric) an integer guiding the number of breaks to produce the curve. Default = 100. |
show_variability |
(logical) if |
show_lines |
(logical) whether to show variability by plotting lines for
all models or replicates. The default = FALSE, uses a GAM to characterize a
median trend and variation among modes or replicates. Ignored if
|
data |
data.frame or matrix of data used in the model calibration step.
The default, NULL, uses data stored in |
new_data |
a |
averages_from |
(character) specifies how the averages or modes of the other variables are calculated when producing responses for the variable of interest. Options are "pr" (from the presences) or "pr_bg" (from presences and background). Default is "pr_bg". See details. |
extrapolate |
(logical) whether to allow extrapolation of the response
outside training conditions. Ignored if |
extrapolation_factor |
(numeric) a value used to calculate how much to expand the training region for extrapolation. Larger values produce extrapolation farther from training limits. Default = 0.1. |
add_points |
(logical) if |
p_col |
(character) color for the observed points when
|
l_limit |
(numeric) directly specifies the lower limit for the variable.
Default = NULL, meaning the lower limit will be calculated from existing data.
(if |
u_limit |
(numeric) directly specifies the upper limit for the variable.
Default = NULL, meaning the upper limit will be calculated from existing data.
(if |
xlab |
(character) a label for the x axis. The default, NULL, uses the
name defined in |
ylab |
(character) a label for the y axis. Default = "Suitability". |
col |
(character) color for lines. Default = "darkblue". |
... |
additional arguments passed to |
ylim |
(numeric) vector of length two with limits for the y axis.
Directly used in |
mfrow |
(numeric) a vector specifying the number of rows and columns in the plot layout, e.g., c(rows, columns). Default is NULL, meaning the grid will be arranged automatically based on the number of plots. |
The response curve for a variable of interest is generated with all other variables set to their mean values (or mode for categorical variables), calculated either from the presence records (if averages_from = "pr") or the combined set of presence and background records (if averages_from = "pr_bg").
For categorical variables, a bar plot is generated with error bars showing variability across models (if multiple models are included).
For response_curve(), a plot with the response curve for a variable. For
all_response_curves(), a multipanel plot with response curves fro all
variables in models.
bivariate_response(), partition_response_curves()
# Example with maxnet
# Import example of fitted_models (output of fit_selected())
data(fitted_model_maxnet, package = "kuenm2")
# Response curves for one variable at a time
response_curve(models = fitted_model_maxnet, variable = "bio_1")
response_curve(models = fitted_model_maxnet, variable = "bio_1",
add_points = TRUE)
response_curve(models = fitted_model_maxnet, variable = "bio_1",
show_lines = TRUE)
response_curve(models = fitted_model_maxnet, variable = "bio_1",
modelID = "Model_192", show_variability = TRUE)
response_curve(models = fitted_model_maxnet, variable = "bio_1",
modelID = "Model_192", show_variability = TRUE,
show_lines = TRUE)
# Example with maxnet
# Import example of fitted_models (output of fit_selected())
data(fitted_model_maxnet, package = "kuenm2")
# Response curves for all variables at once
all_response_curves(fitted_model_maxnet)
all_response_curves(fitted_model_maxnet, show_lines = TRUE)
all_response_curves(fitted_model_maxnet, show_lines = TRUE,
add_points = TRUE)
all_response_curves(fitted_model_maxnet, modelID = "Model_192",
show_variability = TRUE, show_lines = TRUE)
all_response_curves(fitted_model_maxnet, modelID = "Model_192",
show_variability = TRUE, show_lines = TRUE,
add_points = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.