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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 31 16:17:36 CET 2010


Author: jarioksa
Date: 2010-12-31 16:17:36 +0100 (Fri, 31 Dec 2010)
New Revision: 1429

Modified:
   pkg/vegan/R/CCorA.R
   pkg/vegan/inst/ChangeLog
Log:
PL fixed CCorA

Modified: pkg/vegan/R/CCorA.R
===================================================================
--- pkg/vegan/R/CCorA.R	2010-12-31 07:53:23 UTC (rev 1428)
+++ pkg/vegan/R/CCorA.R	2010-12-31 15:17:36 UTC (rev 1429)
@@ -1,7 +1,6 @@
 `CCorA` <-
     function(Y, X, stand.Y = FALSE, stand.X = FALSE, nperm = 0, ...)
 {
-    require(MASS) || stop("Requires package 'MASS'")
     epsilon <- sqrt(.Machine$double.eps)
     ##
     ## BEGIN: Internal functions
@@ -78,7 +77,6 @@
         }
     if(nY != nX) stop("Different numbers of rows in Y and X")
     n <- nY
-    if((p+q) >= (n-1)) stop("Not enough degrees of freedom: (p+q) >= (n-1)")
     if(is.null(rownames(X)) & is.null(rownames(Y))) {
         rownoms <- paste("Obj", 1:n, sep="")
         } else {
@@ -104,6 +102,9 @@
     X <- temp$mat
     qq <- temp$m
     rownames(X) <- rownoms
+    ## Correction PL, 26dec10
+    if(max(pp,qq) >= (n-1)) 
+    	stop("Not enough degrees of freedom: max(pp,qq) >= (n-1)")
     ## Covariance matrices, etc. from the PCA scores
     S11 <- cov(Y)
     if(sum(abs(S11)) < epsilon) return(0)
@@ -129,8 +130,8 @@
     V <- K.svd$v
     A <- S11.chol.inv %*% U
     B <- S22.chol.inv %*% V
-    Cy <- (Y %*% A)/sqrt(n-1)
-    Cx <- (X %*% B)/sqrt(n-1)
+    Cy <- (Y %*% A)    # Correction 27dec10: remove /sqrt(n-1)
+    Cx <- (X %*% B)    # Correction 27dec10: remove /sqrt(n-1)
     ## Compute the 'Biplot scores of Y and X variables' a posteriori --
     corr.Y.Cy <- cor(Y.c, Cy)  # To plot Y in biplot in space Y
     corr.Y.Cx <- cor(Y.c, Cx)  # Available for plotting Y in space of X

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-12-31 07:53:23 UTC (rev 1428)
+++ pkg/vegan/inst/ChangeLog	2010-12-31 15:17:36 UTC (rev 1429)
@@ -7,6 +7,9 @@
 	* new version opened with the release of vegan 1.17-5 (submitted
 	Dec 17, 2010, released at CRAN on on Dec 18, 2010).
 
+	* CCorA: Pierre Legendre's minor fixes, including scaling of
+	scores Cy an Cx, and removing requirement of MASS.
+
 	* metaMDS: function was written for community data with all
 	entries non-negative, but it is used increasingly often with other
 	data types with a risk of failure (especially in wascores()). Now



More information about the Vegan-commits mailing list