Created
February 17, 2022 11:59
-
-
Save zdealveindy/efad86b7e4feac5bbc203542e93da1b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pseudoreplication issue | |
# 1600 quadrats sampled in 8 grids (each grid 200 quadrats) | |
# what happens if we consider quadrats as independent units? | |
DEP <- rnorm (1600) | |
EXP <- rnorm (1600) | |
GRID <- rep (1:8, each = 200) | |
boxplot (DEP ~ GRID) | |
solution <- sapply (0:10, FUN = function (x) | |
replicate (100, expr = { | |
RAND1 <- runif (n = 8, min = 0, max = x) | |
RAND2 <- runif (n = 8, min = 0, max = x) | |
DEP_recoded <- DEP + RAND1[GRID] | |
EXP_recoded <- EXP + RAND2[GRID] | |
cor.test (DEP_recoded, EXP_recoded)$p.value | |
}) | |
) | |
boxplot (solution, xlab = 'Value of Grid level environment', ylab = 'P-values') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment