Friday, July 22, 2016

Background/similarity tests in the ENMTools R package

Okay, let's use our two species to run a background/similarity test.  This works a lot like the identity test (see the post preceding this one), but there's a new option called "test.type" that can be set to "asymmetric" or "symmetric".  Here's an asymmetric background test using Bioclim:




bg.bc.asym = background.test(species.1 = ahli, species.2 = allogus, env = env, type = "bc", nreps = 99, test.type = "asymmetric")
bg.bc.asym
## 
## 
##  
## 
## Asymmetric background test ahli vs. allogus background
## 
## background test p-values:
##        D        I rank.cor 
##      0.32      0.76      0.43 
## 
## 
## Replicates:
## 
## 
## |          |         D|         I|  rank.cor|
## |:---------|---------:|---------:|---------:|
## |empirical | 0.1328502| 0.3177390| 0.0706201|
## |rep 1     | 0.1430965| 0.3114858| 0.0824412|
## |rep 2     | 0.1284871| 0.2801639| 0.0156034|
## |rep 3     | 0.1599120| 0.3384525| 0.1136082|
## |rep 4     | 0.1431022| 0.3101197| 0.0766638|
plot of chunk unnamed-chunk-17


What is "symmetric" vs. "asymmetric"?  Well, an asymmetric test means that we are comparing the empirical overlap to a null distribution generated by comparing one species' real occurrences to the background of another (species.1 vs. background of species.2).  In the Warren et al. 2008 paper we used this sort of asymmetric test, repeating it in each direction (species.1 vs. background of species.2 and species.2 vs. background of species.1).  While we had the idea that that might generate some interesting biological insight, I think it's generated just as much (if not more) confusion.  For this reason, the new R package also provides the option to do symmetric tests.  These tests compare the empirical overlap to the overlap expected when points are drawn randomly from the background of both species (species.1 background vs. species.2 background), keeping sample sizes for each species constant, of course.

And now a symmetric background test using Domain:


bg.dm.sym = background.test(species.1 = ahli, species.2 = allogus, env = env, type = "dm", nreps = 99, test.type = "symmetric")

bg.dm.sym
## 
## 
##  
## 
## Symmetric background test ahli background vs. allogus background
## 
## background test p-values:
##        D        I rank.cor 
##      0.38      0.36      0.21 
## 
## 
## Replicates:
## 
## 
## |          |         D|         I|  rank.cor|
## |:---------|---------:|---------:|---------:|
## |empirical | 0.1328502| 0.3177390| 0.0706201|
## |rep 1     | 0.2382775| 0.4428653| 0.1774936|
## |rep 2     | 0.1518903| 0.3555431| 0.1002003|
## |rep 3     | 0.1250674| 0.3029139| 0.0717565|
## |rep 4     | 0.1165355| 0.2946842| 0.0841041|
plot of chunk unnamed-chunk-20


11 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. (forgot to subscribe to comment, sorry)
    In the background & identity tests, is the overlap analysis equivalent to raster.overlap or enm.overlap? I assume the former, since enm.overlap is new. And in cases where the 2 overlap analyses produce substantially different results, would it make a qualitative difference for the background/identity tests? I've read through the descriptions of these tests several times - very slowly, sideways, and backwards lol - and still can't figure out if using enm.overlap in background/identity would be good, interesting, or inappropriate.

    ReplyDelete
  3. The hazards of developing methods so quickly - this post is already out of date! The tests now spit out the p values for both raster and environment space overlap. The new output is something like:

    ## Identity test ahli vs. allogus
    ##
    ## Identity test p-values:
    ## D I rank.cor env.D env.I env.cor
    ## 0.2 0.2 0.2 0.2 0.2 0.2
    ##

    Sorry those results are boring, but they're from only 4 reps.

    Whether it makes a qualitative difference for the hypothesis tests I think would come down to whether or not there were huge biases in the distribution of geographically available environments in environment space. As to whether that affects outcomes in the real world, I honestly don't know yet - this stuff is too new to have a real idea, which is exciting!

    ReplyDelete
  4. Hello, I recently start to use ENMTools in R to perform a background test, but I got a warning when running the test: "In couldBeLonLat(mask) : CRS is NA. Assuming it is longitude/latitude". Maybe this is something basic for the forum, however I would appreciate the help you can give me. I add the information of one of the enmtools.species object use in the test:

    > pha

    Range raster:
    class : RasterLayer
    dimensions : 1030, 1071, 1103130 (nrow, ncol, ncell)
    resolution : 0.04166667, 0.04166667 (x, y)
    extent : -116.8613, -72.23634, -7.754555, 35.16211 (xmin, xmax, ymin, ymax)
    coord. ref. : NA
    data source : C:\Users\alond\Documents\ENMTools\SpeciesB\BackG_B\m_B.asc
    names : m_B
    values : -16, 287 (min, max)

    Presence points (first ten only):

    | Longitude| Latitude|
    |---------:|--------:|
    | -84.44651| 10.36284|
    | -79.24667| -2.48389|
    | -79.60959| 8.96574|
    | -78.61667| 0.90861|
    | -83.35225| 9.16876|
    | -80.13333| 8.60000|
    | -82.39997| 9.29999|
    | -79.27927| 9.23633|
    | -82.96670| 9.73330|
    | -85.83303| 13.01938|

    Background points not defined.

    Species name: pha

    Thank you in advance,

    Alondra Encarnación-Luévano, Ags, México

    ReplyDelete
  5. Is there a way to add .asc files generated by other means (eg. species.1 = sp1.asc) and conduct Background/similarity tests?

    ReplyDelete
    Replies
    1. Not really. I'm not sure how the permutations required would be possible without the point data.

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Thanks for your response, I didn't do a good job of explaining what I was hoping to do. I have points I used to generate the .asc but is it appropriate to to use an output model as the input for Background/similarity tests? 
    If so,  is it best to include it as a single/only env layer? If this, then do you add the two species ranges into the same stack or rasters?
    env = WEST.asc + SOUTH.asc

    Or add it as a mask in the species definition  
    PcruWEST$species.name = "WEST"
    PcruWEST$presence.points = read.csv("WEST_occ.csv")
    PcruWEST$mask=WEST.asc

    Or is there a better way to include these?

    Again I am sorry about the the lack of information contained in my initial question.  

    ReplyDelete
    Replies
    1. I'm not sure that would make sense to do. The hypothesis tests generate a bunch of models for permutations of the data using the supplied rasters, and then compare the similarities between those models to the similarities to models using empirical data. If you put the raster from an ENM into one of these analyses, it would be treating those suitability scores as though they were an environmental predictor for both species, and I'm not sure that makes much sense to do.

      Delete
    2. OK, I was worried that was the case but I appreciate you clarifying it for me. I'll use the inputs I generated in this analysis and run it in ENMTools.
      Thanks again,
      Best,
      Nick

      Delete
  8. This comment has been removed by the author.

    ReplyDelete