maxent: Maximum Entropy model

View source: R/maxent.R

maxentR Documentation

Maximum Entropy model

Description

Create a "MaxEnt" (Maximum Entropy) species distribution model.

Usage

maxent(x, ...)

## Default S3 method:
maxent(
  x,
  y,
  reg = "lqph",
  beta = 1,
  niter = 500,
  outputType = "Cloglog",
  thrtype = "MaxSens+Spec",
  clamp = TRUE,
  filesPath = paste0(tempdir(), "/maxent"),
  maxentPath = NULL,
  flags = NULL,
  ...
)

## S3 method for class 'formula'
maxent(form, data, ..., subset, na.action)

## S3 method for class 'matrix'
maxent(x, y, ..., categorical = NULL)

maxentCaret

Arguments

x

A data frame of predictors

...

Arguments passed to default method.

y

A response factor, same length as nrow(x). First level is assumed to be "presence" data.

reg

Regularization features to use. l - linear, q - quadratic, p - product, t - threshold, h - hinge

beta

Beta multiplier

niter

Maximum number of iterations

outputType

One of 'Cloglog', 'Logistic', 'Cumulative', 'Raw'

thrtype

Which threshold type to use. One of 'Min_Presence','10%_Presence', 'Sens=Spec','MaxSens+Spec','Balance','Entropy'

clamp

logical. Apply clamping in prediction?

filesPath

Path used to store MaxEnt output files

maxentPath

Path of maxent.jar. If NULL, it will use maxent.jar from the dismo package

flags

Other flags to maxent. Should be in the format c('addsamplestobackground=false', 'beta_hinge=1.5').

form

A formula of the form y ~ x1 + x2 + ...

data

Data frame from which variables specified in formula

subset

An index vector specifying the cases to be used in the training sample.

na.action

A function to specify the action to be taken if NAs are found. The default action is for the procedure to fail.

categorical

A character vector with column names to be treated as categorical variable.

Format

An object of class list of length 12.

Details

This function will use the java implementation of MaxEnt by Phillips, Dudik and Schapire, instead of the package maxnet. Check the MaxEnt documentation for more information. Only suitable for presence/absence or presence/background data. This is similar to maxent, with less options (for instance, this will not accept rasters), but it is faster, specially the predict function. This function do not support maxent.jar replicates, as those should be handled by caret.

Value

An S3 object of class 'maxent' build using maxent.jar, including:

  • path - The path to the files generated by maxent.jar.

  • params - A list with parameters used to build the model.

  • results - A data.frame with multiple results from the model.

  • predicted - A vector with predictions made by the model on the trained data.

Note

When using a data.frame, variables defined as factors are automatically assigned as categorical variables. When using a matrix or a formula with caret, you must the argument categorical if any of the variables are factors/categorical.
Due to the way caret::train handles the data when using a formula, it is not possible to automatically get which variables are categorical.

See Also

methods.maxent

Examples

## Not run: 
maxent(x, y)
maxent(x, y, reg = "lq", maxentPath="~/maxent.jar", filesPath="/run/shm/maxent")

# using caret
# use 'categorical' if there are categorical  variables in traindata
model.maxent = train(species ~ ., data=traindata,
                     method=maxentCaret, metric="ROC", trControl = control,
                     tuneGrid = expand.grid(reg = c("lq","l"), beta = seq(0.5, 2, 0.2)),
                     categorical = c("factor1", "factor2"))

## End(Not run)

correapvf/caretSDM documentation built on June 2, 2022, 8:29 a.m.