projectModel: Project model across explanatory data.

View source: R/projectModel.R

projectModelR Documentation

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
)

Arguments

model

The model to be projected, represented by an object of class 'glm'. 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 'RasterStack' or 'RasterBrick' 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' class 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' class models.

filename

Full file pathway to write raster model predictions if data is an object of class 'RasterStack' or 'RasterBrick'. File format is inferred from the filename extension as in raster::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).

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 RasterStack or RasterBrick.

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

If data is a RasterStack or RasterBrick, the output is also plotted.

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

## Not run: 
# From vignette:
EVstack <- raster::stack(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)))
grasslandPreds <- projectModel(model = grasslandmodel,
                               transformations = grasslandDVs$transformations,
                               data = EVstack)
grasslandPreds

## End(Not run)


julienvollering/MIAmaxent documentation built on July 6, 2023, 11:22 p.m.