[Vegan-commits] r2359 - in pkg/vegan: . R inst man tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 10 14:37:22 CET 2013
Author: jarioksa
Date: 2013-01-10 14:37:21 +0100 (Thu, 10 Jan 2013)
New Revision: 2359
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/stressplot.wcmdscale.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/stressplot.wcmdscale.Rd
pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
add stressplot for prcomp and princomp
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2013-01-10 09:49:01 UTC (rev 2358)
+++ pkg/vegan/NAMESPACE 2013-01-10 13:37:21 UTC (rev 2359)
@@ -408,6 +408,8 @@
S3method(stressplot, capscale)
S3method(stressplot, cca)
S3method(stressplot, rda)
+S3method(stressplot, prcomp)
+S3method(stressplot, princomp)
# summary: base
S3method(summary, anosim)
S3method(summary, bioenv)
Modified: pkg/vegan/R/stressplot.wcmdscale.R
===================================================================
--- pkg/vegan/R/stressplot.wcmdscale.R 2013-01-10 09:49:01 UTC (rev 2358)
+++ pkg/vegan/R/stressplot.wcmdscale.R 2013-01-10 13:37:21 UTC (rev 2359)
@@ -126,3 +126,37 @@
abline(0, 1, col = l.col, lwd = lwd, ...)
invisible(odis)
}
+
+## Standard R PCA functions
+
+`stressplot.prcomp` <-
+ function(object, k = 2, pch, p.col = "blue", l.col = "red", lwd = 2, ...)
+{
+ dis <- dist(object$x)
+ odis <- dist(object$x[, 1:k, drop = FALSE])
+ if (missing(pch))
+ if (length(dis) > 5000)
+ pch <- "."
+ else
+ pch <- 1
+ plot(dis, odis, pch = pch, col = p.col, xlab = "Observed Dissimilarity",
+ ylab = "Ordination Distance", ...)
+ abline(0, 1, col = l.col, lwd = lwd, ...)
+ invisible(odis)
+}
+
+`stressplot.princomp` <-
+ function(object, k = 2, pch, p.col = "blue", l.col = "red", lwd = 2, ...)
+{
+ dis <- dist(object$scores)
+ odis <- dist(object$scores[, 1:k, drop = FALSE])
+ if (missing(pch))
+ if (length(dis) > 5000)
+ pch <- "."
+ else
+ pch <- 1
+ plot(dis, odis, pch = pch, col = p.col, xlab = "Observed Dissimilarity",
+ ylab = "Ordination Distance", ...)
+ abline(0, 1, col = l.col, lwd = lwd, ...)
+ invisible(odis)
+}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-01-10 09:49:01 UTC (rev 2358)
+++ pkg/vegan/inst/ChangeLog 2013-01-10 13:37:21 UTC (rev 2359)
@@ -13,15 +13,15 @@
the value of the additive constant with 'add = TRUE'.
* stressplot: added stressplot() methods for wcmdscale(),
- capscale(), cca() and rda() results. These also work with
- constrained ordination, but not with the partial ordination (at
- least not yet). These methods display the ordination distances in
- given number of dimensions (defaults 'k = 2') against original
- observed distances. These original distances are found from the
- full space solution, and in capscale() and wcmdscale() they are
- correct for the imaginary axes. The weights are not used in
- wcmdscale() and cca(): I must first figure out if they should be
- used or ignored.
+ capscale(), cca(), rda(), prcomp() and princomp() results. These
+ also work with constrained ordination, but not with the partial
+ ordination (at least not yet). These methods display the
+ ordination distances in given number of dimensions (defaults 'k =
+ 2') against original observed distances. These original distances
+ are found from the full space solution, and in capscale() and
+ wcmdscale() they are correct for the imaginary axes. The weights
+ are not used in wcmdscale() and cca(): I must first figure out if
+ they should be used or ignored.
* wcmdscale: added method functions print(), plot() and
scores(). Now class "wcmdscale" results also retun the function
Modified: pkg/vegan/man/stressplot.wcmdscale.Rd
===================================================================
--- pkg/vegan/man/stressplot.wcmdscale.Rd 2013-01-10 09:49:01 UTC (rev 2358)
+++ pkg/vegan/man/stressplot.wcmdscale.Rd 2013-01-10 13:37:21 UTC (rev 2359)
@@ -3,6 +3,8 @@
\alias{stressplot.cca}
\alias{stressplot.rda}
\alias{stressplot.capscale}
+\alias{stressplot.prcomp}
+\alias{stressplot.princomp}
\title{
Display Ordination Distances Against Observed Distances in Eigenvector Ordinations
@@ -16,7 +18,8 @@
with \code{\link{metaMDS}} or \code{\link{monoMDS}}), but shows the
linear relationship of the eigenvector ordinations. The
\code{stressplot} methods are available for \code{\link{wcmdscale}},
- \code{\link{rda}}, \code{\link{cca}} and \code{\link{capscale}}.
+ \code{\link{rda}}, \code{\link{cca}}, \code{\link{capscale}},
+ \code{\link{prcomp}} and \code{\link{princomp}}.
}
\usage{
@@ -53,7 +56,10 @@
\code{\link{wcmdscale}} or \code{\link{capscale}}) with negative
eigenvalues the ordination distances can exceed the observed distances
in real dimensions; the imaginary dimensions with negative eigenvalues
- will correct these excess distances.
+ will correct these excess distances. If you have used
+ \code{\link{capscale}} with argument \code{add = TRUE} to avoid
+ negative eigenvalues, the ordination distances will exceed the
+ observed dissimilarities by the additive constant.
}
\value{
Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-01-10 09:49:01 UTC (rev 2358)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-01-10 13:37:21 UTC (rev 2359)
@@ -161,7 +161,7 @@
Formula:
y ~ poly(x1, 1) + poly(x2, 1)
-<environment: 0x27d9338>
+<environment: 0x2ca4338>
Total model degrees of freedom 3
GCV score: 0.04278782
@@ -4912,7 +4912,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x9181780>
+<environment: 0x94283c0>
Estimated degrees of freedom:
6.45 total = 7.45
@@ -4928,7 +4928,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x9cff1b8>
+<environment: 0x9c4f678>
Estimated degrees of freedom:
6.12 total = 7.12
@@ -5088,7 +5088,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x782f2c8>
+<environment: 0x8bcd578>
Estimated degrees of freedom:
8.93 total = 9.93
@@ -5101,7 +5101,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x9797dc8>
+<environment: 0x9370d28>
Estimated degrees of freedom:
7.75 total = 8.75
@@ -5114,7 +5114,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x9786660>
+<environment: 0x9b14638>
Estimated degrees of freedom:
8.9 total = 9.9
@@ -6881,7 +6881,7 @@
> ### Title: Display Ordination Distances Against Observed Distances in
> ### Eigenvector Ordinations
> ### Aliases: stressplot.wcmdscale stressplot.cca stressplot.rda
-> ### stressplot.capscale
+> ### stressplot.capscale stressplot.prcomp stressplot.princomp
> ### Keywords: multivariate
>
> ### ** Examples
@@ -7691,7 +7691,7 @@
Formula:
y ~ s(x1, x2, k = knots)
-<environment: 0x876fd18>
+<environment: 0x3ac4fa8>
Estimated degrees of freedom:
2 total = 3
@@ -8171,7 +8171,7 @@
> ### * <FOOTER>
> ###
> cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 27.421 0.132 27.652 0 0
+Time elapsed: 26.573 0.116 26.874 0 0
> grDevices::dev.off()
null device
1
More information about the Vegan-commits
mailing list