Skip to contents

Similar as partial this function calculates a partial response of a trained model for a given variable. Differently from partial in space. However the result is a SpatRaster showing the spatial magnitude of the partial response.

Usage

spartial(mod, x.var, constant = NULL, newdata = NULL, plot = FALSE, ...)

# S4 method for class 'ANY,character'
spartial(mod, x.var, constant = NULL, newdata = NULL, plot = FALSE, ...)

spartial.DistributionModel(mod, ...)

Arguments

mod

A DistributionModel object with trained model.

x.var

A character indicating the variable for which a partial effect is to be calculated.

constant

A numeric constant to be inserted for all other variables. Default calculates the mean per variable.

newdata

A data.frame on which to calculate the spartial for. Can be for example created from a raster file (Default: NULL).

plot

A logical indication of whether the result is to be plotted?

...

Other engine specific parameters.

Value

A SpatRaster containing the mapped partial response of the variable.

Details

By default the mean is calculated across all parameters that are not x.var. Instead a constant can be set (for instance 0) to be applied to the output.

See also

Examples

if (FALSE) { # \dontrun{
 # Create and visualize the spartial effect
 spartial(fit, x.var = "Forest.cover", plot = TRUE)
} # }