[Vegan-commits] r329 - in pkg: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 23 15:26:00 CEST 2008


Author: jarioksa
Date: 2008-04-23 15:26:00 +0200 (Wed, 23 Apr 2008)
New Revision: 329

Modified:
   pkg/DESCRIPTION
   pkg/R/adonis.R
   pkg/inst/ChangeLog
Log:
adonis calculates now scores both for the species (when feasible) and for sites (Hank Stevens)

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-04-23 13:18:43 UTC (rev 328)
+++ pkg/DESCRIPTION	2008-04-23 13:26:00 UTC (rev 329)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.12-11
-Date: Apr 19, 2008
+Version: 1.12-12
+Date: Apr 23, 2008
 Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson, 
   M. Henry H. Stevens  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>

Modified: pkg/R/adonis.R
===================================================================
--- pkg/R/adonis.R	2008-04-23 13:18:43 UTC (rev 328)
+++ pkg/R/adonis.R	2008-04-23 13:26:00 UTC (rev 329)
@@ -31,8 +31,10 @@
                            })
     if (inherits(lhs, "dist"))
         dmat <- as.matrix(lhs^2)
-    else
-        dmat <- as.matrix(vegdist(lhs, method=method, ...))^2
+    else {
+        dist.lhs <- as.matrix(vegdist(lhs, method=method, ...))
+        dmat <- dist.lhs^2
+    }
     n <- nrow(dmat)
     I <- diag(n)
     ones <- matrix(1,nrow=n)
@@ -47,8 +49,16 @@
     SS.Res <- sum(diag( ( G %*% (I-H.snterm))))
     df.Exp <- sapply(u.grps[-1], function(i) sum(grps==i) )
     df.Res <- n - qrhs$rank
-    beta <-  qr.coef(qrhs, as.matrix(lhs) )
-    colnames(beta) <- colnames(lhs)
+    ## Get coefficients both for the species (if possible) and sites
+    if (inherits(lhs, "dist")) {
+        beta.sites <- qr.coef(qrhs, as.matrix(lhs))
+        beta.spp <-  NULL
+    } else {
+        beta.sites <- qr.coef(qrhs, dist.lhs)
+        beta.spp <-  qr.coef(qrhs, as.matrix(lhs))
+    }
+    colnames(beta.spp) <- colnames(lhs)
+    colnames(beta.sites) <- rownames(lhs)
     F.Mod <- (SS.Exp.each/df.Exp) / (SS.Res/df.Res)
 
     f.test <- function(H, G, I, df.Exp, df.Res, H.snterm){
@@ -84,7 +94,8 @@
                        "Residuals", "Total")
     colnames(tab)[ncol(tab)] <- "Pr(>F)"
     out <- list(aov.tab = tab, call = match.call(), 
-                coefficients = beta,  f.perms = f.perms, design.matrix = rhs)
+                coefficients = beta.spp, coef.sites = beta.sites,
+                f.perms = f.perms, design.matrix = rhs)
     class(out) <- "adonis"
     out
 }

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-04-23 13:18:43 UTC (rev 328)
+++ pkg/inst/ChangeLog	2008-04-23 13:26:00 UTC (rev 329)
@@ -2,8 +2,14 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 1.12-11 (opened April 19, 2009)
+Version 1.12-12 (opened April 23, 2008)
 
+	* adonis: added calculation of coefficients both for the species
+	(when data matrix was given) and for sites (both with the data
+	matrices and dissimilarities). 
+
+Version 1.12-11 (closed April 23, 2008)
+
 	* adonis: permutation tests fixed. The permutation statistics were
 	wrongly calculated. The results will now be different than in
 	older version, including the example(adonis). Basically, the



More information about the Vegan-commits mailing list