Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdealveindy/efad86b7e4feac5bbc203542e93da1b0 to your computer and use it in GitHub Desktop.
Save zdealveindy/efad86b7e4feac5bbc203542e93da1b0 to your computer and use it in GitHub Desktop.
# 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