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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 13 20:24:26 CET 2013


Author: jarioksa
Date: 2013-01-13 20:24:26 +0100 (Sun, 13 Jan 2013)
New Revision: 2366

Modified:
   pkg/vegan/R/stressplot.wcmdscale.R
Log:
you need u %*% t(v) instead of only u for stressplot (done only for rda now)

Modified: pkg/vegan/R/stressplot.wcmdscale.R
===================================================================
--- pkg/vegan/R/stressplot.wcmdscale.R	2013-01-13 14:35:07 UTC (rev 2365)
+++ pkg/vegan/R/stressplot.wcmdscale.R	2013-01-13 19:24:26 UTC (rev 2366)
@@ -45,14 +45,21 @@
 {
     ## Normalized scores to reconstruct data
     u <- cbind(object$CCA$u, object$CA$u)
+    v <- cbind(object$CCA$v, object$CA$v)
     ev <- c(object$CCA$eig, object$CA$eig)
     ## normalizing constant
     nr <- NROW(u)
     const <- sqrt(ev * (nr-1))
     u <- u %*% diag(const)
     ## Distances
-    dis <- dist(cbind(u, object$pCCA$Fit))
-    odis <- dist(cbind(u[,seq_len(k), drop=FALSE], object$pCCA$Fit))
+    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 like above
         ## Plot
     if (missing(pch))
@@ -99,7 +106,7 @@
     ev <- c(object$CCA$eig, object$CA$eig)
     u <- u %*% diag(sqrt(ev))
     if (!is.null(object$pCCA))
-        pFit <- object$pCCA$Fit/sqrt(nrow(object$pCCA$Fit) - 1)
+        pFit <- object$pCCA$Fit/object$adjust
     else
         pFit <- NULL
     ## Distances



More information about the Vegan-commits mailing list