Wednesday, August 3, 2016

Ecospat tests!

I haven't added this to the vignette on GitHub yet (because I just literally got it working a couple of minutes ago), but I've leveraged the enmtools.species object structure to make the equivalency and similarity tests from ecospat much more accessible.

For those that aren't familiar, these tests essentially do the same sort of thing that the identity/equivalency and background/similarity tests in good ol' ENMTools do, but they do them directly in environment space with no need to build an ENM.  Basically they make kernel density estimates of your species' occurrence in environment space, the available habitat for your species in environment space, and the environment space itself.  Then they basically "correct" the density of your species for the density of available habitat and measure overlap using I and D.  Those overlaps are then tested against a null distribution from a permutation test, much like the ones in ENMTools.

I really liked the Broennimann et al. idea when I read about it, and was super excited when ecospat came out.  The interface is a bit clunky, though, and requires a lot of setup to run.  The nice thing about the enmtools.species object structure is that I can actually automate all of this setup for you, and in the end you get a really cool ecospat test with basically zero hassle!

Oh, one note, though: ecospat only works in two environmental dimensions.  Keep that in mind, because if you try to pass the enmtools.ecospat functions more or less than two dimensions they will barf and yell at you.  If, for instance, you have two enmtools.species objects with backgrounds and presence points (named ahli and allogus here) you can call the ecospat tests like this:
And you get the good stuff you're used to by now...



esp.id = enmtools.ecospat.id(ahli, allogus, env[[c("layer.1", "layer.3")]])

esp.bg.sym = enmtools.ecospat.bg(ahli, allogus, env[[c("layer.1", "layer.3")]], test.type = "symmetric")

esp.bg.asym = enmtools.ecospat.bg(ahli, allogus, env[[c("layer.1", "layer.3")]], test.type = "asymmetric")



ecospat.id test p-values:
   D    I 
0.02 0.02 




As well as this cool sucker:


This plot shows the availability and occupancy of the environment for each species.  Neat, huh?  

Noe that these scaled densities look a little weird.  That's because I left low density thresholds for ecospat at zero (th.sp and th.env options for function ecospat.grid.clim.dyn).  Those are definitely something you should mess with, otherwise you get (as I have here) situations where the most relevant habitat to the I and D metrics is in fact some of the most marginal habitat for the species.

1 comment:

  1. Hi Dan, I am trying to perform a background test using ENMtools in r. But several questions have arisen and I can not solve them. I start to creating a enmtools.species object, I had success to establish the presence points and I assume that for background test it is not necessary establish background points, since those represent ausence data (However, is this assumption correct?). And finally, I think that if I have a range raster for the species (meaning a accessible area, i.e. M), it can be use to establish as a species$raster in the enmtools.species object, Is this possible? Which commands can be used to do this? Thanks in advance for your help! Alondra from Aguascalientes, Mx.

    ReplyDelete