[Vegan-commits] r2406 - in branches/2.0: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 4 18:45:14 CET 2013
Author: jarioksa
Date: 2013-02-04 18:45:14 +0100 (Mon, 04 Feb 2013)
New Revision: 2406
Modified:
branches/2.0/R/protest.R
branches/2.0/inst/ChangeLog
Log:
merge r2388: faster protest, partly hand crafted
Modified: branches/2.0/R/protest.R
===================================================================
--- branches/2.0/R/protest.R 2013-02-04 17:01:55 UTC (rev 2405)
+++ branches/2.0/R/protest.R 2013-02-04 17:45:14 UTC (rev 2406)
@@ -3,14 +3,26 @@
{
X <- scores(X, display = scores, ...)
Y <- scores(Y, display = scores, ...)
- sol <- procrustes(X, Y, symmetric = TRUE)
+ ## Centre and normalize X & Y here so that the permutations will
+ ## be faster
+ X <- scale(X, scale = FALSE)
+ Y <- scale(Y, scale = FALSE)
+ X <- X/sqrt(sum(X^2))
+ Y <- Y/sqrt(sum(Y^2))
+ ## Transformed X and Y will yield symmetric procrustes() and we
+ ## need not specify that in the call (but we set it symmetric
+ ## after the call).
+ sol <- procrustes(X, Y, symmetric = FALSE)
+ sol$symmetric <- TRUE
sol$t0 <- sqrt(1 - sol$ss)
N <- nrow(X)
perm <- rep(0, permutations)
for (i in 1:permutations) {
take <- permuted.index(N, strata)
- tmp <- procrustes(X, Y[take, ], symmetric = TRUE)$ss
- perm[i] <- sqrt(1 - tmp)
+ ## avoid overhead of procrustes() and only evaluate the
+ ## statistic by svd (hand crafted from r2388 of the devel
+ ## branch).
+ perm[i] <- sum(svd(crossprod(X, Y[take,]), nv = 0, nu = 0)$d)
}
Pval <- (sum(perm >= sol$t0) + 1)/(permutations + 1)
if (!missing(strata)) {
Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog 2013-02-04 17:01:55 UTC (rev 2405)
+++ branches/2.0/inst/ChangeLog 2013-02-04 17:45:14 UTC (rev 2406)
@@ -4,10 +4,15 @@
Version 2.0-6 (opened October 8, 2012)
+ * merge 2404: refer Legendre & Legendre for the vegan rda
+ algorithm.
* merge 2934 (partial, mc): oecosimu handles nestedfun() returning
data.frame. Not merged: checking length of statistic when setting
its name.
* merge 2932,3: matching names in treedive() and treedist().
+ * merge 2388 (partial): faster protest, the part of evaluating the
+ test statistic hand crafted, because parallelizations caused
+ conflicts here.
* merge 2385, 7: protest print, faster sum of squares in procrustes.
* merge 2384: new FAQ entries.
* merge 2383: remove alias to print.wcmdscale.
More information about the Vegan-commits
mailing list