[Vegan-commits] r1988 - in pkg/vegan: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 12 11:43:24 CET 2011


Author: gsimpson
Date: 2011-11-12 11:43:24 +0100 (Sat, 12 Nov 2011)
New Revision: 1988

Modified:
   pkg/vegan/DESCRIPTION
   pkg/vegan/R/adonis.R
   pkg/vegan/inst/ChangeLog
Log:
fixes bug in adonis not passing transposed matrix to internal f.test function following speed-up in r1636

Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION	2011-11-05 14:04:04 UTC (rev 1987)
+++ pkg/vegan/DESCRIPTION	2011-11-12 10:43:24 UTC (rev 1988)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 2.1-6
-Date: October 30, 2011
+Version: 2.1-7
+Date: November 12, 2011
 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, 
    Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, 
    M. Henry H. Stevens, Helene Wagner  

Modified: pkg/vegan/R/adonis.R
===================================================================
--- pkg/vegan/R/adonis.R	2011-11-05 14:04:04 UTC (rev 1987)
+++ pkg/vegan/R/adonis.R	2011-11-12 10:43:24 UTC (rev 1988)
@@ -10,7 +10,7 @@
     TOL <- 1e-7
     Terms <- terms(formula, data = data)
     lhs <- formula[[2]]
-    lhs <- eval(lhs, data, parent.frame()) # to force evaluation 
+    lhs <- eval(lhs, data, parent.frame()) # to force evaluation
     formula[[2]] <- NULL                # to remove the lhs
     rhs.frame <- model.frame(formula, data, drop.unused.levels = TRUE) # to get the data frame of rhs
     op.c <- options()$contrasts
@@ -67,7 +67,7 @@
     F.Mod <- (SS.Exp.each/df.Exp) / (SS.Res/df.Res)
 
 
-    
+
     f.test <- function(tH, G, df.Exp, df.Res, tIH.snterm) {
       ## HERE I TRY CHANGING t(H)  TO tH, and
       ## t(I - H.snterm) to tIH.snterm, so that we don't have
@@ -76,23 +76,23 @@
       ## G is an n x n centered distance matrix
       ## H is the hat matrix from the design (X)
       ## note that for R, * is element-wise multiplication,
-      ## whereas %*% is matrix multiplication. 
+      ## whereas %*% is matrix multiplication.
         (sum(G * tH)/df.Exp) /
           (sum(G * tIH.snterm)/df.Res) }
-  
+
  ### Old f.test
     ### f.test <- function(H, G, I, df.Exp, df.Res, H.snterm){
     ##    (sum( G * t(H) )/df.Exp) /
       ##    (sum( G * t(I-H.snterm) )/df.Res) }
-    
+
     SS.perms <- function(H, G, I){
         c(SS.Exp.p = sum( G * t(H) ),
           S.Res.p=sum( G * t(I-H) )
           ) }
-    
+
     ## Permutations
     if (length(permutations) == 1) {
-        if (missing(strata)) 
+        if (missing(strata))
             strata <- NULL
         p <- replicate(permutations,
                        permuted.index(n, strata=strata))
@@ -103,14 +103,14 @@
                           ncol(p), n))
         permutations <- ncol(p)
     }
-    
+
     tH.s <- sapply(H.s, t)
     tIH.snterm <- t(I-H.snterm)
     ## Apply permutations for each term
     ## This is the new f.test (2011-06-15) that uses fewer arguments
     f.perms <- sapply(1:nterms, function(i) {
         sapply(1:permutations, function(j) {
-            f.test(H.s[[i]], G[p[,j], p[,j]], df.Exp[i], df.Res, tIH.snterm)
+            f.test(tH.s[[i]], G[p[,j], p[,j]], df.Exp[i], df.Res, tIH.snterm)
         } )
     })
     ## Round to avoid arbitrary P-values with tied data
@@ -128,7 +128,7 @@
                        "Residuals", "Total")
     colnames(tab)[ncol(tab)] <- "Pr(>F)"
     class(tab) <- c("anova", class(tab))
-    out <- list(aov.tab = tab, call = match.call(), 
+    out <- list(aov.tab = tab, call = match.call(),
                 coefficients = beta.spp, coef.sites = beta.sites,
                 f.perms = f.perms, model.matrix = rhs, terms = Terms)
     class(out) <- "adonis"

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-11-05 14:04:04 UTC (rev 1987)
+++ pkg/vegan/inst/ChangeLog	2011-11-12 10:43:24 UTC (rev 1988)
@@ -2,8 +2,14 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 2.1-6 (opened October 30, 2011)
+Version 2.1-7 (opened November 12, 2011)
 
+	* adonis: speed up implemented in r1636 was not passing the
+	transposed matrices to internal f.test function. Reported by
+	Nicholas Lewin-Koh.
+
+Version 2.1-6 (closed November 12, 2011)
+
 	* FAQ: correct mark-up of hyper links (@uref{} instead of @url{}),
 	add new entries on RDA scaling, scaling of NMDS stress and scaling
 	of environmental arrows in cca/rda/capscale/envfit, plus some



More information about the Vegan-commits mailing list