Learn R Programming

MIAmaxent (version 0.4.0)

projectModel: Project model to data.

Description

projectModel Calculates the probability ratio output (PRO) of a given model for any points where values of the explanatory variables in the model are known.The transformations performed on the explanatory variables to build the model must be specified.

Usage

projectModel(data, transformation, model, clamping = FALSE, rescale = FALSE,
  raw = FALSE)

Arguments

data
Data frame of all the explanatory variables (EVs) included in the model, with column names matching EV names. See readData.
transformation
Full pathway of the 'transformations.Rdata' file containing the transformations used to build the model. This file is saved as a result of the deriveVars function. Equivalently, the second item in the list returned by deriveVars can be used directly.
model
Full pathway of the '.lambdas' file of the model in question. This file is saved as a result of selectEV.
clamping
Logical. Do clamping sensu Phillips et al. (2006). Default is FALSE.
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.
raw
Logical. Return raw Maxent output instead of probability ratio output (PRO)? Default is FALSE.

Value

List of 2:
  1. A data frame with the model output in column 1 and the corresponding explanatory data in subsequent columns.
  2. A data frame showing the range of data compared to the training data, on a 0-1 scale.

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 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
## Not run: ------------------------------------
# modeloutput <- projectModel(newdat,
#    transformation = "D:/path/to/modeling/directory/deriveVars/transformations.Rdata",
#    model = "D:/path/to/modeling/directory/selectEV/round/model/1.lambdas")
## ---------------------------------------------

proj <- projectModel(toydata_sp1po, toydata_dvs$transformations,
   system.file("extdata/sommerfeltia", "1.lambdas", package = "MIAmaxent"))
proj

## Not run: ------------------------------------
# # From vignette:
# grasslandPrediction <- projectModel(grasslandPO,
#    transformation = grasslandDVs[[2]],
#    model = system.file("extdata", "1.lambdas", package = "MIAmaxent"))
# head(grasslandPrediction$output)
# grasslandPrediction$ranges
# 
# # From vignette:
# library(raster)
# contfiles <- list.files(system.file("extdata", "EV_continuous", package = "MIAmaxent"),
#    full.names = TRUE)
# catfiles <- list.files(system.file("extdata", "EV_categorical", package = "MIAmaxent"),
#    full.names = TRUE)
# stack <- raster::stack(c(contfiles, catfiles))
# stackpts <- rasterToPoints(stack)
# spatialPrediction <- projectModel(stackpts,
#    transformation = grasslandDVs[[2]],
#    model = system.file("extdata", "1.lambdas", package = "MIAmaxent"))
# Predictionraster <- raster(stack, layer=0)
# Predictionraster <- rasterize(spatialPrediction$output[, c("x", "y")], Predictionraster,
#    field = spatialPrediction$output$PRO)
# plot(Predictionraster, colNA="black")
## ---------------------------------------------

Run the code above in your browser using DataLab