Tuesday, March 30, 2021

ENMTools currently unavailable on CRAN

Due to some changes to the spatstat package, quite a few packages were kicked off CRAN today including ENMTools.  We have submitted a version that (we think) fixes these issues, but it's currently still in review.  Until it's back up, you can always install the development version from github:


devtools::install_github("danlwarren/ENMTools", ref = "develop")

Sunday, March 21, 2021

CRAN version of ENMTools is currently not working for some people

Due to updates with the spatstat package, the CRAN version of ENMTools is currently not working for some people.  We've got a develop version on github that seems to be doing okay, though, so you can install that by typing:


devtools::install_github("danlwarren/ENMTools", ref = "develop")

We should have the CRAN version working soon.  Sorry for the inconvenience; apparently all of the authors of packages depending on spatstat were supposed to receive emails months ago saying that all of this was coming down the pipe, but none of us seem to have gotten one.

Wednesday, March 10, 2021

Doing replicates of ENMTools models

This is coming from a question on the maxent google group.  Someone wanted to know how to do multiple replicates of an ENMTools model.  At some point we need to create some code for that, but for now it's not too hard to do it using R's existing "replicate" function.

# First we'll load in ENMTools


# Now we're just grabbing a species object out of the built-in data 

mont <- iberolacerta.clade$species$monticola

# Here we're using the "replicate" function to repeat the modeling command 10 times 

# and stuff the results into a list

my.models <- replicate(10, 

          enmtools.gam(mont, euro.worldclim[[c(1,12)]], test.prop = 0.3), 


# And now we want to give each rep a name

names(my.models) <- paste0("rep", 1:10)

# This is a slightly tricky bit - basically I'm grabbing the suitability raster out of each

# replicate model, and then turning them into a raster stack

rep.rasters <- stack(sapply(my.models, function(x) x$suitability))

# Now that we've got that, we can calculate any summary stats we want on that stack

# Here's how you'd plot the mean suitability

mean.raster <- calc(rep.rasters, fun = mean)


# Here's how you'd do variance

var.raster <- calc(rep.rasters, fun = var)


# And here's minimum suitability

min.raster <- calc(rep.rasters, fun = min)