Project model to data.

Share:

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

1
2
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.

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).

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.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## 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")

## End(Not run)

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")

## End(Not run)