[Vegan-commits] r2365 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 13 15:35:08 CET 2013
Author: jarioksa
Date: 2013-01-13 15:35:07 +0100 (Sun, 13 Jan 2013)
New Revision: 2365
Modified:
pkg/vegan/R/stressplot.wcmdscale.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/stressplot.wcmdscale.Rd
Log:
stressplot implemented for partial capscale and cca
Modified: pkg/vegan/R/stressplot.wcmdscale.R
===================================================================
--- pkg/vegan/R/stressplot.wcmdscale.R 2013-01-13 11:36:48 UTC (rev 2364)
+++ pkg/vegan/R/stressplot.wcmdscale.R 2013-01-13 14:35:07 UTC (rev 2365)
@@ -69,17 +69,14 @@
`stressplot.cca` <-
function(object, k = 2, pch, p.col = "blue", l.col = "red", lwd = 2, ...)
{
- ## Not yet done for pCCA
- if (!is.null(object$pCCA))
- stop("not implemented yet for partial CCA")
## Normalized scores to reconstruct data
u <- cbind(object$CCA$u, object$CA$u)
sev <- sqrt(c(object$CCA$eig, object$CA$eig))
w <- sqrt(object$rowsum)
u <- diag(w) %*% u %*% diag(sev)
## Distances
- dis <- dist(u)
- odis <- dist(u[,1:k, drop = FALSE])
+ dis <- dist(cbind(u, object$pCCA$Fit))
+ odis <- dist(cbind(u[,seq_len(k), drop = FALSE], object$pCCA$Fit))
##odis <- dist(sweep(Xbar, 2, sqrt(object$colsum), "*"))
## plot like above
## Plot
@@ -97,21 +94,21 @@
`stressplot.capscale` <-
function(object, k = 2, pch, p.col = "blue", l.col = "red", lwd = 2, ...)
{
- ## Not yet done for pRDA
- if (!is.null(object$pCCA))
- stop("not implemented yet for partial analysis")
- ## Normalized scores to reconstruct data
+ ## Scores to reconstruct data
u <- cbind(object$CCA$u, object$CA$u)
ev <- c(object$CCA$eig, object$CA$eig)
- ## normalizing constant
- const <- sqrt(ev)
+ u <- u %*% diag(sqrt(ev))
+ if (!is.null(object$pCCA))
+ pFit <- object$pCCA$Fit/sqrt(nrow(object$pCCA$Fit) - 1)
+ else
+ pFit <- NULL
## Distances
- dis <- dist(u %*% diag(const))
+ dis <- dist(cbind(u, pFit))
if (!is.null(object$CA$imaginary.u.eig))
dis <- sqrt(dis^2 - dist(object$CA$imaginary.u.eig)^2)
if (!is.null(object$ac))
dis <- dis - object$ac
- odis <- dist(u[,1:k, drop=FALSE] %*% diag(const[1:k], nrow = k))
+ odis <- dist(cbind(u[,seq_len(k), drop=FALSE], pFit))
## plot like above
## Plot
if (missing(pch))
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-01-13 11:36:48 UTC (rev 2364)
+++ pkg/vegan/inst/ChangeLog 2013-01-13 14:35:07 UTC (rev 2365)
@@ -21,7 +21,9 @@
are found from the full space solution, and in capscale() and
wcmdscale() they are correct for the imaginary axes. The weights
are used in wcmdscale() and cca() so that their distances differ
- from plotted ordinations, but agree with eigenvalues.
+ from plotted ordinations, but agree with eigenvalues. Partial
+ models (p-dbRDA, pRDA, pCCA) add the partial component both to the
+ original dissimilarities and the fit.
* 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-13 11:36:48 UTC (rev 2364)
+++ pkg/vegan/man/stressplot.wcmdscale.Rd 2013-01-13 14:35:07 UTC (rev 2365)
@@ -60,6 +60,13 @@
\code{\link{capscale}} with argument \code{add = TRUE} to avoid
negative eigenvalues, the ordination distances will exceed the
observed dissimilarities by the additive constant.
+
+ In partial ordination (\code{\link{cca}}, \code{\link{rda}} and
+ \code{\link{capscale}} with \code{Condition} in the formula), the
+ distances in the partial component are included both in the observed
+ distances and in ordination distances. With \code{k=0}, the
+ ordination distances refer to the partial ordination.
+
}
\value{
More information about the Vegan-commits
mailing list