I have some multivariate data and want to investigate the effect of some environmental gradient. I want to use capscale but I don´t know how to deal with the permutation scheme. I have made up some artificial data, with 20 sites along a gradient ("env"):
######### create some species data along a gradient
df <- structure(list(site = 1:20,
sp1 = c(7L, 4L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
sp2 = c(1L, 2L, 4L, 7L, 8L, 7L, 4L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
sp3 = c(0L, 0L, 0L, 0L, 0L, 1L, 2L, 4L, 7L, 8L, 7L, 4L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L),
sp4 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 4L, 7L, 8L, 7L, 4L, 2L, 1L, 0L),
sp5 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 4L, 7L, 8L),
sp6 = c(0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
sp7 = c(0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
sp8 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
sp9 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 1L, 0L, 0L)),
.Names = c("site", "sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9"),
class = "data.frame", row.names = c(NA, -20L))
# add some linear responses
df$sp6 <- round(seq(1, 8, 7/19), digits = 2) # linear response
df$sp7 <- round(seq(1, 4, 3/19), digits = 2) # no so strong linear response
df$sp9 <- round(seq(1, 6, 5/19), digits = 2)
# gradient
df$env <- 1:20
If I sampled only once I would do something like this:
# db-RDA sampled at one time
require(vegan)
mod <- capscale(df[ ,-c(1, 10)] ~ env, data = df, distance = "bray")
anova(mod, by = "terms", step = 999) # assess the "significance" of contraining variable
plot(mod)
Now imagine I sampled the same data trice, but in three different months:
# now we replate exactly the same data 2 more times
repdf <- rbind(df, df, df)
repdf$time <- rep(1:3, each = nrow(df))
repdf$site <- factor(repdf$site)
If I would use unrestricted permutations, then this won't capture the repeated measures and the p-values would be to low.
I could restrict the permutations within each sites (using strata = site in vegan), but this destroys only the temporal effect and yields to a p of 1 (because every permuation is the same):
repmod <- capscale(repdf[ ,-c(1, 11, 12)] ~ env, data = repdf, distance = "bray") # db-RDA
anova(repmod, by = "terms", strata = repdf$site, step = 999)
My question: How should I restrict the permutations assessing the effect of the gradient taking this temporal correlation into account? What permutationscheme should I use?
Some ideas: a) Permute the strata ( = sites), but not within the strata. This will destroy the env gradient, so the p-value is only determined by this.
b) Include "time" into the model (with interactions) and the run for time-effect a different permutation-scheme (permute within sites) than for env (permute sites, but not within sites).
I know about the permute-package and can incorporate it into permutest.cca, so my question is more theoretical.