1

Niche Tests for Dummies

by MadhviVenkatraman

Here we are using Stata 11.2

  1. Download the Stata routines
  2. Where to download them
  3. They are listed under this paper: (I recommend reading it if you’re doing all this)

15.McCormack JE, AJ Zellmer & LL Knowles. 2010. Does niche divergence accompany allopatric divergence inAphelocomajays as predicted under ecological speciation?: Insights from tests with niche models. Evolution64:1231-1244(PDF)

  1. You need to download
  2. Stata routinefor calculating observed niche divergence
  3. Stata routinefor conducting jackknife replicates of background divergence
  1. Running the Stata routine for conducting jackknife replicates of background divergence
  2. Input your database with occurrence points, random points and GIS data for all environmental layers
  3. Run ‘Do’ file
  4. Annotated Do file follows

Annotated Stata Routine for Conducting Jackknife Replicates of Background Divergence

capture program drop myboot

program define myboot, rclass

preserve

pca bio1 bio2 bio3 bio4 bio7 bio12 bio14 bio15 bio18 bio19 canhtndvindvi_stdqscat tree[s1]

predict pc1 pc2 pc3 pc4 pc5 pc6 pc7 pc8 pc9[s2]

sample 25[s3], by(type[s4]), if type==5 | type==3[s5]

summ pc1 if type==5

scalar pc1_1 = r(mean)

summ pc1 if type==3

scalar pc1_3 = r(mean)

summ pc2 if type==5

scalar pc2_1 = r(mean)

summ pc2 if type==3[s6]

scalar pc2_3 = r(mean)

summ pc3 if type==5

scalar pc3_1 = r(mean)

summ pc3 if type==3

scalar pc3_3 = r(mean)

summ pc4 if type==5

scalar pc4_1 = r(mean)

summ pc4 if type==3

scalar pc4_3 = r(mean)

summ pc5 if type==5

scalar pc5_1 = r(mean)

summ pc5 if type==3

scalar pc5_3 = r(mean)

summ pc6 if type==5

scalar pc6_1 = r(mean)

summ pc6 if type==3

scalar pc6_3 = r(mean)

summ pc9 if type==5

scalar pc9_1 = r(mean)

summ pc9 if type==3

scalar pc9_3 = r(mean)

restore

end

simulate dist1 = (abs(pc1_1-pc1_3)) dist2 =(abs(pc2_1-pc2_3)) dist3 =(abs(pc3_1-pc3_3)) dist4 =(abs(pc4_1-pc4_3)) dist5 =(abs(pc5_1-pc5_3)) dist6 =(abs(pc6_1-pc6_3))dist9 =(abs(pc9_1-pc9_3)), reps(1000) seed(12346): myboot

Annotated Output of Stata Routine for Conducting Jackknife Replicates of Background Divergence

^ Results after simulations run

  • To summarize the results: “summ, dist1, detail
  • Now, depending on the type of tails you are using for this study you would note the 5% or 1% in the smallest column and the 95% or 99% values in the largest column.
  • Do this for all dist values.

Your table should look something like this (here I did 1% tails)

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74
PC2 / 0.00 / 0.39
PC3 / 0.07 / 0.30
PC4 / 0.26 / 0.63
PC5 / 0.90 / 1.32
PC6 / 0.08 / 0.44

Occurrence Point Data

Before you run the do file for calculating observed niche divergence you must do a Principal Components analysis on your data

pca[s7] bio1 bio2 bio3 bio4 bio7 bio12 bio14 bio15 bio18 bio19 canhtndvindvi_stdqscat tree

predict[s8]pc1 pc2 pc3 pc4 pc5 pc6 pc7 pc8 pc9

Annotated Stata routine for calculating observed niche divergence

summ pc1 if type==6[s9]

scalar pc1_8 = r(mean)

summ pc1 if type==4[s10]

scalar pc1_10 = r(mean)

summ pc2 if type==6

scalar pc2_8 = r(mean)

summ pc2 if type==4

scalar pc2_10 = r(mean)

summ pc3 if type==6

scalar pc3_8 = r(mean)

summ pc3 if type==4

scalar pc3_10 = r(mean)

summ pc4 if type==6

scalar pc4_8 = r(mean)

summ pc4 if type==4

scalar pc4_10 = r(mean)

summ pc5 if type==6

scalar pc5_8 = r(mean)

summ pc5 if type==4

scalar pc5_10 = r(mean)

summ pc6 if type==6

scalar pc6_8 = r(mean)

summ pc6 if type==4

scalar pc6_10 = r(mean)

display (abs(pc1_8-pc1_10))

display (abs(pc2_8-pc2_10))

display (abs(pc3_8-pc3_10))

display (abs(pc4_8-pc4_10))

display (abs(pc5_8-pc5_10))

display (abs(pc6_8-pc6_10))

Annotated Output ofStata routine for calculating observed niche divergence

All those values are important: enter them into your table!

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74 / 2.91
PC2 / 0.00 / 0.39 / 0.78
PC3 / 0.07 / 0.30 / 0.43
PC4 / 0.26 / 0.63 / 0.20
PC5 / 0.90 / 1.32 / 2.41
PC6 / 0.08 / 0.44 / 0.61

Now you can determine whether any axes show niche conservatism

Are there any observed values that fall below the null_low value?

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74 / 2.91
PC2 / 0.00 / 0.39 / 0.78
PC3 / 0.07 / 0.30 / 0.43
PC4 / 0.26 / 0.63 / 0.20 / Conserved
PC5 / 0.90 / 1.32 / 2.41
PC6 / 0.08 / 0.44 / 0.61

To determine niche divergence you need to know whether the observed points are significantly different as well.

This calls for a t-test!

Code: ttest pc1 if type==4 | type==6, by(type)

Save the Pr(|T| > |t|) value, because you are doing a two tailed t-test.

Depending on your alpha value determine which comparisons are significant (denoted by *)

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74 / 2.91 / *
PC2 / 0.00 / 0.39 / 0.78 / *
PC3 / 0.07 / 0.30 / 0.43
PC4 / 0.26 / 0.63 / 0.20 / Conserved
PC5 / 0.90 / 1.32 / 2.41 / *
PC6 / 0.08 / 0.44 / 0.61 / *

Now you can determine whether any axes show niche divergence

Are there any observed values that fall above the null_high value and have significantly different observed points?

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74 / 2.91 / *
PC2 / 0.00 / 0.39 / 0.78 / Diverged / *
PC3 / 0.07 / 0.30 / 0.43[s11]
PC4 / 0.26 / 0.63 / 0.20 / Conserved
PC5 / 0.90 / 1.32 / 2.41 / Diverged / *
PC6 / 0.08 / 0.44 / 0.61 / Diverged / *

Final Table:

null_low / null_high / obs / D or C? / ttest
PC1 / 2.75 / 3.74 / 2.91 / *
PC2 / 0.00 / 0.39 / 0.78 / Diverged / *
PC3 / 0.07 / 0.30 / 0.43
PC4 / 0.26 / 0.63 / 0.20 / Conserved
PC5 / 0.90 / 1.32 / 2.41 / Diverged / *
PC6 / 0.08 / 0.44 / 0.61 / Diverged / *

Hoorah! You’re done!

[s1]The environmental layers you are using after dropping correlated layers

[s2]The principal components you have decided to use for further analysis

[s3]Jackknife percentage you are going to use

[s4]Classification you are using for this test: type/subspecies/species, etc.

[s5]Subspecies/ species/ type number you are comparing in this test

[s6]Remember to change these

[s7]Conducts a principal components analysis on your layers

[s8]Saves the components you want to save

[s9]These are your occurrence points species codes

[s10]Remember to change them!

[s11]This value is larger than the null_high value, but the observed points are not significantly different so it does not show niche divergence.