[Vegan-commits] r1081 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 14 19:25:35 CET 2009
Author: jarioksa
Date: 2009-12-14 19:25:35 +0100 (Mon, 14 Dec 2009)
New Revision: 1081
Modified:
pkg/vegan/R/anova.ccabyterm.R
pkg/vegan/R/permutest.cca.R
pkg/vegan/inst/ChangeLog
Log:
avoid arbitrary ordering of tied order statistics by rounding to 12 decimal places
Modified: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R 2009-12-14 17:42:13 UTC (rev 1080)
+++ pkg/vegan/R/anova.ccabyterm.R 2009-12-14 18:25:35 UTC (rev 1081)
@@ -51,8 +51,11 @@
pchi <- sweep(pchi, 1, df, "/")
pchi[-(ntrm + 1), ] <- sweep(pchi[-(ntrm + 1), , drop = FALSE],
2, pchi[ntrm + 1, , drop = FALSE], "/")
+ ## Round to avoid arbitrary P values due to numerical precision
+ pchi <- round(pchi, 12)
+ Fval <- round(Fval, 12)
P <- rowSums(sweep(pchi[-(ntrm + 1), , drop = FALSE], 1,
- Fval[-(ntrm + 1)], ">"))
+ Fval[-(ntrm + 1)], ">="))
P <- c((P + adj)/(step + adj), NA)
out <- data.frame(df, chi, Fval, c(rep(step, ntrm), NA),
P)
Modified: pkg/vegan/R/permutest.cca.R
===================================================================
--- pkg/vegan/R/permutest.cca.R 2009-12-14 17:42:13 UTC (rev 1080)
+++ pkg/vegan/R/permutest.cca.R 2009-12-14 18:25:35 UTC (rev 1081)
@@ -86,6 +86,10 @@
den[i] <- ca.ev
F.perm[i] <- (cca.ev/q)/(ca.ev/r)
}
+ ## Round to avoid arbitrary ordering of statistics due to
+ ## numerical inaccuracy
+ F.0 <- round(F.0, 12)
+ F.perm <- round(F.perm, 12)
sol <- list(call = x$call, model = model, F.0 = F.0, F.perm = F.perm,
chi = c(Chi.z, Chi.xz), num = num, den = den, df = c(q,
r), nperm = permutations, method = x$method, first = first, Random.seed = seed)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-12-14 17:42:13 UTC (rev 1080)
+++ pkg/vegan/inst/ChangeLog 2009-12-14 18:25:35 UTC (rev 1081)
@@ -12,6 +12,12 @@
(r1051), but no R interface. Together with decostand(..., "log")
of r1052 this closes Feature Request #473 submitted by Etienne
Laliberte in R-Forge.
+
+ * anova.cca: tied values could be randomly broken due to
+ numerical precision, and this gave false P-values, for instance in
+ anova(cca(dune ~ Management, dune.env),
+ strata=dune.env$Management). Now rounds statistics to 12 decimal
+ places in permutest.cca and in anova.ccabyterm.
Version 1.16-33 (closed December 13, 2009)
More information about the Vegan-commits
mailing list