project: Project a fitted Maxent model

Description Usage Arguments Details Value Warning References See Also Examples

View source: R/project.R

Description

Project a fitted Maxent model by predicting to new environmental data.

Usage

1
project(lambdas, newdata, return_lfx = FALSE, mask, quiet = FALSE)

Arguments

lambdas

Either (1) a MaxEnt fitted model object (fitted with the maxent function in the dismo package), (2) a file path to a Maxent .lambdas file, or (3) a lambdas object returned by parse_lambdas().

newdata

A RasterStack, RasterBrick, list, data.frame, data.table, or matrix that has layers/elements/columns whose names correspond to the names of predictors used to fit the model. These layers/elements/columns must all have the same length.

return_lfx

Logical. Should Raster layers be returned giving lambda*feature values for each feature with a non-zero lambda? Currently ignored if newdata is not a Raster* object.

mask

(Optional; requires that newdata is a Raster* object.) A Raster object with NA values in cells for which the model should not be projected. These cells will be assigned NA in the returned output.

quiet

Logical. Should projection progress be reported?

Details

project uses feature weights described in a .lambas file or MaxEnt object to predict a Maxent model to environmental data. This function performs the projection entirely in R, without the need for the Maxent Java software. For tested datasets, it performs the projection in roughly one third of the time taken for the same projection by maxent.jar.

Value

If newdata is a RasterStack or RasterBrick, a list with three elements:

Additionally, if newdata is a RasterStack or RasterBrick and return_lfx is TRUE, the returned list will include prediction_lfx (the logit scores for the linear predictor), and lfx_all (the contributions to prediction_lfx of each feature with a non-zero lambda).

Warning

This function is still in development, and no guarantee is made for the accuracy of its projections.

References

See Also

read_mxe()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# Below we use the dismo::maxent example to fit a Maxent model:
fnames <- list.files(system.file('ex', package='dismo'), '\\.grd$', 
                     full.names=TRUE )
predictors <- stack(fnames)
occurrence <- system.file('ex/bradypus.csv', package='dismo')
occ <- read.table(occurrence, header=TRUE, sep=',')[,-1]
me <- maxent(predictors, occ, factors='biome')

# ... and then predict it to the full environmental grids:
pred <- project(me, predictors)
# This is equivalent to using the predict method for MaxEnt objects:
pred2 <- predict(me, predictors, args='outputformat=logistic')
pred3 <- predict(me, predictors, args='outputformat=cloglog')

all.equal(values(pred$prediction_logistic), values(pred2))
all.equal(values(pred$prediction_cloglog), values(pred3))

## End(Not run)

johnbaums/rmaxent documentation built on July 3, 2020, 5:36 p.m.