[Vegan-commits] r773 - in branches/1.15: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 31 18:46:53 CEST 2009
Author: jarioksa
Date: 2009-03-31 18:46:53 +0200 (Tue, 31 Mar 2009)
New Revision: 773
Modified:
branches/1.15/R/metaMDS.R
branches/1.15/R/metaMDSdist.R
branches/1.15/R/postMDS.R
branches/1.15/inst/ChangeLog
branches/1.15/man/metaMDS.Rd
Log:
better handling of halfchange scaling merged to branches/1.15 (rev 762, 763, 765)
Modified: branches/1.15/R/metaMDS.R
===================================================================
--- branches/1.15/R/metaMDS.R 2009-03-31 16:33:49 UTC (rev 772)
+++ branches/1.15/R/metaMDS.R 2009-03-31 16:46:53 UTC (rev 773)
@@ -13,11 +13,7 @@
previous.best <- NULL
out <- metaMDSiter(dis, k = k, trymax = trymax, trace = trace,
plot = plot, previous.best = previous.best, ...)
- maxdis <- attr(dis, "maxdis")
- if (is.null(maxdis))
- maxdis <- max(dis)
- points <- postMDS(out$points, dis, plot = max(0, plot - 1),
- halfchange = (maxdis < 1.1), ...)
+ points <- postMDS(out$points, dis, plot = max(0, plot - 1), ...)
if (is.null(rownames(points)))
rownames(points) <- rownames(comm)
if (wascores) {
@@ -34,4 +30,3 @@
class(out) <- "metaMDS"
out
}
-
Modified: branches/1.15/R/metaMDSdist.R
===================================================================
--- branches/1.15/R/metaMDSdist.R 2009-03-31 16:33:49 UTC (rev 772)
+++ branches/1.15/R/metaMDSdist.R 2009-03-31 16:46:53 UTC (rev 773)
@@ -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: branches/1.15/R/postMDS.R
===================================================================
--- branches/1.15/R/postMDS.R 2009-03-31 16:33:49 UTC (rev 772)
+++ branches/1.15/R/postMDS.R 2009-03-31 16:46:53 UTC (rev 773)
@@ -1,5 +1,5 @@
"postMDS" <-
- function (X, dist, pc = TRUE, center = TRUE, halfchange = TRUE,
+ function (X, dist, pc = TRUE, center = TRUE, halfchange,
threshold = 0.8, nthreshold = 10, plot = FALSE, ...)
{
Size <- attributes(dist)$Size
@@ -13,6 +13,16 @@
x <- prcomp(x, center = center)$x
dimnames(x) <- dn
}
+ ## Check halfchange scaling, if not explicitly defined
+ if (missing(halfchange)) {
+ maxdis <- attr(dist, "maxdis")
+ ## play safe: if 'maxdis' is missing or FALSE, skip halfchange
+ ## scaling ('maxdis' is set in metaMDSdist).
+ if (!is.null(maxdis) && maxdis)
+ halfchange <- TRUE
+ else
+ halfchange <- FALSE
+ }
if (halfchange) {
dist <- as.vector(dist)
ordi <- as.vector(vegdist(x, "euclidean"))
@@ -28,6 +38,10 @@
x <- x/hc
}
}
+ if (!halfchange) {
+ scl <- max(dist)/max(vegdist(x, "euclidean"))
+ x <- x*scl
+ }
if (plot && halfchange) {
cross.lim <- 45
if (Size > cross.lim)
Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog 2009-03-31 16:33:49 UTC (rev 772)
+++ branches/1.15/inst/ChangeLog 2009-03-31 16:46:53 UTC (rev 773)
@@ -5,6 +5,10 @@
Version 1.15-2 (opened January 14, 2009)
+ * merger rev 762, 763, 765: better heuristics for detecting
+ open-ended dissimilarities (Euclidean, Manhattan) and triggering
+ half-change scaling. metaMDS honours 'halfchange'.
+
* merged rev532, 596 to ordisurf: returns a grid item of fitted
surface, and gains option for bubble plots of observed values.
Modified: branches/1.15/man/metaMDS.Rd
===================================================================
--- branches/1.15/man/metaMDS.Rd 2009-03-31 16:33:49 UTC (rev 772)
+++ branches/1.15/man/metaMDS.Rd 2009-03-31 16:46:53 UTC (rev 773)
@@ -39,7 +39,7 @@
metaMDSiter(dist, k = 2, trymax = 20, trace = 1, plot = FALSE, previous.best,
...)
initMDS(x, k=2)
-postMDS(X, dist, pc=TRUE, center=TRUE, halfchange=TRUE, threshold=0.8,
+postMDS(X, dist, pc=TRUE, center=TRUE, halfchange, threshold=0.8,
nthreshold=10, plot=FALSE, ...)
metaMDSredist(object, ...)
}
@@ -94,11 +94,15 @@
\item{dist}{Dissimilarity matrix used in multidimensional scaling. }
\item{pc}{Rotate to principal components. }
\item{center}{Centre the configuration. }
- \item{halfchange}{Scale axes to half-change units.}
- \item{threshold}{Largest dissimilarity used in half-change scaling. }
- \item{nthreshold}{ Minimum number of points in half-change scaling. }
- \item{object}{A result object from \code{metaMDS}.}
- \item{...}{Other parameters passed to functions.}
+ \item{halfchange}{Scale axes to half-change units. This defaults
+ \code{TRUE} when dissimilarities were evaluated within
+ \code{metaMDS} and the dissimilarity index has an upper limit of
+ \eqn{1}. If \code{FALSE}, the ordination dissimilarities are scaled
+ to the same range as the input dissimilarities.}
+ \item{threshold}{Largest dissimilarity used in half-change scaling. }
+ \item{nthreshold}{ Minimum number of points in half-change scaling. }
+ \item{object}{A result object from \code{metaMDS}.}
+ \item{...}{Other parameters passed to functions.}
}
\details{
Non-metric Multidimensional Scaling (NMDS) is commonly regarded as the
@@ -183,6 +187,8 @@
halves according to linear regression. Obviously the method is
applicable only for dissimilarity indices scaled to \eqn{0 \ldots 1},
such as Kulczynski, Bray-Curtis and Canberra indices.
+ If half-change scaling is not used, the ordination is
+ scaled to the same range as the original dissimilarities.
\item Species scores: Function adds the species scores to the final
solution as weighted averages using function
More information about the Vegan-commits
mailing list