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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 13 16:02:30 CEST 2011


Author: jarioksa
Date: 2011-07-13 16:02:30 +0200 (Wed, 13 Jul 2011)
New Revision: 1680

Modified:
   pkg/vegan/R/metaMDSrotate.R
   pkg/vegan/inst/ChangeLog
Log:
remove NA cases in initial orthogonalization in metaMDSrotate

Modified: pkg/vegan/R/metaMDSrotate.R
===================================================================
--- pkg/vegan/R/metaMDSrotate.R	2011-07-13 12:59:26 UTC (rev 1679)
+++ pkg/vegan/R/metaMDSrotate.R	2011-07-13 14:02:30 UTC (rev 1680)
@@ -14,13 +14,6 @@
         stop(gettextf("function works only with univariate 'vec'"))
     if (!is.numeric(vec))
         stop(gettextf("'vec' must be numeric"))
-    ## scores must be orthogonal for the next loop to work
-    if (N > 2) {
-        pc <- prcomp(x)
-        x <- pc$x
-        if (!all(is.na(sp)))
-            sp <- sp %*% pc$rotation
-    }
     ## vectorfit finds the direction cosine. We rotate first axis to
     ## 'vec' which means that we make other axes orthogonal to 'vec'
     ## one by one
@@ -28,6 +21,14 @@
         keep <- !is.na(vec)
     else
         keep <- !logical(length(vec))
+    ## scores must be orthogonal for the next loop to work
+    if (N > 2) {
+        pc <- prcomp(x[keep,])
+        x <- x %*% pc$rotation
+        if (!all(is.na(sp)))
+            sp <- sp %*% pc$rotation
+    }
+    ## Rotation loop
     for (k in 2:N) {
         rot <- vectorfit(x[keep, c(1,k)], vec[keep], permutations=0)$arrows
         rot <- drop(rot)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-07-13 12:59:26 UTC (rev 1679)
+++ pkg/vegan/inst/ChangeLog	2011-07-13 14:02:30 UTC (rev 1680)
@@ -4,6 +4,11 @@
 
 Version 1.90-1 (opened July 3, 2011)
 
+	* metaMDSrotate: results could be a bit off with NA in
+	environmental vector and >2D solution. The starting scores must be
+	orthogonal, but the initial orthogonalizing PCA was run without
+	removing NA cases.
+
 	* ordiellipse, ordihull, ordispider: will remove NA scores that
 	can appear with na.action in cca/rda/capscale (and perhaps in
 	other cases).



More information about the Vegan-commits mailing list