Learn R Programming

MIAmaxent (version 1.3.1)

projectModel: Project model across explanatory data.

Description

projectModel calculates model predictions for any points where values of the explanatory variables in the model are known. It can be used to get model predictions for the training data, or to project the model to a new space or time.

Usage

projectModel(
  model,
  transformations,
  data,
  clamping = FALSE,
  raw = FALSE,
  rescale = FALSE,
  filename = NULL
)

Value

List of 2:

  1. output: A data frame with the model output in column 1 and the corresponding explanatory data in subsequent columns, or a raster containing predictions if data is a SpatRaster.

  2. ranges: A list showing the range of data compared to the training data, on a 0-1 scale.

If data is a SpatRaster, the output is also plotted.

Arguments

model

The model to be projected. This may be the object returned by chooseModel, or the 'selectedmodel' returned by selectEV.

transformations

Transformation functions used to create the derived variables in the model. I.e. the 'transformations' returned by deriveVars. Equivalently, the full file pathway of the 'transformations.Rdata' file saved as a result of deriveVars.

data

Data frame of all the explanatory variables (EVs) included in the model (see readData). Alternatively, an object of class 'SpatRaster' containing rasters for all EVs included in the model. Column or raster names must match EV names.

clamping

Logical. Do clamping sensu Phillips et al. (2006). Default is FALSE.

raw

Logical. Return raw maxent output instead of probability ratio output (PRO)? Default is FALSE. Irrelevant for "LR"-type models.

rescale

Logical. Linearly rescale model output (PRO or raw) with respect to the projection data? This has implications for the interpretation of output values with respect to reference values (e.g. PRO = 1). See details. Irrelevant for "LR"-type models.

filename

Full file pathway to write raster model predictions if data is an object of class 'SpatRaster'. File format is inferred from the filename extension as in terra::writeRaster.

Details

Missing data (NA) for a continuous variable will result in NA output for that point. Missing data for a categorical variable is treated as belonging to none of the categories.

When rescale = FALSE the scale of the maxent model output (PRO or raw) returned by this function is dependent on the data used to train the model. For example, a location with PRO = 2 can be interpreted as having a probability of presence twice as high as an average site in the training data (Halvorsen, 2013, Halvorsen et al., 2015). When rescale = TRUE, the output is linearly rescaled with respect to the data onto which the model is projected. In this case, a location with PRO = 2 can be interpreted as having a probability of presence twice as high as an average site in the projection data. Similarly, raw values are on a scale which is dependent on the size of either the training data extent (rescale = FALSE) or projection data extent (rescale = TRUE).

References

Halvorsen, R. (2013) A strict maximum likelihood explanation of MaxEnt, and some implications for distribution modelling. Sommerfeltia, 36, 1-132.

Halvorsen, R., Mazzoni, S., Bryn, A. & Bakkestuen, V. (2015) Opportunities for improved distribution modelling practice via a strict maximum likelihood interpretation of MaxEnt. Ecography, 38, 172-183.

Phillips, S.J., Anderson, R.P. & Schapire, R.E. (2006) Maximum entropy modeling of species geographic distributions. Ecological Modelling, 190, 231-259.

Examples

Run this code
if (FALSE) {
# From vignette:
EVfiles <- c(list.files(system.file("extdata", "EV_continuous", package="MIAmaxent"),
                        full.names=TRUE),
             list.files(system.file("extdata", "EV_categorical", package="MIAmaxent"),
                        full.names=TRUE))
EVstack <- rast(EVfiles)
names(EVstack) <- gsub(".asc", "", basename(EVfiles))
grasslandPreds <- projectModel(model = grasslandmodel,
                               transformations = grasslandDVs$transformations,
                               data = EVstack)
grasslandPreds
}

Run the code above in your browser using DataLab