Learn R Programming

GSIF (version 0.5-3)

MaxEnt: Prediction and cross-validation using the Maximum Entropy

Description

Runs MaxEnt algorithm on a set of observations ("ppp" class from the spatstat package) and environmental covariates (of "SpatialPixelsDataFrame" class) and returns predicted probability of occurrence and cross-validation of models with presence/absence data.

Usage

"MaxEnt"(occurrences, covariates, nfold = 5, Npoints = 1000, sciname = as.character(NA), period = c(Sys.Date()-1, Sys.Date()), ...)

Arguments

occurrences
object of type "ppp"; occurrences
covariates
object of type "SpatialPixelsData"; list of covariate layers
nfold
object of type "integer"; number of folds used for cross-validation
Npoints
object of type "integer"; number of points used for cross-validation
sciname
object of type "character"; usually species latin name (it can also be a surveyor's team name or a sampling design)
period
object of type "Date"; sampling period
...
for more additional arguments see dismo::predict

Value

"SpatialMaxEntOutput" with the following slots: sciname (usually latin "genus" and "species" name), occurrences (occurrence-only records), TimeSpan.begin (begin of sampling), TimeSpan.end (end of sampling), maxent (object of class "MaxEnt" produced as an output of the dismo::maxent function), sp.domain (assumed spatial domain), and predicted (results of prediction produced using the MaxEnt software).

References

See Also

dismo::maxent, plotKML::SpatialMaxEntOutput-class

Examples

Run this code
# load data:
library(plotKML)
library(rJava)
library(spatstat)
library(maptools)
library(dismo)
library(rgdal)

data(eberg)
data(eberg_grid)
## prepare data for spatial analysis:
eberg.xy <- eberg[runif(nrow(eberg))<0.3,]
coordinates(eberg.xy) <- ~X+Y
proj4string(eberg.xy) <- CRS("+init=epsg:31467")
## format gridded data:
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
## convert to a "ppp" object:
eberg.ppp <- as.ppp(eberg.xy)
## run MaxEnt analysis (evaluates sampling bias or mis-representation):
jar <- paste(system.file(package="dismo"), "/java/maxent.jar", sep='')
if(file.exists(jar)){
  me.eberg <- MaxEnt(occurrences=eberg.ppp, covariates=eberg_grid)
  ## NOTE: MaxEnt can be time-consuming!
  # plot the results:
  par(mfrow=c(1,2), mar=c(0.5,0.5,0.5,0.5), oma=c(0,0,0,0))
  image(as(me.eberg@predicted, "SpatialPixelsDataFrame"), 
    col=rev(heat.colors(25)), xlab="", ylab="")
  points(me.eberg@occurrences, pch="+", cex=.7)
  image(me.eberg@sp.domain, col="grey", xlab="", ylab="")
}

Run the code above in your browser using DataLab