[Vegan-commits] r2751 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 24 15:50:18 CET 2013
Author: jarioksa
Date: 2013-11-24 15:50:17 +0100 (Sun, 24 Nov 2013)
New Revision: 2751
Modified:
pkg/vegan/R/anovacca.byterm.R
pkg/vegan/R/permutest.cca.R
Log:
handle one axis and one constraint cases in anovacca by=
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-11-24 13:54:51 UTC (rev 2750)
+++ pkg/vegan/R/anovacca.byterm.R 2013-11-24 14:50:17 UTC (rev 2751)
@@ -67,6 +67,9 @@
Fstat <- (Chisq/Df)/(chibig/dfbig)
## Simulated F-values
Fval <- sapply(mods, function(x) x$den)
+ ## Had we an empty model we need to clone the denominator
+ if (length(Fval) == 1)
+ Fval <- matrix(Fval, nrow=nperm)
Fval <- sweep(Fval, 1, big$den, "-")
Fval <- sweep(Fval, 2, Df, "/")
Fval <- sweep(Fval, 1, scale, "/")
@@ -97,10 +100,16 @@
Pvals <- numeric(length(eig))
environment(object$terms) <- environment()
for (i in 1:length(eig)) {
- Partial <- LC[,-i]
- mod <- permutest(update(object, . ~ . + Condition(Partial)),
- permutations, model = model,
- parellel = parallel)
+ Partial <- LC[,-i, drop = FALSE]
+ ## only one axis, and cannot partial out?
+ if (!ncol(Partial))
+ mod <- permutest(object, permutations, model = model,
+ parallel = parallel)
+ else
+ mod <-
+ permutest(update(object, . ~ . + Condition(Partial)),
+ permutations, model = model,
+ parellel = parallel)
Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1)
}
out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi),
Modified: pkg/vegan/R/permutest.cca.R
===================================================================
--- pkg/vegan/R/permutest.cca.R 2013-11-24 13:54:51 UTC (rev 2750)
+++ pkg/vegan/R/permutest.cca.R 2013-11-24 14:50:17 UTC (rev 2751)
@@ -13,7 +13,7 @@
if (is.null(x$CCA)) {
sol <- list(call = match.call(), testcall = x$call, model = NA,
F.0 = NA, F.perm = NA, chi = c(0, x$CA$tot.chi),
- num = 0, den = 0,
+ num = 0, den = x$CA$tot.chi,
df = c(0, nrow(x$CA$u) - max(x$pCCA$rank,0) - 1),
nperm = 0, method = x$method, first = FALSE,
Random.seed = NA)
More information about the Vegan-commits
mailing list