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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 20 11:55:57 CEST 2011


Author: jarioksa
Date: 2011-10-20 11:55:57 +0200 (Thu, 20 Oct 2011)
New Revision: 1959

Modified:
   pkg/vegan/R/capscale.R
   pkg/vegan/inst/ChangeLog
Log:
capscale could fail if constrained component was (aliased to)
zero rank: see 
https://stat.ethz.ch/pipermail/r-help/2011-October/293077.html


Modified: pkg/vegan/R/capscale.R
===================================================================
--- pkg/vegan/R/capscale.R	2011-10-20 09:50:46 UTC (rev 1958)
+++ pkg/vegan/R/capscale.R	2011-10-20 09:55:57 UTC (rev 1959)
@@ -91,7 +91,7 @@
     if (adjust == 1)
         X$eig <- X$eig/k
     sol <- rda.default(X$points, d$Y, d$Z, ...)
-    if (!is.null(sol$CCA)) {
+    if (!is.null(sol$CCA) && sol$CCA$rank > 0) {
         colnames(sol$CCA$u) <- colnames(sol$CCA$biplot) <- names(sol$CCA$eig) <-
             colnames(sol$CCA$wa) <- colnames(sol$CCA$v) <-
                 paste("CAP", 1:ncol(sol$CCA$u), sep = "")
@@ -118,9 +118,9 @@
         ## NA action after 'subset'
         if (!is.null(d$na.action))
             comm <- comm[-d$na.action, , drop = FALSE]
-        if (!is.null(sol$pCCA)) 
+        if (!is.null(sol$pCCA) && sol$pCCA$rank > 0) 
             comm <- qr.resid(sol$pCCA$QR, comm)
-        if (!is.null(sol$CCA)) {
+        if (!is.null(sol$CCA) && sol$CCA$rank > 0) {
             sol$CCA$v.eig <- t(comm) %*% sol$CCA$u/sqrt(k)
             sol$CCA$v <- sweep(sol$CCA$v.eig, 2, sqrt(sol$CCA$eig), 
                                "/")
@@ -139,7 +139,7 @@
             sol$CCA$v.eig[] <- sol$CCA$v[] <- NA
         sol$colsum <- NA
     }
-    if (!is.null(sol$CCA)) 
+    if (!is.null(sol$CCA) && sol$CCA$rank > 0) 
         sol$CCA$centroids <- centroids.cca(sol$CCA$wa, d$modelframe)
     if (!is.null(sol$CCA$alias)) 
         sol$CCA$centroids <- unique(sol$CCA$centroids)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-10-20 09:50:46 UTC (rev 1958)
+++ pkg/vegan/inst/ChangeLog	2011-10-20 09:55:57 UTC (rev 1959)
@@ -6,6 +6,12 @@
 
 	* opened a new version with the release of vegan 2.0-1 on Oct 20,
 	2011.
+
+	* capscale: could fail if constrained component had zero rank,
+	typically in partial models where constrained component was
+	completely aliased. This was observed when checking an R-News
+	query of October 19, 2011
+	(https://stat.ethz.ch/pipermail/r-help/2011-October/293077.html)
 	
 Version 2.1-4 (opened October 20, 2011)
 



More information about the Vegan-commits mailing list