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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 27 08:13:56 CET 2009


Author: jarioksa
Date: 2009-03-27 08:13:56 +0100 (Fri, 27 Mar 2009)
New Revision: 763

Modified:
   pkg/vegan/R/metaMDS.R
   pkg/vegan/R/metaMDSdist.R
   pkg/vegan/inst/ChangeLog
Log:
better heuristics of triggering halfchange scaling in metaMDS

Modified: pkg/vegan/R/metaMDS.R
===================================================================
--- pkg/vegan/R/metaMDS.R	2009-03-26 22:12:04 UTC (rev 762)
+++ pkg/vegan/R/metaMDS.R	2009-03-27 07:13:56 UTC (rev 763)
@@ -15,9 +15,9 @@
                        plot = plot, previous.best = previous.best, ...)
     maxdis <- attr(dis, "maxdis")
     if (is.null(maxdis)) 
-        maxdis <- max(dis)
+        maxdis <- abs(max(dis) - 1) < 1e-4
     points <- postMDS(out$points, dis, plot = max(0, plot - 1), 
-                      halfchange = (maxdis < 1.1), ...)
+                      halfchange = maxdis, ...)
     if (is.null(rownames(points))) 
         rownames(points) <- rownames(comm)
     if (wascores) {
@@ -34,4 +34,3 @@
     class(out) <- "metaMDS"
     out
 }
-

Modified: pkg/vegan/R/metaMDSdist.R
===================================================================
--- pkg/vegan/R/metaMDSdist.R	2009-03-26 22:12:04 UTC (rev 762)
+++ pkg/vegan/R/metaMDSdist.R	2009-03-27 07:13:56 UTC (rev 763)
@@ -36,7 +36,12 @@
             warning("Zero dissimilarities changed into ", zero)
         }
     }
-    maxdis <- max(dis)
+    ## We actually used maxdis to decide whether index has a closed
+    ## upper limit, but simple maximum does not give that info.
+    ## Therefore we see if an arbitrary matrix with no shared species
+    ## has distance = 1.
+    maxdis <- abs(distfun(matrix(c(7,0,0,3), 2, 2),
+                      method = distance, ...) - 1) < 1e-4
     if (noshare > 0 && sum(tmp <- no.shared(comm))/length(dis) > noshare) {
         if (trace) 
             cat("Using step-across dissimilarities:\n")

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-03-26 22:12:04 UTC (rev 762)
+++ pkg/vegan/inst/ChangeLog	2009-03-27 07:13:56 UTC (rev 763)
@@ -4,9 +4,13 @@
 
 Version 1.16-16 (openen Mar 25, 2009)
 
-	* metaMDS: scale ordination scores to the same max distance as
+	* metaMDS: scale ordination scores to the same range as
 	input dissimilarities if halfchange = FALSE (not yet documented,
-	still experimental).
+	still experimental). Better heuristics to decide whether to use
+	halfchange scaling: the old heuristics failed if Euclidean or
+	other open-ended dissimilarities were small (max < 1), like after
+	wisconsin() in metaMDSdist. This changes an undocumented internal
+	'maxdis' argument to logical in metaMDSdist.
 
 	* mrpp: reports now "classification strength" when weight.type = 3
 	or weights n*(n-1) are used. Returns mean dissimilarities and



More information about the Vegan-commits mailing list