[Vegan-commits] r2368 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 14 09:32:51 CET 2013


Author: jarioksa
Date: 2013-01-14 09:32:50 +0100 (Mon, 14 Jan 2013)
New Revision: 2368

Modified:
   pkg/vegan/R/stressplot.wcmdscale.R
Log:
dist(u%*%t(v)) implemented for CCA similarly as r2366 for RDA

Modified: pkg/vegan/R/stressplot.wcmdscale.R
===================================================================
--- pkg/vegan/R/stressplot.wcmdscale.R	2013-01-14 07:57:24 UTC (rev 2367)
+++ pkg/vegan/R/stressplot.wcmdscale.R	2013-01-14 08:32:50 UTC (rev 2368)
@@ -81,12 +81,18 @@
     sev <- sqrt(c(object$CCA$eig, object$CA$eig))
     w <- sqrt(object$rowsum)
     u <- diag(w) %*% u %*% diag(sev)
+    v <- cbind(object$CCA$v, object$CA$v)
+    v <- diag(sqrt(object$colsum)) %*% v
     ## Distances
-    dis <- dist(cbind(u, object$pCCA$Fit))
-    odis <- dist(cbind(u[,seq_len(k), drop = FALSE], object$pCCA$Fit))
-    ##odis <- dist(sweep(Xbar, 2, sqrt(object$colsum), "*"))
-    ## plot like above
-        ## Plot
+    Xbar <- u %*% t(v)
+    Xbark <- u[,seq_len(k), drop = FALSE] %*% t(v[,seq_len(k), drop = FALSE])
+    if (!is.null(object$pCCA)) {
+        Xbar <- Xbar + object$pCCA$Fit
+        Xbark <- Xbark + object$pCCA$Fit
+    }
+    dis <- dist(Xbar)
+    odis <- dist(Xbark)
+    ## Plot
     if (missing(pch))
         if (length(dis) > 5000)
             pch <- "."



More information about the Vegan-commits mailing list