Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. NeiH(group1)
  2. NeiH(group2)
  3.  
  4. B <- 5000 # number of bootstrap replicates
  5.  
  6. # Initialization of three vectors that will receive the statistics for each bootstrap sample:
  7. g1_boot <- rep(NA, B); g2_boot <- rep(NA, B); diff_boot <- rep(NA, B)
  8.  
  9. # Resampling (with replacement) in each population:
  10. for (i in 1:B) {
  11. g1star <- sample(group1, replace=TRUE, size=length(group1)) # draw a random sample in group1
  12. g2star <- sample(group2, replace=TRUE, size=length(group2))
  13. g1_boot[i] <- NeiH(g1star)
  14. g2_boot[i] <- NeiH(g2star)
  15. diff_boot[i] <- g1_boot[i] - g2_boot[i]
  16. }
  17.  
  18. # Histogram for the difference between the two indicators of gene diversity:
  19. hist(diff_boot, xlim=c(-0.5,0.1), main="Difference between Nei's H indices")
  20. # Bootstrap 95% IC for the difference:
  21. quantile(diff_boot, 0.025)
  22. quantile(diff_boot, 0.975)
  23.  
  24. hist(g2_boot)
  25. abline(v=0.97, lty=2, lwd=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement