[Vegan-commits] r804 - in branches/1.15: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 14 21:21:18 CEST 2009
Author: jarioksa
Date: 2009-04-14 21:21:18 +0200 (Tue, 14 Apr 2009)
New Revision: 804
Modified:
branches/1.15/R/adonis.R
branches/1.15/inst/ChangeLog
branches/1.15/inst/NEWS
branches/1.15/man/adonis.Rd
Log:
merged r800 (adonis uses less memory) and r802 (enhanced example in adonis.Rd)
Modified: branches/1.15/R/adonis.R
===================================================================
--- branches/1.15/R/adonis.R 2009-04-14 18:56:20 UTC (rev 803)
+++ branches/1.15/R/adonis.R 2009-04-14 19:21:18 UTC (rev 804)
@@ -80,15 +80,13 @@
## Permutations
if (missing(strata))
strata <- NULL
- G.p <- lapply(1:permutations, function(x) {
- permutes <- permuted.index(n, strata = strata)
- G[permutes, permutes]
- } )
+ p <- sapply(1:permutations,
+ function(x) permuted.index(n, strata=strata))
- ## SS.s <- sapply(G.p, function(Gs) { SS.perms(H, Gs, I) } )
+ ## Apply permutations for each term
f.perms <- sapply(1:nterms, function(i) {
sapply(1:permutations, function(j) {
- f.test(H.s[[i]], G.p[[j]], I, df.Exp[i], df.Res, H.snterm)
+ f.test(H.s[[i]], G[p[,j],p[,j]], I, df.Exp[i], df.Res, H.snterm)
} )
})
Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog 2009-04-14 18:56:20 UTC (rev 803)
+++ branches/1.15/inst/ChangeLog 2009-04-14 19:21:18 UTC (rev 804)
@@ -5,6 +5,9 @@
Version 1.15-2 (opened January 14, 2009)
+ * merged r800 (adonis uses less memory in permutation tests) and
+ r802 (example enhanced in adonis.Rd, with formatting).
+
* merged r600: Oribatid mites (dataset 'mite') got taxon names.
* copied nestednodf.R and print.nestednodf.R from pkg/vegan at
Modified: branches/1.15/inst/NEWS
===================================================================
--- branches/1.15/inst/NEWS 2009-04-14 18:56:20 UTC (rev 803)
+++ branches/1.15/inst/NEWS 2009-04-14 19:21:18 UTC (rev 804)
@@ -7,7 +7,8 @@
- adonis: adds one to numerator and denominator of permutation
tests, the default number of iterations was raised from 5 to
- 999, and the result object got a 'terms' component.
+ 999, and the result object got a 'terms' component. Uses much
+ less memory allowing analysis of larger problems.
- anova.cca: anova(..., by = "axis") gained new keyword 'cutoff'
to stop permutation tests after exceeding the given cut-off
Modified: branches/1.15/man/adonis.Rd
===================================================================
--- branches/1.15/man/adonis.Rd 2009-04-14 18:56:20 UTC (rev 803)
+++ branches/1.15/man/adonis.Rd 2009-04-14 19:21:18 UTC (rev 804)
@@ -60,6 +60,15 @@
\code{\link[ade4]{amova}} in the \pkg{ade4} package) for both crossed
and nested factors.
+If the experimental design has nestedness, then use \code{strata} to
+test hypotheses. For instance, imagine we are testing the whether a
+plant community is influenced by nitrate amendments, and we have two
+replicate plots at each of two levels of nitrate (0, 10 ppm). We have
+replicated the experiment in three fields with (perhaps) different
+average productivity. In this design, we would need to specify
+\code{strata = field} so that randomizations occur only \emph{within
+each field} and not across all fields . See example below.
+
Like AMOVA (Excoffier et al. 1992), \code{adonis} relies on a
long-understood phenomenon that allows one to partition sums of squared
deviations from a centroid in two different ways (McArdle and Anderson
@@ -162,6 +171,33 @@
data(dune)
data(dune.env)
adonis(dune ~ Management*A1, data=dune.env, permutations=99)
+
+
+### Example of use with strata, for nested (e.g., block) designs.
+
+dat <- expand.grid(rep=gl(2,1), NO3=factor(c(0,10)),field=gl(3,1) )
+dat
+Agropyron <- with(dat, as.numeric(field) + as.numeric(NO3)+2) +rnorm(12)/2
+Schizachyrium <- with(dat, as.numeric(field) - as.numeric(NO3)+2) +rnorm(12)/2
+total <- Agropyron + Schizachyrium
+library(lattice)
+dotplot(total ~ NO3, dat, jitter.x=TRUE, groups=field,
+ type=c('p','a'), xlab="NO3", auto.key=list(columns=3, lines=TRUE) )
+
+Y <- data.frame(Agropyron, Schizachyrium)
+mod <- metaMDS(Y)
+plot(mod)
+### Hulls show treatment
+ordihull(mod, group=dat$NO3, show="0")
+ordihull(mod, group=dat$NO3, show="10", col=3)
+### Spider shows fields
+ordispider(mod, group=dat$field, lty=3, col="red")
+
+### Correct hypothesis test (with strata)
+adonis(Y ~ NO3, data=dat, strata=dat$field, perm=1e3)
+
+### Incorrect (no strata)
+adonis(Y ~ NO3, data=dat, perm=1e3)
}
\keyword{multivariate }
More information about the Vegan-commits
mailing list