Skip to contents

This function allows to add predictors to distribution or BiodiversityScenario objects. Predictors are covariates that in spatial projection have to match the geographic projection of the background layer in the distribution object. This function furthermore allows to transform or create derivates of provided predictors.

A transformation takes the provided rasters and for instance rescales them or transforms them through a principal component analysis (prcomp). In contrast, derivates leave the original provided predictors alone, but instead create new ones, for instance by transforming their values through a quadratic or hinge transformation. Note that this effectively increases the number of predictors in the object, generally requiring stronger regularization by the used Engine. Both transformations and derivates can also be combined. Available options for transformation are:

  • 'none' - Leaves the provided predictors in the original scale.

  • 'pca' - Converts the predictors to principal components. Note that this results in a renaming of the variables to principal component axes!

  • 'scale' - Transforms all predictors by applying scale on them.

  • 'norm' - Normalizes all predictors by transforming them to a scale from 0 to 1.

  • 'windsor' - Applies a windsorization to the target predictors. By default this effectively cuts the predictors to the 0.05 and 0.95, thus helping to remove extreme outliers.

Available options for creating derivates are:

  • 'none' - No additional predictor derivates are created.

  • 'quad' - Adds quadratic transformed predictors.

  • 'interaction' - Add interacting predictors. Interactions need to be specified ("int_variables")!

  • 'thresh' - Add threshold transformed predictors.

  • 'hinge' - Add hinge transformed predictors.

  • 'bin' - Add predictors binned by their percentiles.


  names = NULL,
  transform = "scale",
  derivates = "none",
  derivate_knots = 4,
  int_variables = NULL,
  bgmask = TRUE,
  harmonize_na = FALSE,
  explode_factors = FALSE,
  priors = NULL,

# S4 method for BiodiversityDistribution,SpatRasterCollection,ANY,character,character,numeric,ANY,logical,logical,logical,ANY

# S4 method for BiodiversityDistribution,SpatRaster,ANY,character,character,numeric,ANY,logical,logical,logical,ANY

# S4 method for BiodiversityDistribution,stars,ANY,character,character,numeric,ANY,logical,logical,logical,ANY

# S4 method for BiodiversityScenario,SpatRaster,ANY,character,character,numeric,ANY,logical

# S4 method for BiodiversityScenario,stars,ANY,character,character,numeric,ANY,logical



distribution() (i.e. BiodiversityDistribution) object.


A SpatRaster or stars object.


A vector of character names describing the environmental stack in case they should be renamed.


A vector stating whether predictors should be preprocessed in any way (Options: 'none','pca', 'scale', 'norm')


A Boolean check whether derivate features should be considered (Options: 'none', 'thresh', 'hinge', 'quad') )


A single numeric or vector giving the number of knots for derivate creation if relevant (Default: 4).


A vector with length greater or equal than 2 specifying the covariates (Default: NULL).


Check whether the environmental data should be masked with the background layer (Default: TRUE).


A logical value indicating of whether NA values should be harmonized among predictors (Default: FALSE).


logical of whether any factor variables should be split up into binary variables (one per class). (Default: FALSE).


A PriorList object. Default is set to NULL which uses default prior assumptions.


Other parameters passed down


Important: Not every Engine supported by the ibis.iSDM R-package allows missing data points among extracted covariates. Thus any observation with missing data is generally removed prior from model fitting. Thus ensure that covariates have appropriate no-data settings (for instance setting NA values to 0 or another out of range constant).

Not every engine does actually need covariates. For instance it is perfectly legit to fit a model with only occurrence data and a spatial latent effect (add_latent_spatial). This correspondents to a spatial kernel density estimate.

Certain names such "offset" are forbidden as predictor variable names. The function will return an error message if these are used.


if (FALSE) {
 obj <- distribution(background) |>
        add_predictors(covariates, transform = 'scale')