response_curve {enmpa}R Documentation

Variable response curves for GLMs

Description

A view of variable responses in models. Responses based on single or multiple models can be provided.

Usage

response_curve(fitted, variable, n = 100, new_data = NULL, extrapolate = TRUE,
               xlab = NULL, ylab = "Probability", col = "red", ...)

Arguments

fitted

an object of class glm or a list of GLMs obtained using the functions fit_selected or fit_glms.

variable

(character) name of the variables to be plotted.

n

(numeric) an integer guiding the number of breaks. Default = 100

new_data

a SpatRaster, data.frame, or matrix of variables representing the range of variable values in an area of interest. Default = NULL.

extrapolate

(logical) whether to allow extrapolation to study the behavior of the response outside the calibration limits. Ignored if new_data is defined. Default = TRUE.

xlab

(character) a label for the x axis. The default, NULL, uses the name defined in variable.

ylab

(character) a label for the y axis. Default = "Probability".

col

(character) color for lines. Default = "red".

...

additional arguments passed to plot.

Details

The function calculates these probabilities by focusing on a single environmental variable while keeping all other variables constant at their mean values.

When responses for multiple models are to be plotted, the mean and confidence intervals for the set of responses are calculated using a GAM.

Value

A plot with the response curve for a variable.

Examples

# Load a fitted selected model
data(sel_fit, package = "enmpa")

# Response curve for single models
response_curve(sel_fit$ModelID_7, variable = "bio_1")

# Response curve when model(s) are in a list (only one model in this one)
response_curve(sel_fit, variable = "bio_12")

[Package enmpa version 0.1.5 Index]