[Vegan-commits] r398 - in pkg: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 5 06:14:17 CEST 2008


Author: jarioksa
Date: 2008-06-05 06:14:16 +0200 (Thu, 05 Jun 2008)
New Revision: 398

Modified:
   pkg/R/cca.default.R
   pkg/R/rda.default.R
   pkg/inst/ChangeLog
Log:
constraints are not aliased any longer if their rank is higher than the rank of the community: unstabilizing and DANGEROUS change

Modified: pkg/R/cca.default.R
===================================================================
--- pkg/R/cca.default.R	2008-06-05 03:55:03 UTC (rev 397)
+++ pkg/R/cca.default.R	2008-06-05 04:14:16 UTC (rev 398)
@@ -1,4 +1,4 @@
-"cca.default" <-
+`cca.default` <-
     function (X, Y, Z, ...) 
 {
     ZERO <- 1e-04
@@ -50,9 +50,14 @@
         if (is.null(pCCA)) 
             rank <- Q$rank
         else rank <- Q$rank - pCCA$rank
+        ## save rank of constraints
+        qrank <- rank
         Y <- qr.fitted(Q, Xbar)
         sol <- svd(Y)
+        ## rank of svd can be < qrank
         rank <- min(rank, sum(sol$d > ZERO))
+        if (rank < Q$rank)
+            warning("rank of QR decomposition > rank of svd: trouble ahead")
         ax.names <- paste("CCA", 1:length(sol$d), sep = "")
         colnames(sol$u) <- ax.names
         colnames(sol$v) <- ax.names
@@ -73,7 +78,7 @@
             oo <- Q$pivot
             if (!is.null(pCCA$rank)) 
                 oo <- oo[-(1:pCCA$rank)] - ncol(Z.r)
-            oo <- oo[1:rank]
+            oo <- oo[1:qrank]
             if (length(oo) < ncol(Y.r)) 
                 CCA$alias <- colnames(Y.r)[-oo]
             CCA$biplot <- cor(Y.r[, oo, drop = FALSE], sol$u[, 
@@ -127,3 +132,4 @@
     class(sol) <- "cca"
     sol
 }
+

Modified: pkg/R/rda.default.R
===================================================================
--- pkg/R/rda.default.R	2008-06-05 03:55:03 UTC (rev 397)
+++ pkg/R/rda.default.R	2008-06-05 04:14:16 UTC (rev 398)
@@ -1,4 +1,4 @@
-"rda.default" <-
+`rda.default` <-
     function (X, Y, Z, scale = FALSE, ...) 
 {
     ZERO <- 1e-04
@@ -33,9 +33,14 @@
         if (is.null(pCCA)) 
             rank <- Q$rank
         else rank <- Q$rank - pCCA$rank
+        ## qrank saves the rank of the constraints
+        qrank <- rank
         Y <- qr.fitted(Q, Xbar)
         sol <- svd(Y)
+        ## it can happen that rank < qrank
         rank <- min(rank, sum(sol$d > ZERO))
+        if (rank < Q$rank)
+            warning("rank of QR decomposition > rank of svd: trouble ahead")
         sol$d <- sol$d/sqrt(NR)
         ax.names <- paste("RDA", 1:length(sol$d), sep = "")
         colnames(sol$u) <- ax.names
@@ -57,7 +62,7 @@
             oo <- Q$pivot
             if (!is.null(pCCA$rank)) 
                 oo <- oo[-(1:pCCA$rank)] - ncol(Z.r)
-            oo <- oo[1:rank]
+            oo <- oo[1:qrank]
             if (length(oo) < ncol(Y.r)) 
                 CCA$alias <- colnames(Y.r)[-oo]
             CCA$biplot <- cor(Y.r[, oo, drop = FALSE], sol$u[, 
@@ -105,3 +110,4 @@
     class(sol) <- c("rda", "cca")
     sol
 }
+

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-06-05 03:55:03 UTC (rev 397)
+++ pkg/inst/ChangeLog	2008-06-05 04:14:16 UTC (rev 398)
@@ -9,6 +9,11 @@
 	of the dependent (community) data. Now issues a warning in
 	'print'. This is an ancient problem, but surfaced recently in
 	several places.
+
+	* rda, cca, capscale: constraints are not aliased any more if
+	their rank is higher than the rank of the community data.  Because
+	cca objects are handled by many other functions, this may cause
+	trouble in surprising places and the change is unstabilizing.
 	
 Version 1.14-2 (closed June 5, 2008)
 



More information about the Vegan-commits mailing list