maxent_IC: Calculate information criteria for Maxent models

Description Usage Arguments Value Warning References Examples

Description

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

Usage

1
maxent_IC(x, occ, lambdas)

Arguments

x

Either a file path to a Maxent raw prediction raster, 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.

lambdas

The path to a Maxent .lambdas file, or a MaxEnt fitted model object.

Value

An n x 6 matrix, where n is the number of Maxent rasters 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
library(dismo)
fnames <- list.files(path=file.path(system.file(package='dismo'), 'ex'), 
                     patt='grd', full=TRUE )
predictors <- stack(fnames)
occ <- read.csv(file.path(system.file(package="dismo"), 'ex/bradypus.csv'))[, -1]
me <- maxent(predictors, occ, args=c('hinge=false', 'threshold=false'),
             path=tempdir())
r <- project_maxent(me, predictors, quiet=TRUE)$prediction_raw

# passing the raster object to pred.raw and the maxent object to lambdas:
maxent_IC(r, occ, me)

# passing a lambdas file path to lambdas:
maxent_IC(r, occ, file.path(tempdir(), 'species.lambdas'))

# passing a raster file path and lambdas file path to lambdas:
writeRaster(r, f <- tempfile(fileext='.tif'))
maxent_IC(f, occ, file.path(tempdir(), 'species.lambdas'))

johnbaums/things documentation built on May 19, 2019, 3:03 p.m.