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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 20 08:44:08 CET 2013


Author: jarioksa
Date: 2013-02-20 08:44:07 +0100 (Wed, 20 Feb 2013)
New Revision: 2448

Modified:
   pkg/vegan/R/metaMDSiter.R
   pkg/vegan/R/print.monoMDS.R
   pkg/vegan/inst/ChangeLog
Log:
metaMDS(..., trace = 2) prints convergence info with engine = 'monoMDS'

Modified: pkg/vegan/R/metaMDSiter.R
===================================================================
--- pkg/vegan/R/metaMDSiter.R	2013-02-19 10:11:50 UTC (rev 2447)
+++ pkg/vegan/R/metaMDSiter.R	2013-02-20 07:44:07 UTC (rev 2448)
@@ -13,7 +13,17 @@
     RMSELIM <- 0.005
     SOL <- FALSE
     converged <- FALSE
+    ## set tracing for engines
     isotrace <- max(0, trace - 1)
+    monotrace <- engine == "monoMDS" && trace > 1
+    monostop <- function(mod) {
+        lab <- switch(mod$icause,
+                      "no. of iterations >= maxit",
+                      "stress < smin",
+                      "change of stress < sratmax",
+                      "scale factor of the gradient < sfgrmin")
+        cat("   ", mod$iters, "iterations: ", lab, "\n")
+    }
     ## Previous best or initial configuration 
     if (!missing(previous.best) && !is.null(previous.best)) {
         ## check if previous.best is from metaMDS or isoMDS
@@ -57,6 +67,8 @@
     }
     if (trace) 
         cat("Run 0 stress", s0$stress, "\n")
+    if (monotrace)
+        monostop(s0)
     tries <- 0
     ## Prepare for parallel processing
     if (is.null(parallel) && getRversion() >= "2.15.0")
@@ -109,9 +121,10 @@
         ## analyse results of 'nclus' tries
         for (i in 1:nclus) {
             tries <- tries + 1
-            if (trace) {
+            if (trace)
                 cat("Run", tries, "stress", stry[[i]]$stress, "\n")
-            }
+            if (monotrace)
+                monostop(stry[[i]])
             if ((s0$stress - stry[[i]]$stress) > -EPS) {
                 pro <- procrustes(s0, stry[[i]], symmetric = TRUE)
                 if (plot && k > 1) 

Modified: pkg/vegan/R/print.monoMDS.R
===================================================================
--- pkg/vegan/R/print.monoMDS.R	2013-02-19 10:11:50 UTC (rev 2447)
+++ pkg/vegan/R/print.monoMDS.R	2013-02-20 07:44:07 UTC (rev 2448)
@@ -31,10 +31,10 @@
         cat(", rotated to principal components")
     cat("\n")
     stoplab <- switch(x$icause,
-                      "Maximum number of iteration reached",
-                      "Stress nearly zero",
-                      "Stress nearly unchanged",
-                      "Scale factor of gradient nearly zero")
+                      "Maximum number of iterations (maxit) reached",
+                      "Stress nearly zero (< smin)",
+                      "Stress nearly unchanged (change < sratmax)",
+                      "Scale factor of gradient nearly zero (< sfgrmin)")
     cat("Stopped after ", x$iters, " iterations: ", stoplab, "\n", sep="")
     invisible(x)
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-02-19 10:11:50 UTC (rev 2447)
+++ pkg/vegan/inst/ChangeLog	2013-02-20 07:44:07 UTC (rev 2448)
@@ -8,8 +8,10 @@
 	11, 2013.
 
 	* metaMDS: exposed argument 'maxit' in metaMDSiter() so that users
-	can set the number of iterations in monoMDS() or isoMDS(). After a
-	wish by Jon Bakker, Univ Washington (U.S.A.).
+	can set the number of iterations in monoMDS() or isoMDS().
+	metaMDS(..., trace = 2) show the stopping criterion used in with
+	engine = "monoMDS". After wishes by Jon Bakker, Univ Washington
+	(U.S.A.).
 
 	* tabasco: a sister function of vegemite() to display a compact
 	community table using heatmap(). Both vegemite() and tabasco() can



More information about the Vegan-commits mailing list