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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 24 15:25:59 CEST 2012


Author: jarioksa
Date: 2012-05-24 15:25:59 +0200 (Thu, 24 May 2012)
New Revision: 2184

Modified:
   pkg/vegan/R/metaMDS.R
   pkg/vegan/R/monoMDS.R
   pkg/vegan/R/print.metaMDS.R
   pkg/vegan/R/print.monoMDS.R
   pkg/vegan/inst/ChangeLog
Log:
Warn about "too good stress" only in metaMDS

Assume that users of monoMDS know what they are doing
and do not warn them. Also no permanent print messages,
but only a run-time warning. 

Reverts commits r2150, 2172, 2179, 2181.


Modified: pkg/vegan/R/metaMDS.R
===================================================================
--- pkg/vegan/R/metaMDS.R	2012-05-24 12:15:27 UTC (rev 2183)
+++ pkg/vegan/R/metaMDS.R	2012-05-24 13:25:59 UTC (rev 2184)
@@ -37,6 +37,12 @@
     out <- metaMDSiter(dis, k = k, trymax = trymax, trace = trace, 
                        plot = plot, previous.best = previous.best,
                        engine = engine, ...)
+    ## Nearly zero stress is usually not a good thing but a symptom of
+    ## a problem: you may have insufficient data for NMDS
+    if (out$stress < 1e-3) {
+        warning(gettextf("Stress is (nearly) zero - you may have insufficient data:\n  %d dimensions x %d points = %d estimated scores with %d dissimilarities",
+                out$ndim, out$nobj, out$ndim * out$nobj, out$ndis))
+    }     
     points <- postMDS(out$points, dis, plot = max(0, plot - 1), ...)
     if (is.null(rownames(points))) 
         rownames(points) <- rownames(comm)

Modified: pkg/vegan/R/monoMDS.R
===================================================================
--- pkg/vegan/R/monoMDS.R	2012-05-24 12:15:27 UTC (rev 2183)
+++ pkg/vegan/R/monoMDS.R	2012-05-24 13:25:59 UTC (rev 2184)
@@ -91,9 +91,6 @@
     }
     ## ndis: number of >0 dissimilarities (distinct points)
     ndis <- length(dist)
-    if (ndis <= k * nobj)
-        warning(gettextf("Not enough data: you have %d dissimilarities >0,\n  and you ask %d scores (%d dimensions times %d points)",
-                         ndis, k * nobj, k, nobj))
     ## starting configuration
     if (missing(y)) {
         y <- matrix(runif(nobj*k, -1, 1), nobj, k)

Modified: pkg/vegan/R/print.metaMDS.R
===================================================================
--- pkg/vegan/R/print.metaMDS.R	2012-05-24 12:15:27 UTC (rev 2183)
+++ pkg/vegan/R/print.metaMDS.R	2012-05-24 13:25:59 UTC (rev 2184)
@@ -23,11 +23,6 @@
     } else {
         cat("No convergent solutions - best solution after", 
             x$tries, "tries\n")
-        if (x$stress < 1e-3) {
-            cat("Stress is (nearly) zero - you may have too few points for NMDS:\n")
-            cat(gettextf("You have %d dissimilarities >0, and you ask for %d scores\n", sum(x$dist > 0), prod(dim(x$points))))
-            cat(gettextf("(%d points x %d dimensions).\n", nrow(x$points), ncol(x$points)))
-        }                 
     }
     z <- x$points
     scal <- c(if (attr(z, "centre")) "centring",

Modified: pkg/vegan/R/print.monoMDS.R
===================================================================
--- pkg/vegan/R/print.monoMDS.R	2012-05-24 12:15:27 UTC (rev 2183)
+++ pkg/vegan/R/print.monoMDS.R	2012-05-24 13:25:59 UTC (rev 2184)
@@ -36,13 +36,6 @@
                       "Stress nearly unchanged",
                       "Scale factor of gradient nearly zero")
     cat("Stopped after ", x$iters, " iterations: ", stoplab, "\n", sep="")
-    if (x$stress < 1e-3) {
-        cat("Stress is (nearly) zero: check your analysis\n")
-        ndis <- sum(x$dist > 0)
-        pdim <- dim(x$points)
-        cat(gettextf("You asked % d scores (%d points x %d dimensions)\nand  you have %d dissimilarities > 0\n",
-                    prod(pdim), pdim[1], pdim[2], ndis))
-    }
     invisible(x)
 }
 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-05-24 12:15:27 UTC (rev 2183)
+++ pkg/vegan/inst/ChangeLog	2012-05-24 13:25:59 UTC (rev 2184)
@@ -19,8 +19,14 @@
 	ordihull() is similar to ordiellipse(). The labels are centred
 	more correctly.
 
-	* monoMDS: Count only above-zero non-NA dissimilarities for the
-	absolute lower limit of sufficient data. 
+	* metaMDS: A warning is issued on too good stress (zero or nearly
+	zero).  This is often a symptom of insufficient data.  In general,
+	you need n > 2*k + 1 points for k dimensions, and Kruskal's advice
+	is to have n > 4*k + 1.  With low number of points there can be
+	several complete (zero stress) but different results, and no two
+	convergent solution can be found.  The warning is issued also when
+	convergence was obtained, and information on dimensions is
+	printed.  FAQ gained an entry on the issue.
 
 	* bioenv: accepts now dissimilarities or a square matrix that can
 	interpred as dissimilarities instead of a community data frame.



More information about the Vegan-commits mailing list