[Vegan-commits] r886 - in pkg/vegan: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 4 16:33:19 CEST 2009


Author: jarioksa
Date: 2009-07-04 16:33:19 +0200 (Sat, 04 Jul 2009)
New Revision: 886

Modified:
   pkg/vegan/R/wcmdscale.R
   pkg/vegan/man/wcmdscale.Rd
Log:
wcmdscale: finally saved the final version & example on neg. eigenvalues for reconstructing dissimilarities

Modified: pkg/vegan/R/wcmdscale.R
===================================================================
--- pkg/vegan/R/wcmdscale.R	2009-07-04 06:58:07 UTC (rev 885)
+++ pkg/vegan/R/wcmdscale.R	2009-07-04 14:33:19 UTC (rev 886)
@@ -34,7 +34,7 @@
     ## If 'k' not given, find it as the number of positive
     ## eigenvalues, and also save negative eigenvalues
     negaxes <- NULL
-    if (missing(k) || k > sum(e$) {
+    if (missing(k) || k > sum(e$value > ZERO)) {
         k <- sum(e$values > ZERO)
         if (any(e$values < 0))
             negaxes <- points[, e$values < 0, drop = FALSE]

Modified: pkg/vegan/man/wcmdscale.Rd
===================================================================
--- pkg/vegan/man/wcmdscale.Rd	2009-07-04 06:58:07 UTC (rev 885)
+++ pkg/vegan/man/wcmdscale.Rd	2009-07-04 14:33:19 UTC (rev 886)
@@ -81,5 +81,12 @@
 ## eigenvalues in CA
 procrustes(ord, ca, choices=1:19, scaling = 1)
 plot(procrustes(ord, ca, choices=1:2, scaling=1))
+## Reconstruction of non-Euclidean distances with negative eigenvalues
+d <- vegdist(dune)
+ord <- wcmdscale(d, eig = TRUE)
+## Only positive eigenvalues:
+cor(d, dist(ord$points))
+## Correction with negative eigenvalues:
+cor(d, sqrt(dist(ord$points)^2 - dist(ord$negaxes)^2))
 }
 \keyword{multivariate}



More information about the Vegan-commits mailing list