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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 9 16:29:18 CET 2011


Author: jarioksa
Date: 2011-01-09 16:29:17 +0100 (Sun, 09 Jan 2011)
New Revision: 1446

Modified:
   pkg/vegan/R/fitted.capscale.R
   pkg/vegan/R/predict.rda.R
   pkg/vegan/inst/ChangeLog
Log:
revome 'ac' when reconstituting distances from capscale()

Modified: pkg/vegan/R/fitted.capscale.R
===================================================================
--- pkg/vegan/R/fitted.capscale.R	2011-01-09 15:15:04 UTC (rev 1445)
+++ pkg/vegan/R/fitted.capscale.R	2011-01-09 15:29:17 UTC (rev 1446)
@@ -10,8 +10,11 @@
                 CA = object$CA$u.eig,
                 Imaginary = object$CA$imaginary.u.eig)
     ## Distances or working scores U
-    if (type == "response")
-        dist(U)
-    else
-        U
+    if (type == "response") {
+        U <- dist(U)
+        ## remove additive constant (if add = TRUE)
+        if (!is.null(object$ac))
+            U <- U - object$ac
+    }
+    U
 }

Modified: pkg/vegan/R/predict.rda.R
===================================================================
--- pkg/vegan/R/predict.rda.R	2011-01-09 15:15:04 UTC (rev 1445)
+++ pkg/vegan/R/predict.rda.R	2011-01-09 15:29:17 UTC (rev 1446)
@@ -30,8 +30,11 @@
                          newdata = newdata, rank = take)
         }
         if (inherits(object, "capscale")) {
-            if (take > 0)
+            if (take > 0) {
                 out <- dist(u %*% slam/sqrt(nr))
+                if (!is.null(object$ac))
+                    out <- out - object$ac
+            }
         } else {
             if (take > 0) 
                 out <- u %*% slam %*% t(v)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-01-09 15:15:04 UTC (rev 1445)
+++ pkg/vegan/inst/ChangeLog	2011-01-09 15:29:17 UTC (rev 1446)
@@ -6,6 +6,10 @@
 
 	* capscale: return additive constant ('ac') when 'add = TRUE'. 
 
+	* fitted.capscale, predict.rda: additive constant ('ac')
+	subtracted from the estimated distances when 'add = TRUE' was used
+	in capscale().
+
 Version 1.18-20 (closed January 9, 2011)
 
 	* capscale: the total inertia was defined as the sum of absolute



More information about the Vegan-commits mailing list