[Vegan-commits] r2179 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 23 18:47:54 CEST 2012
Author: jarioksa
Date: 2012-05-23 18:47:53 +0200 (Wed, 23 May 2012)
New Revision: 2179
Modified:
pkg/vegan/R/monoMDS.R
pkg/vegan/R/print.metaMDS.R
pkg/vegan/R/print.monoMDS.R
Log:
only warn about insufficient data in NMDS, but more loudly
Modified: pkg/vegan/R/monoMDS.R
===================================================================
--- pkg/vegan/R/monoMDS.R 2012-05-23 15:24:31 UTC (rev 2178)
+++ pkg/vegan/R/monoMDS.R 2012-05-23 16:47:53 UTC (rev 2179)
@@ -90,12 +90,9 @@
nobj <- nrow(mat)
}
## ndis: number of >0 dissimilarities (distinct points)
- ndis <- sum(dist > 0)
- ## some people try to use NMDS with too few points and too many
- ## dimensions
- if (ndis <= k * nobj)
- stop(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))
+ ndis <- length(dist)
+ 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-23 15:24:31 UTC (rev 2178)
+++ pkg/vegan/R/print.metaMDS.R 2012-05-23 16:47:53 UTC (rev 2179)
@@ -17,11 +17,18 @@
cat(", ", c("weak", "strong")[x$ities], " ties", sep = "")
cat("\n")
}
- if (x$converged)
+ if (x$converged) {
cat("Two convergent solutions found after", x$tries,
"tries\n")
- else cat("No convergent solutions - best solution after",
- x$tries, "tries\n")
+ } 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",
if (attr(z, "pc")) "PC rotation",
Modified: pkg/vegan/R/print.monoMDS.R
===================================================================
--- pkg/vegan/R/print.monoMDS.R 2012-05-23 15:24:31 UTC (rev 2178)
+++ pkg/vegan/R/print.monoMDS.R 2012-05-23 16:47:53 UTC (rev 2179)
@@ -36,6 +36,13 @@
"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)
}
More information about the Vegan-commits
mailing list