ic: Calculate information criteria for Maxent models

Description Usage Arguments Value Warning References Examples

View source: R/ic.R

Description

Calculate AIC, AICc, and BIC for Maxent models as implemented in ENMTools.

Usage

1
ic(x, occ, lambdas)

Arguments

x

Either a vector of one or more file paths to Maxent raw prediction raster files, or a Raster or RasterStack containing raw Maxent predictions for which information criteria will be calculated.

occ

A matrix or data.frame containing the coordinates for occurrence data used to fit the model. This is assumed to be common to all models being compared.

lambdas

A vector of one or more file paths to Maxent .lambdas files, or a list of one or more MaxEnt fitted model objects. The length of this vector/list should equal the length (or number of layers) of x.

Value

An n x 6 matrix, where n is the number of Maxent models for which information criteria are to be calculated. Columns give n (the number of occurrence records used for model training), k (the number of features with non-zero weights), ll (the negative log likelihood of the model), AIC, AICc, and BIC (as calculated in ENMTools).

Warning

These information criteria should not be calculated for models that use hinge or threshold features because the number of predictors is not estimated correctly.

References

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
# Below we use the dismo::maxent example to fit a Maxent model:
if (require(dismo) && require(rJava) && 
    file.exists(system.file('java/maxent.jar', package='dismo'))) {
  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, args=c('hinge=false', 'threshold=false'),
               path=tempdir())
  r <- project(me, predictors, quiet=TRUE)$prediction_raw

  # passing the raster object to pred.raw and the maxent object to lambdas:
  ic(r, occ, me)
  
  # passing a lambdas file path to lambdas:
  ic(r, occ, file.path(tempdir(), 'species.lambdas'))
  
  # comparing multiple models
  me2 <- maxent(predictors, occ, args=c('hinge=false', 'threshold=false',
                'betamultiplier=3'), path=tempdir())
  r2 <- project(me2, predictors, quiet=TRUE)$prediction_raw               
  ic(stack(r, r2), occ, list(me, me2))
}

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