Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. library(randtests)
  2. specii <- c(32, 29, 35, 36, 41, 62, 88, 77, 50, 22.6)
  3. area <- c(2.0, 0.9, 3.1, 3.0, 1.0, 2.0, 4.0, 3.5, 2.4375, 1.1426)
  4. r <- cor(specii, area)
  5.  
  6. specii_s <- permut(specii)
  7. n <- factorial(10)
  8. r_s <- 1:n
  9. for (i in 1:n) {
  10. area_s <- sample(area)
  11. r_s[i] <- cor(specii_s[i, ], area_s)
  12. }
  13.  
  14. prob <- length(r_s[r_s >= r])/n
  15. cat("Probability randomized r >= r0",prob)
  16. hist(r_s, breaks = 50, main = expression(paste("Distribution around ",rho, "= 0")), xlab = "r from randomized samples")
  17. r <- round(r, digits = 2)
  18. legend(.40, 200, r, bty = "n")
  19. arrows(.5,150,.53, 10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement