[Vegan-commits] r667 - in branches/1.15: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 18 15:29:54 CET 2009


Author: jarioksa
Date: 2009-01-18 15:29:54 +0100 (Sun, 18 Jan 2009)
New Revision: 667

Modified:
   branches/1.15/R/adonis.R
   branches/1.15/R/print.adonis.R
   branches/1.15/inst/ChangeLog
   branches/1.15/man/adonis.Rd
Log:
merged r659, 662-664: adonis fixes and upgrades

Modified: branches/1.15/R/adonis.R
===================================================================
--- branches/1.15/R/adonis.R	2009-01-18 07:02:22 UTC (rev 666)
+++ branches/1.15/R/adonis.R	2009-01-18 14:29:54 UTC (rev 667)
@@ -1,5 +1,5 @@
 `adonis` <-
-    function(formula, data=NULL, permutations=5, method="bray", strata=NULL,
+    function(formula, data=NULL, permutations=999, method="bray", strata=NULL,
              contr.unordered="contr.sum", contr.ordered="contr.poly",
              ...)
 {
@@ -7,7 +7,13 @@
     ## frame or a matrix, and A, B, and C may be factors or continuous
     ## variables.  data is the data frame from which A, B, and C would
     ## be drawn.
-  TOL <- 1e-7
+    TOL <- 1e-7
+    ## Set no. of permutations to x-1 if x is an even hundred
+    if (permutations %% 100 == 0) {
+        permutations <- permutations - 1
+        warning("Setting no. of permutations to ", permutations)
+    }
+    Terms <- terms(formula, data = data)
     lhs <- formula[[2]]
     lhs <- eval(lhs, data, parent.frame()) # to force evaluation 
     formula[[2]] <- NULL                # to remove the lhs
@@ -92,13 +98,13 @@
                       MeanSqs = c(SS.Exp.each/df.Exp, SS.Res/df.Res, NA),
                       F.Model = c(F.Mod, NA,NA),
                       R2 = SumsOfSqs/SumsOfSqs[length(SumsOfSqs)],
-                      P = c(rowSums(t(f.perms) > F.Mod)/permutations, NA, NA))
+                      P = c((rowSums(t(f.perms) > F.Mod)+1)/(permutations+1), NA, NA))
     rownames(tab) <- c(attr(attr(rhs.frame, "terms"), "term.labels")[u.grps],
                        "Residuals", "Total")
     colnames(tab)[ncol(tab)] <- "Pr(>F)"
     out <- list(aov.tab = tab, call = match.call(), 
                 coefficients = beta.spp, coef.sites = beta.sites,
-                f.perms = f.perms, design.matrix = rhs)
+                f.perms = f.perms, model.matrix = rhs, terms = Terms)
     class(out) <- "adonis"
     out
 }

Modified: branches/1.15/R/print.adonis.R
===================================================================
--- branches/1.15/R/print.adonis.R	2009-01-18 07:02:22 UTC (rev 666)
+++ branches/1.15/R/print.adonis.R	2009-01-18 14:29:54 UTC (rev 667)
@@ -3,6 +3,6 @@
 {
     cat("\nCall:\n")
     cat(deparse(x$call), "\n\n")
-    printCoefmat(x$aov.tab, eps = 1/nrow(x$f.perms), na.print = "")
+    printCoefmat(x$aov.tab,  na.print = "")
     invisible(x)
 }

Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog	2009-01-18 07:02:22 UTC (rev 666)
+++ branches/1.15/inst/ChangeLog	2009-01-18 14:29:54 UTC (rev 667)
@@ -5,6 +5,10 @@
 
 Version 1.15-2 (opened January 14, 2009)
 
+	* merged r559, r662, r663, r664: adonis adds one both to numerator
+	and denominator in permuation tests, increases default number of
+	permutations from 5 to 999, and gains a 'terms' component.
+
 	* merged r660: Rd parser v2 fixes to make vegan R 2.9.0-ready.
 
 	* merged r652, r657: cleaner output of summary.cca in unconstrained

Modified: branches/1.15/man/adonis.Rd
===================================================================
--- branches/1.15/man/adonis.Rd	2009-01-18 07:02:22 UTC (rev 666)
+++ branches/1.15/man/adonis.Rd	2009-01-18 14:29:54 UTC (rev 667)
@@ -11,7 +11,7 @@
   matrices; uses a permutation test with pseudo-F ratios.}
 
 \usage{
-adonis(formula, data, permutations = 5, method = "bray",
+adonis(formula, data, permutations = 999, method = "bray",
        strata = NULL, contr.unordered = "contr.sum",
        contr.ordered = "contr.poly", ...)
 }
@@ -123,6 +123,9 @@
   \item{f.perms}{ an \eqn{N} by \eqn{m} matrix of the null \eqn{F}
     statistics for each source of variation  based on \eqn{N}
     permutations of the data.}
+  \item{model.matrix}{The \code{\link{model.matrix}} for the right hand
+    side of the formula.}
+  \item{terms}{The \code{\link{terms}} component of the model.}
 }
 \references{
 Anderson, M.J. 2001. A new method for non-parametric multivariate
@@ -158,7 +161,7 @@
 \examples{
 data(dune)
 data(dune.env)
-adonis(dune ~ Management*A1, data=dune.env, permutations=100)
+adonis(dune ~ Management*A1, data=dune.env, permutations=99)
 }
 
 \keyword{multivariate }



More information about the Vegan-commits mailing list