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