From noreply at r-forge.r-project.org Sun Dec 1 00:32:45 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 00:32:45 +0100 (CET)
Subject: [Vegan-commits] r2785 - in pkg/permute: R inst man tests/Examples
Message-ID: <20131130233245.EF41A184F56@r-forge.r-project.org>
Author: gsimpson
Date: 2013-12-01 00:32:45 +0100 (Sun, 01 Dec 2013)
New Revision: 2785
Modified:
pkg/permute/R/numPerms.R
pkg/permute/inst/ChangeLog
pkg/permute/inst/TODO.md
pkg/permute/man/shuffleSet.Rd
pkg/permute/tests/Examples/permute-Ex.Rout.save
Log:
fix a bug in 'numPerms' which was ignoring the 'constant' setting when there were plots and within plot, samples ere freely permuted.
Modified: pkg/permute/R/numPerms.R
===================================================================
--- pkg/permute/R/numPerms.R 2013-11-30 22:17:01 UTC (rev 2784)
+++ pkg/permute/R/numPerms.R 2013-11-30 23:32:45 UTC (rev 2785)
@@ -131,7 +131,11 @@
1
} else if(isTRUE(all.equal(typeW, "free"))) {
if(!is.null(PSTRATA)) {
- prod(factorial(tab))
+ if(constantW) {
+ factorial(tab[1])
+ } else {
+ prod(factorial(tab))
+ }
} else {
exp(lfactorial(n))
}
Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog 2013-11-30 22:17:01 UTC (rev 2784)
+++ pkg/permute/inst/ChangeLog 2013-11-30 23:32:45 UTC (rev 2785)
@@ -17,6 +17,9 @@
* allPerms: fix a bug where the blocks of permutations were being
recombined in the wrong way, by rows instead of by columns.
+ * numPerms: was ignoring the `constant` setting if free permutations
+ within level of plots.
+
Version 0.7-8
* how, Plots: enforces that `blocks` and `strata` are factors, or
Modified: pkg/permute/inst/TODO.md
===================================================================
--- pkg/permute/inst/TODO.md 2013-11-30 22:17:01 UTC (rev 2784)
+++ pkg/permute/inst/TODO.md 2013-11-30 23:32:45 UTC (rev 2785)
@@ -47,7 +47,7 @@
a `call` component and hence can be `update()`ed, hence the nested
calls to `update()`.
- * `permControl` - deprecate this in favour of `how` as in "how to
+ * `permControl` - deprecate this in favour of `how` as in "how to
permute"? *DONE Completed in 0.7-4*
* `permuplot` - this may be fundamentally bust - it only worked in the
@@ -75,6 +75,10 @@
within = Within(type = "free", constant = TRUE))
shuffleSet(20, 10, CTRL)
+ *DONE in 0.8-0*
+
* Write an Rd page for the `"permutationMatrix"` S3 class where I can
describe the object returned by `shuffleSet()` and the methods
available for it.
+
+ *DONE in 0.7-8*
\ No newline at end of file
Modified: pkg/permute/man/shuffleSet.Rd
===================================================================
--- pkg/permute/man/shuffleSet.Rd 2013-11-30 22:17:01 UTC (rev 2784)
+++ pkg/permute/man/shuffleSet.Rd 2013-11-30 23:32:45 UTC (rev 2785)
@@ -112,10 +112,12 @@
plotStrata <- Plots(strata = gl(4,5))
CTRL <- how(plots = plotStrata,
within = Within(type = "free"))
+numPerms(20, control = CTRL)
shuffleSet(20, 10, control = CTRL)
## as above but same random permutation within Plot-level strata
CTRL <- how(plots = plotStrata,
within = Within(type = "free", constant = TRUE))
+numPerms(20, control = CTRL)
shuffleSet(20, 10, CTRL) ## check this.
## time series within each level of Plot strata
Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save
===================================================================
--- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 22:17:01 UTC (rev 2784)
+++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 23:32:45 UTC (rev 2785)
@@ -1086,6 +1086,8 @@
> plotStrata <- Plots(strata = gl(4,5))
> CTRL <- how(plots = plotStrata,
+ within = Within(type = "free"))
+> numPerms(20, control = CTRL)
+[1] 207360000
> shuffleSet(20, 10, control = CTRL)
No. of Permutations: 10
No. of Samples: 20 (Nested in: plots; Randomised)
@@ -1116,6 +1118,8 @@
> ## as above but same random permutation within Plot-level strata
> CTRL <- how(plots = plotStrata,
+ within = Within(type = "free", constant = TRUE))
+> numPerms(20, control = CTRL)
+[1] 120
> shuffleSet(20, 10, CTRL) ## check this.
No. of Permutations: 10
No. of Samples: 20 (Nested in: plots; Randomised; same permutation in
@@ -1203,7 +1207,7 @@
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 2.227 0.035 2.282 0 0
+Time elapsed: 2.288 0.038 2.347 0 0
> grDevices::dev.off()
null device
1
From noreply at r-forge.r-project.org Sun Dec 1 16:57:50 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 16:57:50 +0100 (CET)
Subject: [Vegan-commits] r2786 - pkg/vegan/R
Message-ID: <20131201155750.E283E185C8C@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 16:57:50 +0100 (Sun, 01 Dec 2013)
New Revision: 2786
Added:
pkg/vegan/R/howHead.R
Modified:
pkg/vegan/R/anovacca.R
Log:
anovacca got header from the how object
Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-11-30 23:32:45 UTC (rev 2785)
+++ pkg/vegan/R/anovacca.R 2013-12-01 15:57:50 UTC (rev 2786)
@@ -79,11 +79,9 @@
is.rda <- inherits(object, "rda")
colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"),
"F", "N.Perm", "Pr(>F)")
- head <- paste("Permutation test for", tst$method, "under",
- tst$model, "model\n")
- if (!is.null(tst$strata))
- head <- paste(head, "Permutations stratified within '",
- tst$strata, "'\n", sep = "")
+ head <- paste0("Permutation test for ", tst$method, " under ",
+ tst$model, " model\n", howHead(control),
+ "Number of permutations: ", tst$nperm, "\n")
mod <- paste("Model:", c(object$call))
structure(table, heading = c(head, mod), Random.seed = seed,
control = control,
Added: pkg/vegan/R/howHead.R
===================================================================
--- pkg/vegan/R/howHead.R (rev 0)
+++ pkg/vegan/R/howHead.R 2013-12-01 15:57:50 UTC (rev 2786)
@@ -0,0 +1,51 @@
+### Make a compact summary of permutations. This copies Gav Simpson's
+### permute:::print.how, but only displays non-default choices in how().
+`howHead` <- function(x, ...)
+{
+ ## this should always work
+ if (is.null(x) || !inherits(x, "how"))
+ stop("not a 'how' object: contact the package maintainer")
+ ## collect header
+ head <- NULL
+ ## blocks
+ if (!is.null(getBlocks(x)))
+ head <- paste0(head, paste("Blocks: ", x$blocks.name, "\n"))
+ ## plots
+ plotStr <- getStrata(x, which = "plots")
+ if (!is.null(plotStr)) {
+ plots <- getPlots(x)
+ ptype <- getType(x, which = "plots")
+ head <- paste0(head, paste0("Plots: ", plots$plots.name, ", "))
+ head <- paste0(head, paste("plot permutation:", ptype))
+ if(getMirror(x, which = "plots") == "Yes")
+ head <- paste(head, "mirrored")
+ if (isTRUE(all.equal(ptype, "grid"))) {
+ nr <- getRow(x, which = "plots")
+ nc <- getCol(x, which = "plots")
+ head <- paste0(head, sprintf(ngettext(nr, " %d row", " %d rows"),
+ nr))
+ head <- paste0(head, sprintf(ngettext(nc, " %d column",
+ " %d columns"), nc))
+ }
+ head <- paste0(head, "\n")
+ }
+ ## the fine level (within plots if any)
+ type <- getType(x, which = "within")
+ head <- paste0(head, "Permutation: ", type)
+ if (isTRUE(type %in% c("series", "grid"))) {
+ if(getMirror(x, which = "within") == "Yes")
+ head <- paste(head, "mirrored")
+ if(getConstant(x) == "Yes")
+ head <- paste0(head, " constant permutation within each Plot")
+ }
+ if (isTRUE(all.equal(type, "grid"))) {
+ nr <- getRow(x, which = "plots")
+ nc <- getCol(x, which = "plots")
+ head <- paste0(head, sprintf(ngettext(nr, " %d row", " %d rows"),
+ nr))
+ head <- paste0(head, sprintf(ngettext(nc, " %d column",
+ " %d columns"), nc))
+ }
+ head <- paste0(head, "\n")
+ head
+}
From noreply at r-forge.r-project.org Sun Dec 1 17:07:19 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 17:07:19 +0100 (CET)
Subject: [Vegan-commits] r2787 - in pkg/permute: . R inst
Message-ID: <20131201160719.DD16D185C8C@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 17:07:19 +0100 (Sun, 01 Dec 2013)
New Revision: 2787
Modified:
pkg/permute/DESCRIPTION
pkg/permute/R/setFoo-methods.R
pkg/permute/inst/ChangeLog
Log:
deparse substitute block name before evaluating block and destroying its name
Modified: pkg/permute/DESCRIPTION
===================================================================
--- pkg/permute/DESCRIPTION 2013-12-01 15:57:50 UTC (rev 2786)
+++ pkg/permute/DESCRIPTION 2013-12-01 16:07:19 UTC (rev 2787)
@@ -1,6 +1,6 @@
Package: permute
Title: Functions for generating restricted permutations of data
-Version: 0.8-0
+Version: 0.8-1
Date: $Date$
Authors at R: c(person(given = "Gavin L.", family = "Simpson",
email = "ucfagls at gmail.com",
Modified: pkg/permute/R/setFoo-methods.R
===================================================================
--- pkg/permute/R/setFoo-methods.R 2013-12-01 15:57:50 UTC (rev 2786)
+++ pkg/permute/R/setFoo-methods.R 2013-12-01 16:07:19 UTC (rev 2787)
@@ -143,8 +143,8 @@
`setBlocks<-.how` <- function(object, value) {
if (!is.null(value))
value <- as.factor(value)
+ object[["blocks.name"]] <- deparse(substitute(value))
object["blocks"] <- list(value)
- object[["blocks.name"]] <- deparse(substitute(value))
object <- fixupCall(object, "blocks", value)
object
}
Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog 2013-12-01 15:57:50 UTC (rev 2786)
+++ pkg/permute/inst/ChangeLog 2013-12-01 16:07:19 UTC (rev 2787)
@@ -2,6 +2,12 @@
permute ChangeLog
+Version 0.8-1
+
+ * setBlocks<-: the name of the block must be collected with
+ deparse(substitute()) before it is evaluated with list() or its
+ name will be lost.
+
Version 0.8-0
* Released to CRAN
From noreply at r-forge.r-project.org Sun Dec 1 17:26:11 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 17:26:11 +0100 (CET)
Subject: [Vegan-commits] r2788 - pkg/vegan/R
Message-ID: <20131201162611.D49AC186B21@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 17:26:11 +0100 (Sun, 01 Dec 2013)
New Revision: 2788
Modified:
pkg/vegan/R/anovacca.byterm.R
Log:
anovacca by= methods got headers
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:07:19 UTC (rev 2787)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:26:11 UTC (rev 2788)
@@ -33,6 +33,11 @@
c(sol[-1,6], NA))
colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
rownames(out) <- c(trmlab, "Residual")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ model, " model\n",
+ "Terms added sequentially (first to last)")
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
class(out) <- c("anova","data.frame")
out
}
@@ -83,6 +88,11 @@
c(Fstat, NA), c(Pval, NA))
colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
rownames(out) <- c(trmlab, "Residual")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ mods[[1]]$model, " model\n",
+ "Marginal effects of terms")
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
class(out) <- c("anova", "data.frame")
out
}
@@ -135,6 +145,11 @@
c(Fstat, NA), c(Pvals,NA))
rownames(out) <- c(names(eig), "Residual")
colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ model, " model\n",
+ "Marginal tests for axes")
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
class(out) <- c("anova", "data.frame")
out
}
From noreply at r-forge.r-project.org Sun Dec 1 17:34:07 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 17:34:07 +0100 (CET)
Subject: [Vegan-commits] r2789 - in pkg/vegan: R man
Message-ID: <20131201163407.89F93186B21@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 17:34:07 +0100 (Sun, 01 Dec 2013)
New Revision: 2789
Modified:
pkg/vegan/R/anovacca.R
pkg/vegan/R/anovacca.byterm.R
pkg/vegan/man/anovacca.Rd
Log:
anovacca(..., by='axis') gained 'cutoff' argument
Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-12-01 16:26:11 UTC (rev 2788)
+++ pkg/vegan/R/anovacca.R 2013-12-01 16:34:07 UTC (rev 2789)
@@ -1,7 +1,8 @@
`anovacca` <-
function(object, ..., permutations = how(nperm=999), by = NULL,
model = c("reduced", "direct", "full"),
- parallel = getOption("mc.cores"), strata = NULL)
+ parallel = getOption("mc.cores"), strata = NULL,
+ cutoff = 1)
{
model <- match.arg(model)
## permutations is either a single number, a how() structure or a
@@ -64,7 +65,8 @@
model = model, parallel = parallel),
"axis" = anovacca.byaxis(object,
permutations = permutations,
- model = model, parallel = parallel))
+ model = model, parallel = parallel,
+ cutoff = cutoff))
attr(sol, "Random.seed") <- seed
attr(sol, "control") <- control
return(sol)
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:26:11 UTC (rev 2788)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:34:07 UTC (rev 2789)
@@ -100,7 +100,7 @@
### Marginal test for axes
`anovacca.byaxis` <-
- function(object, permutations, model, parallel)
+ function(object, permutations, model, parallel, cutoff = 1)
{
nperm <- nrow(permutations)
## Observed F-values and Df
@@ -124,7 +124,7 @@
}
LC <- as.data.frame(LC)
fla <- reformulate(names(LC))
- Pvals <- numeric(length(eig))
+ Pvals <- rep(NA, length(eig))
environment(object$terms) <- environment()
for (i in 1:length(eig)) {
part <- paste("~ . +Condition(",
@@ -140,6 +140,8 @@
permutations, model = model,
parallel = parallel)
Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1)
+ if (Pvals[i] > cutoff)
+ break
}
out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi),
c(Fstat, NA), c(Pvals,NA))
Modified: pkg/vegan/man/anovacca.Rd
===================================================================
--- pkg/vegan/man/anovacca.Rd 2013-12-01 16:26:11 UTC (rev 2788)
+++ pkg/vegan/man/anovacca.Rd 2013-12-01 16:34:07 UTC (rev 2789)
@@ -24,7 +24,8 @@
\usage{
anovacca(object, ..., permutations = how(nperm=999),
by = NULL, model = c("reduced", "direct", "full"),
- parallel = getOption("mc.cores"), strata = NULL)
+ parallel = getOption("mc.cores"), strata = NULL,
+ cutoff = 1)
}
\arguments{
@@ -59,6 +60,9 @@
deprecated in the future: use
\code{permutations = how(\dots, blocks)} instead. }
+ \item{cutoff}{Only effective with \code{by="axis"} where stops
+ permutations after an axis exceeds the \code{cutoff}.}
+
\item{\dots}{Parameters passed to other functions. \code{anova.cca}
passes all arguments to \code{permutest.cca}. In \code{anova} with
\code{by = "axis"} you can use argument \code{cutoff} (defaults
From noreply at r-forge.r-project.org Sun Dec 1 17:44:31 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 17:44:31 +0100 (CET)
Subject: [Vegan-commits] r2790 - in pkg/vegan: R man
Message-ID: <20131201164431.18449186B21@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 17:44:30 +0100 (Sun, 01 Dec 2013)
New Revision: 2790
Modified:
pkg/vegan/R/anovacca.R
pkg/vegan/R/anovacca.byterm.R
pkg/vegan/man/anovacca.Rd
Log:
anovacca(..., by='margin' gained 'scope'
Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-12-01 16:34:07 UTC (rev 2789)
+++ pkg/vegan/R/anovacca.R 2013-12-01 16:44:30 UTC (rev 2790)
@@ -2,7 +2,7 @@
function(object, ..., permutations = how(nperm=999), by = NULL,
model = c("reduced", "direct", "full"),
parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1)
+ cutoff = 1, scope = NULL)
{
model <- match.arg(model)
## permutations is either a single number, a how() structure or a
@@ -62,7 +62,8 @@
model = model, parallel = parallel),
"margin" = anovacca.bymargin(object,
permutations = permutations,
- model = model, parallel = parallel),
+ model = model, parallel = parallel,
+ scope = scope),
"axis" = anovacca.byaxis(object,
permutations = permutations,
model = model, parallel = parallel,
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:34:07 UTC (rev 2789)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:44:30 UTC (rev 2790)
@@ -46,14 +46,17 @@
## term in turn and compare against the complete model.
`anovacca.bymargin` <-
- function(object, permutations, ...)
+ function(object, permutations, scope, ...)
{
nperm <- nrow(permutations)
## Refuse to handle models with missing data
if (!is.null(object$na.action))
stop("by = 'margin' models cannot handle missing data")
## We need term labels but without Condition() terms
- trms <- drop.scope(object)
+ if (!is.null(scope) && is.character(scope))
+ trms <- scope
+ else
+ trms <- drop.scope(object)
trmlab <- trms[trms %in% attr(terms(object$terminfo),
"term.labels")]
## baseline: all terms
Modified: pkg/vegan/man/anovacca.Rd
===================================================================
--- pkg/vegan/man/anovacca.Rd 2013-12-01 16:34:07 UTC (rev 2789)
+++ pkg/vegan/man/anovacca.Rd 2013-12-01 16:44:30 UTC (rev 2790)
@@ -25,7 +25,7 @@
anovacca(object, ..., permutations = how(nperm=999),
by = NULL, model = c("reduced", "direct", "full"),
parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1)
+ cutoff = 1, scope = NULL)
}
\arguments{
@@ -63,6 +63,10 @@
\item{cutoff}{Only effective with \code{by="axis"} where stops
permutations after an axis exceeds the \code{cutoff}.}
+ \item{scope}{Only effective with \code{by="margin"} where it can be
+ used to select the marginal terms for testing. The default is to
+ test all marginal terms in \code{\link{drop.scope}}.}
+
\item{\dots}{Parameters passed to other functions. \code{anova.cca}
passes all arguments to \code{permutest.cca}. In \code{anova} with
\code{by = "axis"} you can use argument \code{cutoff} (defaults
From noreply at r-forge.r-project.org Sun Dec 1 18:07:03 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 18:07:03 +0100 (CET)
Subject: [Vegan-commits] r2791 - pkg/vegan/R
Message-ID: <20131201170703.B7FD1186229@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 18:07:03 +0100 (Sun, 01 Dec 2013)
New Revision: 2791
Modified:
pkg/vegan/R/anovacca.R
pkg/vegan/R/howHead.R
Log:
howHead returns no. of permutations, and we use that in anova display instead of N.perm column
Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-12-01 16:44:30 UTC (rev 2790)
+++ pkg/vegan/R/anovacca.R 2013-12-01 17:07:03 UTC (rev 2791)
@@ -77,14 +77,12 @@
Fval <- c(tst$F.0, NA)
Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1)
Pval <- c(Pval, NA)
- nperm <- c(tst$nperm, NA)
- table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval)
+ table <- data.frame(tst$df, tst$chi, Fval, Pval)
is.rda <- inherits(object, "rda")
colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"),
- "F", "N.Perm", "Pr(>F)")
+ "F", "Pr(>F)")
head <- paste0("Permutation test for ", tst$method, " under ",
- tst$model, " model\n", howHead(control),
- "Number of permutations: ", tst$nperm, "\n")
+ tst$model, " model\n", howHead(control))
mod <- paste("Model:", c(object$call))
structure(table, heading = c(head, mod), Random.seed = seed,
control = control,
Modified: pkg/vegan/R/howHead.R
===================================================================
--- pkg/vegan/R/howHead.R 2013-12-01 16:44:30 UTC (rev 2790)
+++ pkg/vegan/R/howHead.R 2013-12-01 17:07:03 UTC (rev 2791)
@@ -46,6 +46,6 @@
head <- paste0(head, sprintf(ngettext(nc, " %d column",
" %d columns"), nc))
}
- head <- paste0(head, "\n")
+ head <- paste0(head, "\nNumber of permutations: ", getNperm(x), "\n")
head
}
From noreply at r-forge.r-project.org Sun Dec 1 18:17:05 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 1 Dec 2013 18:17:05 +0100 (CET)
Subject: [Vegan-commits] r2792 - pkg/vegan/R
Message-ID: <20131201171705.8F922184475@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-01 18:17:05 +0100 (Sun, 01 Dec 2013)
New Revision: 2792
Modified:
pkg/vegan/R/anovacca.byterm.R
Log:
anovacca(..., by=...) cases use howHead
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:07:03 UTC (rev 2791)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:17:05 UTC (rev 2792)
@@ -35,7 +35,8 @@
rownames(out) <- c(trmlab, "Residual")
head <- paste0("Permutation test for ", object$method, " under ",
model, " model\n",
- "Terms added sequentially (first to last)")
+ "Terms added sequentially (first to last)\n",
+ howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
class(out) <- c("anova","data.frame")
@@ -93,7 +94,8 @@
rownames(out) <- c(trmlab, "Residual")
head <- paste0("Permutation test for ", object$method, " under ",
mods[[1]]$model, " model\n",
- "Marginal effects of terms")
+ "Marginal effects of terms\n",
+ howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
class(out) <- c("anova", "data.frame")
@@ -152,7 +154,8 @@
colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
head <- paste0("Permutation test for ", object$method, " under ",
model, " model\n",
- "Marginal tests for axes")
+ "Marginal tests for axes\n",
+ howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
class(out) <- c("anova", "data.frame")
From noreply at r-forge.r-project.org Mon Dec 2 14:38:25 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Mon, 2 Dec 2013 14:38:25 +0100 (CET)
Subject: [Vegan-commits] r2793 - pkg/vegan/R
Message-ID: <20131202133825.ABF5E185979@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-02 14:38:24 +0100 (Mon, 02 Dec 2013)
New Revision: 2793
Modified:
pkg/vegan/R/anovacca.byterm.R
Log:
anovacca(..., by='axis', scope=) handles empty scopes (like wrong names in scope)
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:17:05 UTC (rev 2792)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-02 13:38:24 UTC (rev 2793)
@@ -60,6 +60,8 @@
trms <- drop.scope(object)
trmlab <- trms[trms %in% attr(terms(object$terminfo),
"term.labels")]
+ if(length(trmlab) == 0)
+ stop("the scope was empty: no available marginal terms")
## baseline: all terms
big <- permutest(object, permutations, ...)
dfbig <- big$df[2]
From noreply at r-forge.r-project.org Mon Dec 2 18:47:14 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Mon, 2 Dec 2013 18:47:14 +0100 (CET)
Subject: [Vegan-commits] r2794 - in pkg/permute: . R inst
Message-ID: <20131202174714.963611852AE@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-02 18:47:14 +0100 (Mon, 02 Dec 2013)
New Revision: 2794
Modified:
pkg/permute/DESCRIPTION
pkg/permute/R/setFoo-methods.R
pkg/permute/inst/ChangeLog
Log:
revert r2787: did not work
Modified: pkg/permute/DESCRIPTION
===================================================================
--- pkg/permute/DESCRIPTION 2013-12-02 13:38:24 UTC (rev 2793)
+++ pkg/permute/DESCRIPTION 2013-12-02 17:47:14 UTC (rev 2794)
@@ -1,6 +1,6 @@
Package: permute
Title: Functions for generating restricted permutations of data
-Version: 0.8-1
+Version: 0.8-0
Date: $Date$
Authors at R: c(person(given = "Gavin L.", family = "Simpson",
email = "ucfagls at gmail.com",
Modified: pkg/permute/R/setFoo-methods.R
===================================================================
--- pkg/permute/R/setFoo-methods.R 2013-12-02 13:38:24 UTC (rev 2793)
+++ pkg/permute/R/setFoo-methods.R 2013-12-02 17:47:14 UTC (rev 2794)
@@ -143,8 +143,8 @@
`setBlocks<-.how` <- function(object, value) {
if (!is.null(value))
value <- as.factor(value)
+ object["blocks"] <- list(value)
object[["blocks.name"]] <- deparse(substitute(value))
- object["blocks"] <- list(value)
object <- fixupCall(object, "blocks", value)
object
}
Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog 2013-12-02 13:38:24 UTC (rev 2793)
+++ pkg/permute/inst/ChangeLog 2013-12-02 17:47:14 UTC (rev 2794)
@@ -2,12 +2,6 @@
permute ChangeLog
-Version 0.8-1
-
- * setBlocks<-: the name of the block must be collected with
- deparse(substitute()) before it is evaluated with list() or its
- name will be lost.
-
Version 0.8-0
* Released to CRAN
From noreply at r-forge.r-project.org Tue Dec 3 16:39:15 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 16:39:15 +0100 (CET)
Subject: [Vegan-commits] r2795 - pkg/vegan/R
Message-ID: <20131203153915.1A169185F5E@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 16:39:14 +0100 (Tue, 03 Dec 2013)
New Revision: 2795
Modified:
pkg/vegan/R/print.permutest.cca.R
Log:
print.permutest.cca uses howHead
Modified: pkg/vegan/R/print.permutest.cca.R
===================================================================
--- pkg/vegan/R/print.permutest.cca.R 2013-12-02 17:47:14 UTC (rev 2794)
+++ pkg/vegan/R/print.permutest.cca.R 2013-12-03 15:39:14 UTC (rev 2795)
@@ -1,7 +1,8 @@
-"print.permutest.cca" <-
+`print.permutest.cca` <-
function (x, ...)
{
cat("\nPermutation test for", x$method, "\n\n")
+ cat(howHead(x$control), "\n")
writeLines(strwrap(pasteCall(x$testcall)))
Pval <- (sum(x$F.perm >= x$F.0) + 1)/(x$nperm + 1)
cat("Permutation test for ")
@@ -12,10 +13,6 @@
cat("Pseudo-F:\t", x$F.0, "(with", paste(x$df, collapse = ", "),
"Degrees of Freedom)\n")
cat("Significance:\t", format.pval(Pval),
- "\n")
- cat("Based on", x$nperm, "permutations under", x$model, "model")
- if (!is.null(x$strata))
- cat(",\nstratified within factor", x$strata)
- cat(".\n\n")
+ "\n\n")
invisible(x)
}
From noreply at r-forge.r-project.org Tue Dec 3 17:02:58 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 17:02:58 +0100 (CET)
Subject: [Vegan-commits] r2796 - pkg/vegan/R
Message-ID: <20131203160258.6780E185ABA@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 17:02:58 +0100 (Tue, 03 Dec 2013)
New Revision: 2796
Modified:
pkg/vegan/R/anova.ccalist.R
pkg/vegan/R/anovacca.R
pkg/vegan/R/anovacca.byterm.R
Log:
adopt column header Variance/ChiSquare to ordination method
Modified: pkg/vegan/R/anova.ccalist.R
===================================================================
--- pkg/vegan/R/anova.ccalist.R 2013-12-03 15:39:14 UTC (rev 2795)
+++ pkg/vegan/R/anova.ccalist.R 2013-12-03 16:02:58 UTC (rev 2796)
@@ -72,13 +72,18 @@
## collect table
table <- data.frame(resdf, resdev, c(NA, df),
c(NA,changedev), c(NA,fval), c(NA,pval))
- dimnames(table) <- list(1L:nmodels, c("Resid. Df", "Res. Chisq",
- "Df", "Chisq", "F", "Pr(>F)"))
+ isRDA <- method != "cca"
+ dimnames(table) <- list(1L:nmodels,
+ c("Res.Df",
+ ifelse(isRDA,"Res.Variance", "Res.ChiSquare"),
+ "Df",
+ ifelse(isRDA,"Variance","ChiSquare"),
+ "F", "Pr(>F)"))
## Collect header information
formulae <- sapply(object, function(z) deparse(formula(z)))
head <- paste0("Permutation tests for ", method, " under ",
- mods[[big]]$model, " model\nwith ", nperm,
- " permutations\n")
+ mods[[big]]$model, " model\n",
+ howHead(attr(permutations, "control")))
topnote <- paste("Model ", format(1L:nmodels), ": ", formulae,
sep = "", collapse = "\n")
structure(table, heading=c(head,topnote), class = c("anova", "data.frame"))
Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-12-03 15:39:14 UTC (rev 2795)
+++ pkg/vegan/R/anovacca.R 2013-12-03 16:02:58 UTC (rev 2796)
@@ -79,7 +79,7 @@
Pval <- c(Pval, NA)
table <- data.frame(tst$df, tst$chi, Fval, Pval)
is.rda <- inherits(object, "rda")
- colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"),
+ colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"),
"F", "Pr(>F)")
head <- paste0("Permutation test for ", tst$method, " under ",
tst$model, " model\n", howHead(control))
Modified: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-03 15:39:14 UTC (rev 2795)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-03 16:02:58 UTC (rev 2796)
@@ -31,7 +31,9 @@
c(sol[-1,4], sol[ntrm+1,2]),
c(sol[-1,5], NA),
c(sol[-1,6], NA))
- colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
rownames(out) <- c(trmlab, "Residual")
head <- paste0("Permutation test for ", object$method, " under ",
model, " model\n",
@@ -92,7 +94,9 @@
## Collect results to anova data.frame
out <- data.frame(c(Df, dfbig), c(Chisq, chibig),
c(Fstat, NA), c(Pval, NA))
- colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
rownames(out) <- c(trmlab, "Residual")
head <- paste0("Permutation test for ", object$method, " under ",
mods[[1]]$model, " model\n",
@@ -153,7 +157,9 @@
out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi),
c(Fstat, NA), c(Pvals,NA))
rownames(out) <- c(names(eig), "Residual")
- colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)")
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
head <- paste0("Permutation test for ", object$method, " under ",
model, " model\n",
"Marginal tests for axes\n",
From noreply at r-forge.r-project.org Tue Dec 3 17:12:16 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 17:12:16 +0100 (CET)
Subject: [Vegan-commits] r2797 - pkg/vegan/R
Message-ID: <20131203161216.E6174185122@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 17:12:16 +0100 (Tue, 03 Dec 2013)
New Revision: 2797
Modified:
pkg/vegan/R/permutest.cca.R
Log:
disable 'full' model in permutest.cca: no code removal
Modified: pkg/vegan/R/permutest.cca.R
===================================================================
--- pkg/vegan/R/permutest.cca.R 2013-12-03 16:02:58 UTC (rev 2796)
+++ pkg/vegan/R/permutest.cca.R 2013-12-03 16:12:16 UTC (rev 2797)
@@ -6,7 +6,7 @@
`permutest.cca` <-
function (x, permutations = how(nperm=99),
- model = c("reduced", "direct", "full"), first = FALSE,
+ model = c("reduced", "direct"), first = FALSE,
strata = NULL, parallel = getOption("mc.cores") , ...)
{
## do something sensible with insensible input (no constraints)
From noreply at r-forge.r-project.org Tue Dec 3 17:37:33 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 17:37:33 +0100 (CET)
Subject: [Vegan-commits] r2798 - pkg/vegan/man
Message-ID: <20131203163733.58D63185ABA@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 17:37:33 +0100 (Tue, 03 Dec 2013)
New Revision: 2798
Modified:
pkg/vegan/man/anova.cca.Rd
pkg/vegan/man/anovacca.Rd
Log:
prepare documentation for switching from old to new anova.cca
Modified: pkg/vegan/man/anova.cca.Rd
===================================================================
--- pkg/vegan/man/anova.cca.Rd 2013-12-03 16:12:16 UTC (rev 2797)
+++ pkg/vegan/man/anova.cca.Rd 2013-12-03 16:37:33 UTC (rev 2798)
@@ -5,32 +5,19 @@
\alias{anova.ccabyterm}
\alias{anova.ccabymargin}
\alias{anova.prc}
-\alias{permutest}
-\alias{permutest.default}
-\alias{permutest.cca}
\title{Permutation Test for Constrained Correspondence Analysis,
Redundancy Analysis and Constrained Analysis of Principal Coordinates }
\description{
- The function performs an ANOVA like permutation test for Constrained
- Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis
- (\code{\link{rda}}) or distance-based Redundancy Analysis
- (dbRDA, \code{\link{capscale}}) to assess the significance of constraints.
+ This function is deprecated.
}
\usage{
\method{anova}{cca}(object, alpha=0.05, beta=0.01, step=100, perm.max=9999,
by = NULL, ...)
-
-permutest(x, ...)
-
-\method{permutest}{cca}(x, permutations = how(nperm=99),
- model = c("reduced", "direct", "full"),
- first = FALSE, strata = NULL,
- parallel = getOption("mc.cores") , ...)
}
\arguments{
- \item{object,x}{A result object from \code{\link{cca}}. }
+ \item{object}{A result object from \code{\link{cca}}. }
\item{alpha}{Targeted Type I error rate. }
\item{beta}{Accepted Type II error rate. }
\item{step}{Number of permutations during one step. }
@@ -46,124 +33,37 @@
\code{permutest.cca}. In \code{anova} with \code{by = "axis"} you
can use argument \code{cutoff} (defaults \code{1}) which stops
permutations after exceeding the given level. }
-
- \item{permutations}{Either a \code{\link[permute]{how}} result
- defining permutations, or a permutation matrix with each row giving
- the permutation indices, or the number of permutations for simple
- permutations. See \code{\link{permutations}} for details.}
-
- \item{model}{Permutation model (partial match).}
- \item{first}{Assess only the significance of the first constrained
- eigenvalue; will be passed from \code{anova.cca}. }
-
- \item{strata}{An integer vector or factor specifying the strata for
- permutation. If supplied, observations are permuted only within the
- specified strata. It is an error to use this when
- \code{permutations} is a matrix, or a \code{\link[permute]{how}}
- defines \code{blocks}. This is a legacy argument that will be
- deprecated in the future: use \code{permutations = how(\dots, blocks)}
- instead. }
-
- \item{parallel}{Number of parallel processes or a predefined socket
- cluster. With \code{parallel = 1} uses ordinary, non-parallel
- processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
-
}
\details{
- Functions \code{anova.cca} and \code{permutest.cca} implement an ANOVA
- like permutation test for the joint effect of constraints in
- \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}.
- Functions \code{anova.cca} and \code{permutest.cca} differ in printout
- style and in interface.
- Function \code{permutest.cca} is the proper workhorse, but
- \code{anova.cca} passes all parameters to \code{permutest.cca}.
-
- The default test is for the sum of all constrained eigenvalues.
- Setting \code{first = TRUE} will perform a test for the first
- constrained eigenvalue. Argument \code{first} can be set either in
- \code{anova.cca} or in \code{permutest.cca}. It is also possible to
- perform significance tests for each axis or for each term
- (constraining variable) using argument \code{by} in
- \code{anova.cca}. Setting \code{by = "axis"} will perform separate
- significance tests for each constrained axis. All previous
- constrained axes will be used as conditions (\dQuote{partialled
- out}) and a test for the first constrained eigenvalues is
- performed (Legendre et al. 2011).
- You can stop permutation tests after exceeding a given
- significance level with argument \code{cutoff} to speed up
- calculations in large models. Setting \code{by = "terms"} will
- perform separate significance test for each term (constraining
- variable). The terms are assessed sequentially from first to last,
- and the order of the terms will influence their
- significances. Setting \code{by = "margin"} will perform separate
- significance test for each marginal term in a model with all other
- terms. The marginal test also accepts a \code{scope} argument for
- the \code{\link{drop.scope}} which can be a character vector of term
- labels that are analysed, or a fitted model of lower scope. The
- marginal effects are also known as \dQuote{Type III} effects, but
- the current function only evaluates marginal terms. It will, for
- instance, ignore main effects that are included in interaction
- terms. In calculating pseudo-\eqn{F}, all terms are compared to the
- same residual of the full model. Permutations for all axes or terms
- will start from the same \code{\link{.Random.seed}}, and the seed
- will be advanced to the value after the longest permutation at the
- exit from the function.
+ This function contains a deprecated version of \code{anova.cca}.
+ The new function is completely rewritten. With the same random
+ number seed and the same number of permutations, the results are
+ mostly identical. The only difference is that marginal tests
+ (\code{by = "margin"}) are implemented differently. The most
+ important difference is that the new code is based on the
+ \pkg{permute} package and uses the fixed number of permutations in
+ all tests (cf. below). Both the new and old functions are based
+ \code{\link{permutest.cca}}, and the function can pass extra
+ arguments to \code{permutest.cca}.
+
In \code{anova.cca} the number of permutations is controlled by
targeted \dQuote{critical} \eqn{P} value (\code{alpha}) and accepted
Type II or rejection error (\code{beta}). If the results of
- permutations differ from the targeted \code{alpha} at risk level given
- by \code{beta}, the permutations are terminated. If the current
- estimate of \eqn{P} does not differ significantly from \code{alpha} of
- the alternative hypothesis, the permutations are continued with
- \code{step} new permutations (at the first step, the number of
- permutations is \code{step - 1}). However, with \code{by="terms"} a
- fixed number of permutations will be used, and this is given by
- argument \code{permutations}, or if this is missing, by \code{step}.
+ permutations differ from the targeted \code{alpha} at risk level
+ given by \code{beta}, the permutations are terminated. If the
+ current estimate of \eqn{P} does not differ significantly from
+ \code{alpha} of the alternative hypothesis, the permutations are
+ continued with \code{step} new permutations (at the first step, the
+ number of permutations is \code{step - 1}). However, with
+ \code{by="terms"} a fixed number of permutations will be used, and
+ this is given by argument \code{permutations}, or if this is
+ missing, by \code{step}.
- Community data are permuted with choice \code{model="direct"},
- residuals after partial CCA/ RDA/ dbRDA with choice \code{model="reduced"}
- (default), and residuals after CCA/ RDA/ dbRDA under choice
- \code{model="full"}. If there is no partial CCA/ RDA/ dbRDA stage,
- \code{model="reduced"} simply permutes the data and is equivalent to
- \code{model="direct"}. The test statistic is \dQuote{pseudo-\eqn{F}},
- which is the ratio of constrained and unconstrained total Inertia
- (Chi-squares, variances or something similar), each divided by their
- respective ranks. If there are no conditions (\dQuote{partial}
- terms), the sum of all eigenvalues remains constant, so that
- pseudo-\eqn{F} and eigenvalues would give equal results. In partial
- CCA/ RDA/ dbRDA, the effect of conditioning variables
- (\dQuote{covariables}) is removed before permutation, and these
- residuals are added to the non-permuted fitted values of partial CCA
- (fitted values of \code{X ~ Z}). Consequently, the total Chi-square
- is not fixed, and test based on pseudo-\eqn{F} would differ from the
- test based on plain eigenvalues. CCA is a weighted method, and
- environmental data are re-weighted at each permutation step using
- permuted weights.
}
-\value{
- Function \code{permutest.cca} returns an object of class
- \code{"permutest.cca"}, which has its own \code{print} method. The
- distribution of permuted \eqn{F} values can be inspected with
- \code{\link{density.permutest.cca}} function. The function
- \code{anova.cca} calls \code{permutest.cca} and fills an
- \code{\link{anova}} table.
-}
-
\note{
- Some cases of \code{anova} need access to the original data on
- constraints (at least \code{by = "term"} and \code{by = "margin"}),
- and they may fail if data are unavailable.
-
- The default permutation \code{model} changed from \code{"direct"} to
- \code{"reduced"} in \pkg{vegan} version 1.15-0, and you must
- explicitly set \code{model = "direct"} for compatibility with the old
- version.
-
- Tests \code{by = "terms"} and \code{by = "margin"} are consistent
- only when \code{model = "direct"}.
+ The function is deprecated and replaced with \code{\link{anova.cca}}.
}
\references{
Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd
@@ -173,29 +73,8 @@
significance of canonical axes in redundancy analysis.
\emph{Methods in Ecology and Evolution} 2, 269--277.
}
-\author{Jari Oksanen}
-\seealso{\code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}}
- to get something to analyse. Function \code{\link{drop1.cca}} calls
- \code{anova.cca} with \code{by = "margin"}, and
- \code{\link{add1.cca}} an analysis for single terms additions, which
- can be used in automatic or semiautomatic model building (see
- \code{\link{deviance.cca}}). }
+\author{Jari Oksanen}
-\examples{
-data(varespec)
-data(varechem)
-vare.cca <- cca(varespec ~ Al + P + K, varechem)
-## overall test
-anova(vare.cca)
-## Test for axes
-anova(vare.cca, by="axis", perm.max=500)
-## Sequential test for terms
-anova(vare.cca, by="terms", permu=200)
-## Marginal or Type III effects
-anova(vare.cca, by="margin")
-## Marginal test knows 'scope'
-anova(vare.cca, by = "m", scope="P")
-}
\keyword{ multivariate }
\keyword{ htest }
Modified: pkg/vegan/man/anovacca.Rd
===================================================================
--- pkg/vegan/man/anovacca.Rd 2013-12-03 16:12:16 UTC (rev 2797)
+++ pkg/vegan/man/anovacca.Rd 2013-12-03 16:37:33 UTC (rev 2798)
@@ -5,9 +5,9 @@
%\alias{anova.ccabyterm}
%\alias{anova.ccabymargin}
%\alias{anova.prc}
-%\alias{permutest}
+\alias{permutest}
%\alias{permutest.default}
-%\alias{permutest.cca}
+\alias{permutest.cca}
\title{Permutation Test for Constrained Correspondence Analysis,
Redundancy Analysis and Constrained Analysis of Principal Coordinates }
@@ -17,15 +17,16 @@
Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis
(\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA,
\code{\link{capscale}}) to assess the significance of constraints.
+}
- This function is still experimental and unstable, but is scheduled
- to replace \code{\link{anova.cca}} in the future. }
-
\usage{
anovacca(object, ..., permutations = how(nperm=999),
- by = NULL, model = c("reduced", "direct", "full"),
- parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1, scope = NULL)
+ by = NULL, model = c("reduced", "direct", "full"),
+ parallel = getOption("mc.cores"), strata = NULL,
+ cutoff = 1, scope = NULL)
+\method{permutest}{cca}(x, permutations = how(nperm = 99),
+ model = c("reduced", "direct"), first = FALSE, strata = NULL,
+ parallel = getOption("mc.cores"), ...)
}
\arguments{
@@ -34,7 +35,9 @@
\code{\link{rda}} or \code{\link{capscale}}. If there are several
result objects, they are compared against each other in the ordre
they were supplied. For a single object, a test specified in
- \code{by} or an overal test is given. }
+ \code{by} or an overal test is given.}
+
+ \item{x}{A single ordination result object.}
\item{permutations}{Either a \code{\link[permute]{how}} result
defining permutations, or a permutation matrix with each row giving
@@ -46,11 +49,14 @@
significance for each term (sequentially from first to last), and
setting \code{by = "margin"} will assess the marginal effects of
the terms (each marginal term analysed in a model with all other
- variables). Not yet implemented.}
+ variables)}
- \item{model}{Model}
+ \item{model}{Permutation model: \code{model="direct"} permutes
+ community data, and \code{model="reduced"} permutes residuals
+ of the community data after Conditions (partial model).}
- \item{parallel}{Parallel processing}
+ \item{parallel}{Use parallel processing with the given number of
+ cores.}
\item{strata}{An integer vector or factor specifying the strata for
permutation. If supplied, observations are permuted only within
@@ -76,14 +82,18 @@
\details{
- Functions \code{anova.cca} and \code{permutest.cca} implement an
- ANOVA like permutation test for the joint effect of constraints in
+ Functions \code{anova.cca} and \code{permutest.cca} implement
+ ANOVA like permutation tests for the joint effect of constraints in
\code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}.
Functions \code{anova.cca} and \code{permutest.cca} differ in
printout style and in interface. Function \code{permutest.cca} is
the proper workhorse, but \code{anova.cca} passes all parameters to
\code{permutest.cca}.
+ Function \code{anova} can analyse a sequence of constrained
+ ordination models. The analysis is based on the differences in
+ residual deviances in permutations of nested models.
+
The default test is for the sum of all constrained eigenvalues.
Setting \code{first = TRUE} will perform a test for the first
constrained eigenvalue. Argument \code{first} can be set either in
@@ -110,15 +120,11 @@
the current function only evaluates marginal terms. It will, for
instance, ignore main effects that are included in interaction
terms. In calculating pseudo-\eqn{F}, all terms are compared to the
- same residual of the full model. Permutations for all axes or terms
- will start from the same \code{\link{.Random.seed}}, and the seed
- will be advanced to the value after the longest permutation at the
- exit from the function.
+ same residual of the full model.
Community data are permuted with choice \code{model="direct"},
- residuals after partial CCA/ RDA/ dbRDA with choice
- \code{model="reduced"} (default), and residuals after CCA/ RDA/
- dbRDA under choice \code{model="full"}. If there is no partial CCA/
+ and residuals after partial CCA/ RDA/ dbRDA with choice
+ \code{model="reduced"} (default). If there is no partial CCA/
RDA/ dbRDA stage, \code{model="reduced"} simply permutes the data
and is equivalent to \code{model="direct"}. The test statistic is
\dQuote{pseudo-\eqn{F}}, which is the ratio of constrained and
@@ -144,14 +150,6 @@
Some cases of \code{anova} need access to the original data on
constraints (at least \code{by = "term"} and \code{by = "margin"}),
and they may fail if data are unavailable.
-
- The default permutation \code{model} changed from \code{"direct"} to
- \code{"reduced"} in \pkg{vegan} version 1.15-0, and you must
- explicitly set \code{model = "direct"} for compatibility with the old
- version.
-
- Tests \code{by = "terms"} and \code{by = "margin"} are consistent
- only when \code{model = "direct"}.
}
\references{
Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd
From noreply at r-forge.r-project.org Tue Dec 3 18:03:29 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 18:03:29 +0100 (CET)
Subject: [Vegan-commits] r2799 - in pkg/vegan: . R inst man
Message-ID: <20131203170329.AC5D018346D@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 18:03:28 +0100 (Tue, 03 Dec 2013)
New Revision: 2799
Added:
pkg/vegan/R/ccanova.R
pkg/vegan/R/ccanova.byaxis.R
pkg/vegan/R/ccanova.bymargin.R
pkg/vegan/R/ccanova.byterm.R
pkg/vegan/man/ccanova.Rd
Removed:
pkg/vegan/R/anova.cca.R
pkg/vegan/R/anova.ccabyaxis.R
pkg/vegan/R/anova.ccabymargin.R
pkg/vegan/R/anova.ccabyterm.R
pkg/vegan/man/anova.cca.Rd
Modified:
pkg/vegan/DESCRIPTION
pkg/vegan/inst/ChangeLog
Log:
first stage of replacing old anova.cca: rename old functions to ccanova*
Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/DESCRIPTION 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 2.1-39
-Date: November 10, 2013
+Version: 2.1-40
+Date: December 3, 2013
Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre,
Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos,
M. Henry H. Stevens, Helene Wagner
Deleted: pkg/vegan/R/anova.cca.R
===================================================================
--- pkg/vegan/R/anova.cca.R 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/R/anova.cca.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,62 +0,0 @@
-`anova.cca` <-
- function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999,
- by = NULL, ...)
-{
- if (is.null(object$CA) || is.null(object$CCA) ||
- object$CCA$rank == 0 || object$CA$rank == 0)
- return(anova.ccanull(object))
- perm.max <- max(step-1, perm.max)
- if (perm.max %% step == 0)
- perm.max <- perm.max - 1
- if (!is.null(by)) {
- by <- match.arg(by, c("axis", "terms", "margin"))
- if (by == "axis")
- sol <- anova.ccabyaxis(object, alpha = alpha, beta = beta,
- step = step, perm.max = perm.max, by = NULL,
- ...)
- else if (by == "margin") {
- sol <- anova.ccabymargin(object, alpha = alpha, beta = beta,
- step = step, perm.max = perm.max,
- by = NULL, ...)
- }
- else {
- mf <- match.call(expand.dots = FALSE)
- if (!is.null(mf$...) && any(k <- pmatch(names(mf$...),
- "permutations", nomatch = FALSE)))
- step <- unlist(mf$...[k == 1])
- sol <- anova.ccabyterm(object, step = step, ...)
- }
- return(sol)
- }
- seed <- NULL
- betaq <- c(beta/2, 1 - beta/2)
- nperm <- 0
- unsure <- TRUE
- hits <- 0
- while (unsure && nperm < perm.max) {
- adj <- as.numeric(nperm == 0)
- tst <- permutest.cca(object, step - adj, ...)
- if (is.null(seed))
- seed <- tst$Random.seed
- nperm <- nperm + step - adj
- hits <- hits + sum(tst$F.perm >= tst$F.0)
- fork <- qbinom(betaq, nperm, alpha)
- if (hits < fork[1] || hits > fork[2])
- unsure <- FALSE
- }
- Fval <- c(tst$F.0, NA)
- Pval <- c((hits+1)/(nperm+1), NA)
- nperm <- c(nperm, NA)
- table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval)
- is.rda <- inherits(object, "rda")
- colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"),
- "F", "N.Perm", "Pr(>F)")
- head <- paste("Permutation test for", tst$method, "under",
- tst$model, "model\n")
- if (!is.null(tst$strata))
- head <- paste(head, "Permutations stratified within '",
- tst$strata, "'\n", sep = "")
- mod <- paste("Model:", c(object$call))
- structure(table, heading = c(head, mod), Random.seed = seed,
- class = c("anova.cca", "anova", "data.frame"))
-}
Deleted: pkg/vegan/R/anova.ccabyaxis.R
===================================================================
--- pkg/vegan/R/anova.ccabyaxis.R 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/R/anova.ccabyaxis.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,89 +0,0 @@
-`anova.ccabyaxis` <-
- function (object, cutoff = 1, ...)
-{
- cutoff <- cutoff + sqrt(.Machine$double.eps)
- rnk <- object$CCA$rank
- if (!max(rnk, 0))
- stop("Needs a constrained ordination")
- if (is.null(object$terms))
- stop("Analysis is only possible for models fitted using formula")
- ## Handle missing values in scores, both "omit" and "exclude" to
- ## match dims with data.
- if (!is.null(object$na.action)) {
- u <- napredict(structure(object$na.action, class="exclude"),
- object$CCA$u)
- } else {
- u <- object$CCA$u
- }
- ## Get conditions
- if (!is.null(object$pCCA)) {
- CondMat <- qr.X(object$pCCA$QR)
- ## deweight if CCA
- if (!inherits(object, "rda"))
- CondMat <- sweep(CondMat, 1, sqrt(object$rowsum), "/")
- }
- else
- CondMat <- NULL
- ## pad with NA rows if there is a subset
- if (!is.null(object$subset)) {
- lc <- matrix(NA, nrow=length(object$subset),
- ncol = NCOL(u))
- lc[object$subset,] <- u
- if (!is.null(CondMat)) {
- tmp <- matrix(NA, nrow=length(object$subset),
- ncol = NCOL(CondMat))
- tmp[object$subset,] <- CondMat
- CondMat <- tmp
- }
- object$call$subset <- object$subset
- } else {
- lc <- u
- }
- lc <- as.data.frame(lc)
- axnam <- colnames(lc)
- df <- c(rep(1, rnk), object$CA$rank)
- chi <- c(object$CCA$eig, Residual = object$CA$tot.chi)
- Fval <- c(chi[1:rnk]/df[1:rnk]/chi[rnk+1]*df[rnk+1], NA)
- nperm <- c(numeric(rnk), NA)
- Pval <- rep(NA, rnk+1)
- out <- data.frame(df, chi, Fval, nperm, Pval)
- environment(object$terms) <- environment()
- fla <- paste(". ~ ", axnam[1], "+ Condition(",
- paste(axnam[-1], collapse="+"),")")
- if (!is.null(CondMat)) {
- fla <- paste(fla, " + Condition(CondMat)")
- lc$CondMat <- CondMat
- }
- fla <- update(formula(object), fla)
- sol <- anova(update(object, fla, data=lc), ...)
- out[c(1, rnk + 1), ] <- sol
- seed <- attr(sol, "Random.seed")
- attr(out, "names") <- attr(sol, "names")
- .call <- pasteCall(object$call, "Model:")
- attr(out, "heading") <- sub(" \n","", .call)
- attr(out, "Random.seed") <- seed
- bigseed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
- bigperm <- out$N.Perm[1]
- if (rnk > 1) {
- for (.ITRM in 2:rnk) {
- fla <- paste(".~", axnam[.ITRM], "+Condition(",
- paste(axnam[-(.ITRM)], collapse="+"),")")
- if (!is.null(CondMat))
- fla <- paste(fla, "+ Condition(CondMat)")
- fla <- update(formula(object), fla)
- sol <- update(object, fla, data = lc)
- assign(".Random.seed", seed, envir = .GlobalEnv)
- out[.ITRM, ] <- as.matrix(anova(sol, ...))[1,]
- if (out[.ITRM, "N.Perm"] > bigperm) {
- bigperm <- out[.ITRM, "N.Perm"]
- bigseed <- get(".Random.seed", envir = .GlobalEnv,
- inherits = FALSE)
- }
- if (out[.ITRM, "Pr(>F)"] > cutoff)
- break
- }
- }
- assign(".Random.seed", bigseed, envir = .GlobalEnv)
- class(out) <- c("anova.cca", "anova", "data.frame")
- out
-}
Deleted: pkg/vegan/R/anova.ccabymargin.R
===================================================================
--- pkg/vegan/R/anova.ccabymargin.R 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/R/anova.ccabymargin.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,52 +0,0 @@
-`anova.ccabymargin` <-
- function(object, step=100, scope, ...)
-{
- if(inherits(object, "prc"))
- stop("anova(..., by = 'margin') cannot be used for 'prc' results")
- if (!missing(scope) && is.character(scope))
- trms <- scope
- else
- trms <- drop.scope(object, scope)
- alltrms <- labels(terms(object$terminfo))
- keep <- trms %in% alltrms
- trms <- trms[keep]
- ntrms <- length(trms)
- bigperm <- 0
- for (.ITRM in 1:ntrms) {
- fla <- formula(object)
- ## Put all trms except current into Condition() and update
- ## formula
- if (length(alltrms) > 1) {
- keeptrms <- alltrms[!(alltrms==trms[.ITRM])]
- updfla <- paste("Condition(",paste(keeptrms, collapse="+"), ")")
- fla <- update(fla, paste(". ~ . + ", updfla))
- }
- tmp <- update(object, fla)
- tmp <- anova(tmp, step=step, ...)
- ## Start every permutation from the same seed, but get the
- ## seed of the longest simulation and reset the RNG to that
- ## state when exiting the function
- if (tmp[1,"N.Perm"] > bigperm) {
- bigperm <- tmp[1, "N.Perm"]
- bigseed <- get(".Random.seed", envir = .GlobalEnv,
- inherits = FALSE)
- }
- if (.ITRM == 1) {
- seed <- attr(tmp, "Random.seed")
- sol <- tmp
- }
- else {
- sol <- rbind(sol[1:(.ITRM-1),], as.matrix(tmp[1,]), sol[.ITRM,])
- }
- assign(".Random.seed", seed, envir = .GlobalEnv)
- }
- ## Put RNG at the end of the longest simulation
- if (bigperm > 0)
- assign(".Random.seed", bigseed, envir = .GlobalEnv)
- rownames(sol)[1:ntrms] <- trms
- head <- attr(sol, "heading")
- head[1] <- paste(head[1], "Marginal effects of terms\n", sep="")
- head[2] <- paste("Model:", c(object$call))
- attr(sol, "heading") <- head
- sol
-}
Deleted: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/R/anova.ccabyterm.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,78 +0,0 @@
-`anova.ccabyterm` <-
- function (object, step = 100, ...)
-{
- ## Data set size may change during iteration if there are missing
- ## values: use length(object$residual) to check this like step,
- ## drop1.default, add1.default do.
- n0 <- length(object$residuals)
- trm <- terms(object)
- call <- paste("Model:", c(object$call))
- trmlab <- attr(trm, "term.labels")
- trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo),
- "term.labels")]
- ntrm <- length(trmlab)
- ## 'adj' puts the result together with the permutations and reduces
- ## number of simulations by one so that P = (hits+1)/(permutations+1).
- ## The first step is reduced by adj.
- adj <- (step %% 10) == 0
- step <- step - adj
- pchi <- matrix(0, nrow = ntrm + 1, ncol = step)
- chi <- numeric(ntrm + 1)
- df <- numeric(ntrm + 1)
- names(df) <- c(trmlab, "Residual")
- sim <- permutest.cca(object, permutations = step, ...)
- pchi[ntrm + 1, ] <- sim$den
- pchi[ntrm, ] <- sim$num
- df[ntrm:(ntrm + 1)] <- sim$df
- chi[ntrm:(ntrm + 1)] <- sim$chi
- if (!is.null(object$call$data))
- modelframe <- ordiGetData(object$call, globalenv())
- else
- modelframe <- model.frame(object)
- for (.ITRM in ntrm:2) {
- if (ntrm < 2)
- break
- assign(".Random.seed", sim$Random.seed, envir = .GlobalEnv)
- fla <- as.formula(paste(" . ~ . -", trmlab[.ITRM]))
- object <- update(object, fla,
- if (!is.null(modelframe)) data = modelframe)
- ## Change in data set due to missing values?
- if (length(object$residuals) != n0)
- stop("number of rows has changed: remove missing values?")
- if (is.null(object$CCA))
- break
- sim <- permutest.cca(object, permutations = step, ...)
- pchi[.ITRM, ] <- pchi[.ITRM, ] - sim$num
- chi[.ITRM] <- chi[.ITRM] - sim$chi[1]
- df[.ITRM] <- df[.ITRM] - sim$df[1]
- pchi[.ITRM - 1, ] <- sim$num
- chi[.ITRM - 1] <- sim$chi[1]
- df[.ITRM - 1] <- sim$df[1]
- }
- Fval <- chi/df/(chi[ntrm + 1]/df[ntrm + 1])
- Fval[ntrm + 1] <- NA
- 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)], ">="))
- P <- c((P + adj)/(step + adj), NA)
- out <- data.frame(df, chi, Fval, c(rep(step, ntrm), NA),
- P)
- inertname <- if (sim$method == "cca")
- "Chisq"
- else "Var"
- colnames(out) <- c("Df", inertname, "F", "N.Perm", "Pr(>F)")
- out <- out[out[, 1] > 0 | out[, 2] > sqrt(.Machine$double.eps),
- ]
- head <- paste("Permutation test for", sim$method, "under",
- sim$model, "model\nTerms added sequentially (first to last)\n")
- if (!is.null(sim$strata))
- head <- paste(head, "Permutations stratified within '",
- sim$strata, "'\n", sep = "")
- structure(out, heading = c(head, call), Random.seed = sim$Random.seed,
- class = c("anova.cca", "anova", "data.frame"))
-}
Copied: pkg/vegan/R/ccanova.R (from rev 2796, pkg/vegan/R/anova.cca.R)
===================================================================
--- pkg/vegan/R/ccanova.R (rev 0)
+++ pkg/vegan/R/ccanova.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -0,0 +1,62 @@
+`anova.cca` <-
+ function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999,
+ by = NULL, ...)
+{
+ if (is.null(object$CA) || is.null(object$CCA) ||
+ object$CCA$rank == 0 || object$CA$rank == 0)
+ return(anova.ccanull(object))
+ perm.max <- max(step-1, perm.max)
+ if (perm.max %% step == 0)
+ perm.max <- perm.max - 1
+ if (!is.null(by)) {
+ by <- match.arg(by, c("axis", "terms", "margin"))
+ if (by == "axis")
+ sol <- ccanova.byaxis(object, alpha = alpha, beta = beta,
+ step = step, perm.max = perm.max, by = NULL,
+ ...)
+ else if (by == "margin") {
+ sol <- ccanova.bymargin(object, alpha = alpha, beta = beta,
+ step = step, perm.max = perm.max,
+ by = NULL, ...)
+ }
+ else {
+ mf <- match.call(expand.dots = FALSE)
+ if (!is.null(mf$...) && any(k <- pmatch(names(mf$...),
+ "permutations", nomatch = FALSE)))
+ step <- unlist(mf$...[k == 1])
+ sol <- ccanova.byterm(object, step = step, ...)
+ }
+ return(sol)
+ }
+ seed <- NULL
+ betaq <- c(beta/2, 1 - beta/2)
+ nperm <- 0
+ unsure <- TRUE
+ hits <- 0
+ while (unsure && nperm < perm.max) {
+ adj <- as.numeric(nperm == 0)
+ tst <- permutest.cca(object, step - adj, ...)
+ if (is.null(seed))
+ seed <- tst$Random.seed
+ nperm <- nperm + step - adj
+ hits <- hits + sum(tst$F.perm >= tst$F.0)
+ fork <- qbinom(betaq, nperm, alpha)
+ if (hits < fork[1] || hits > fork[2])
+ unsure <- FALSE
+ }
+ Fval <- c(tst$F.0, NA)
+ Pval <- c((hits+1)/(nperm+1), NA)
+ nperm <- c(nperm, NA)
+ table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval)
+ is.rda <- inherits(object, "rda")
+ colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"),
+ "F", "N.Perm", "Pr(>F)")
+ head <- paste("Permutation test for", tst$method, "under",
+ tst$model, "model\n")
+ if (!is.null(tst$strata))
+ head <- paste(head, "Permutations stratified within '",
+ tst$strata, "'\n", sep = "")
+ mod <- paste("Model:", c(object$call))
+ structure(table, heading = c(head, mod), Random.seed = seed,
+ class = c("anova.cca", "anova", "data.frame"))
+}
Copied: pkg/vegan/R/ccanova.byaxis.R (from rev 2796, pkg/vegan/R/anova.ccabyaxis.R)
===================================================================
--- pkg/vegan/R/ccanova.byaxis.R (rev 0)
+++ pkg/vegan/R/ccanova.byaxis.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -0,0 +1,89 @@
+`ccanova.byaxis` <-
+ function (object, cutoff = 1, ...)
+{
+ cutoff <- cutoff + sqrt(.Machine$double.eps)
+ rnk <- object$CCA$rank
+ if (!max(rnk, 0))
+ stop("Needs a constrained ordination")
+ if (is.null(object$terms))
+ stop("Analysis is only possible for models fitted using formula")
+ ## Handle missing values in scores, both "omit" and "exclude" to
+ ## match dims with data.
+ if (!is.null(object$na.action)) {
+ u <- napredict(structure(object$na.action, class="exclude"),
+ object$CCA$u)
+ } else {
+ u <- object$CCA$u
+ }
+ ## Get conditions
+ if (!is.null(object$pCCA)) {
+ CondMat <- qr.X(object$pCCA$QR)
+ ## deweight if CCA
+ if (!inherits(object, "rda"))
+ CondMat <- sweep(CondMat, 1, sqrt(object$rowsum), "/")
+ }
+ else
+ CondMat <- NULL
+ ## pad with NA rows if there is a subset
+ if (!is.null(object$subset)) {
+ lc <- matrix(NA, nrow=length(object$subset),
+ ncol = NCOL(u))
+ lc[object$subset,] <- u
+ if (!is.null(CondMat)) {
+ tmp <- matrix(NA, nrow=length(object$subset),
+ ncol = NCOL(CondMat))
+ tmp[object$subset,] <- CondMat
+ CondMat <- tmp
+ }
+ object$call$subset <- object$subset
+ } else {
+ lc <- u
+ }
+ lc <- as.data.frame(lc)
+ axnam <- colnames(lc)
+ df <- c(rep(1, rnk), object$CA$rank)
+ chi <- c(object$CCA$eig, Residual = object$CA$tot.chi)
+ Fval <- c(chi[1:rnk]/df[1:rnk]/chi[rnk+1]*df[rnk+1], NA)
+ nperm <- c(numeric(rnk), NA)
+ Pval <- rep(NA, rnk+1)
+ out <- data.frame(df, chi, Fval, nperm, Pval)
+ environment(object$terms) <- environment()
+ fla <- paste(". ~ ", axnam[1], "+ Condition(",
+ paste(axnam[-1], collapse="+"),")")
+ if (!is.null(CondMat)) {
+ fla <- paste(fla, " + Condition(CondMat)")
+ lc$CondMat <- CondMat
+ }
+ fla <- update(formula(object), fla)
+ sol <- ccanova(update(object, fla, data=lc), ...)
+ out[c(1, rnk + 1), ] <- sol
+ seed <- attr(sol, "Random.seed")
+ attr(out, "names") <- attr(sol, "names")
+ .call <- pasteCall(object$call, "Model:")
+ attr(out, "heading") <- sub(" \n","", .call)
+ attr(out, "Random.seed") <- seed
+ bigseed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
+ bigperm <- out$N.Perm[1]
+ if (rnk > 1) {
+ for (.ITRM in 2:rnk) {
+ fla <- paste(".~", axnam[.ITRM], "+Condition(",
+ paste(axnam[-(.ITRM)], collapse="+"),")")
+ if (!is.null(CondMat))
+ fla <- paste(fla, "+ Condition(CondMat)")
+ fla <- update(formula(object), fla)
+ sol <- update(object, fla, data = lc)
+ assign(".Random.seed", seed, envir = .GlobalEnv)
+ out[.ITRM, ] <- as.matrix(ccanova(sol, ...))[1,]
+ if (out[.ITRM, "N.Perm"] > bigperm) {
+ bigperm <- out[.ITRM, "N.Perm"]
+ bigseed <- get(".Random.seed", envir = .GlobalEnv,
+ inherits = FALSE)
+ }
+ if (out[.ITRM, "Pr(>F)"] > cutoff)
+ break
+ }
+ }
+ assign(".Random.seed", bigseed, envir = .GlobalEnv)
+ class(out) <- c("anova.cca", "anova", "data.frame")
+ out
+}
Copied: pkg/vegan/R/ccanova.bymargin.R (from rev 2796, pkg/vegan/R/anova.ccabymargin.R)
===================================================================
--- pkg/vegan/R/ccanova.bymargin.R (rev 0)
+++ pkg/vegan/R/ccanova.bymargin.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -0,0 +1,52 @@
+`ccanova.bymargin` <-
+ function(object, step=100, scope, ...)
+{
+ if(inherits(object, "prc"))
+ stop("ccanova(..., by = 'margin') cannot be used for 'prc' results")
+ if (!missing(scope) && is.character(scope))
+ trms <- scope
+ else
+ trms <- drop.scope(object, scope)
+ alltrms <- labels(terms(object$terminfo))
+ keep <- trms %in% alltrms
+ trms <- trms[keep]
+ ntrms <- length(trms)
+ bigperm <- 0
+ for (.ITRM in 1:ntrms) {
+ fla <- formula(object)
+ ## Put all trms except current into Condition() and update
+ ## formula
+ if (length(alltrms) > 1) {
+ keeptrms <- alltrms[!(alltrms==trms[.ITRM])]
+ updfla <- paste("Condition(",paste(keeptrms, collapse="+"), ")")
+ fla <- update(fla, paste(". ~ . + ", updfla))
+ }
+ tmp <- update(object, fla)
+ tmp <- ccanova(tmp, step=step, ...)
+ ## Start every permutation from the same seed, but get the
+ ## seed of the longest simulation and reset the RNG to that
+ ## state when exiting the function
+ if (tmp[1,"N.Perm"] > bigperm) {
+ bigperm <- tmp[1, "N.Perm"]
+ bigseed <- get(".Random.seed", envir = .GlobalEnv,
+ inherits = FALSE)
+ }
+ if (.ITRM == 1) {
+ seed <- attr(tmp, "Random.seed")
+ sol <- tmp
+ }
+ else {
+ sol <- rbind(sol[1:(.ITRM-1),], as.matrix(tmp[1,]), sol[.ITRM,])
+ }
+ assign(".Random.seed", seed, envir = .GlobalEnv)
+ }
+ ## Put RNG at the end of the longest simulation
+ if (bigperm > 0)
+ assign(".Random.seed", bigseed, envir = .GlobalEnv)
+ rownames(sol)[1:ntrms] <- trms
+ head <- attr(sol, "heading")
+ head[1] <- paste(head[1], "Marginal effects of terms\n", sep="")
+ head[2] <- paste("Model:", c(object$call))
+ attr(sol, "heading") <- head
+ sol
+}
Copied: pkg/vegan/R/ccanova.byterm.R (from rev 2796, pkg/vegan/R/anova.ccabyterm.R)
===================================================================
--- pkg/vegan/R/ccanova.byterm.R (rev 0)
+++ pkg/vegan/R/ccanova.byterm.R 2013-12-03 17:03:28 UTC (rev 2799)
@@ -0,0 +1,78 @@
+`ccanova.byterm` <-
+ function (object, step = 100, ...)
+{
+ ## Data set size may change during iteration if there are missing
+ ## values: use length(object$residual) to check this like step,
+ ## drop1.default, add1.default do.
+ n0 <- length(object$residuals)
+ trm <- terms(object)
+ call <- paste("Model:", c(object$call))
+ trmlab <- attr(trm, "term.labels")
+ trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo),
+ "term.labels")]
+ ntrm <- length(trmlab)
+ ## 'adj' puts the result together with the permutations and reduces
+ ## number of simulations by one so that P = (hits+1)/(permutations+1).
+ ## The first step is reduced by adj.
+ adj <- (step %% 10) == 0
+ step <- step - adj
+ pchi <- matrix(0, nrow = ntrm + 1, ncol = step)
+ chi <- numeric(ntrm + 1)
+ df <- numeric(ntrm + 1)
+ names(df) <- c(trmlab, "Residual")
+ sim <- permutest.cca(object, permutations = step, ...)
+ pchi[ntrm + 1, ] <- sim$den
+ pchi[ntrm, ] <- sim$num
+ df[ntrm:(ntrm + 1)] <- sim$df
+ chi[ntrm:(ntrm + 1)] <- sim$chi
+ if (!is.null(object$call$data))
+ modelframe <- ordiGetData(object$call, globalenv())
+ else
+ modelframe <- model.frame(object)
+ for (.ITRM in ntrm:2) {
+ if (ntrm < 2)
+ break
+ assign(".Random.seed", sim$Random.seed, envir = .GlobalEnv)
+ fla <- as.formula(paste(" . ~ . -", trmlab[.ITRM]))
+ object <- update(object, fla,
+ if (!is.null(modelframe)) data = modelframe)
+ ## Change in data set due to missing values?
+ if (length(object$residuals) != n0)
+ stop("number of rows has changed: remove missing values?")
+ if (is.null(object$CCA))
+ break
+ sim <- permutest.cca(object, permutations = step, ...)
+ pchi[.ITRM, ] <- pchi[.ITRM, ] - sim$num
+ chi[.ITRM] <- chi[.ITRM] - sim$chi[1]
+ df[.ITRM] <- df[.ITRM] - sim$df[1]
+ pchi[.ITRM - 1, ] <- sim$num
+ chi[.ITRM - 1] <- sim$chi[1]
+ df[.ITRM - 1] <- sim$df[1]
+ }
+ Fval <- chi/df/(chi[ntrm + 1]/df[ntrm + 1])
+ Fval[ntrm + 1] <- NA
+ 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)], ">="))
+ P <- c((P + adj)/(step + adj), NA)
+ out <- data.frame(df, chi, Fval, c(rep(step, ntrm), NA),
+ P)
+ inertname <- if (sim$method == "cca")
+ "Chisq"
+ else "Var"
+ colnames(out) <- c("Df", inertname, "F", "N.Perm", "Pr(>F)")
+ out <- out[out[, 1] > 0 | out[, 2] > sqrt(.Machine$double.eps),
+ ]
+ head <- paste("Permutation test for", sim$method, "under",
+ sim$model, "model\nTerms added sequentially (first to last)\n")
+ if (!is.null(sim$strata))
+ head <- paste(head, "Permutations stratified within '",
+ sim$strata, "'\n", sep = "")
+ structure(out, heading = c(head, call), Random.seed = sim$Random.seed,
+ class = c("anova.cca", "anova", "data.frame"))
+}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/inst/ChangeLog 2013-12-03 17:03:28 UTC (rev 2799)
@@ -2,7 +2,13 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 2.1-39 (opened November 10, 2013)
+Version 2.1-40 (opened December 3, 2013)
+
+ * anova.cca: start deprecation of old anova.cca and rename it to
+ ccanova. Vegan should fail all tests while deprecation is
+ incomplete and new code is not yet in use.
+
+Version 2.1-39 (closed December 3, 2013)
* anova.cca: started to rewrite the anova.cca family of functions
for permute package. At the first stage, a temporary development
Deleted: pkg/vegan/man/anova.cca.Rd
===================================================================
--- pkg/vegan/man/anova.cca.Rd 2013-12-03 16:37:33 UTC (rev 2798)
+++ pkg/vegan/man/anova.cca.Rd 2013-12-03 17:03:28 UTC (rev 2799)
@@ -1,80 +0,0 @@
-\name{anova.cca}
-\alias{anova.cca}
-\alias{anova.ccanull}
-\alias{anova.ccabyaxis}
-\alias{anova.ccabyterm}
-\alias{anova.ccabymargin}
-\alias{anova.prc}
-
-\title{Permutation Test for Constrained Correspondence Analysis,
- Redundancy Analysis and Constrained Analysis of Principal Coordinates }
-\description{
- This function is deprecated.
-}
-\usage{
-\method{anova}{cca}(object, alpha=0.05, beta=0.01, step=100, perm.max=9999,
- by = NULL, ...)
-}
-
-\arguments{
- \item{object}{A result object from \code{\link{cca}}. }
- \item{alpha}{Targeted Type I error rate. }
- \item{beta}{Accepted Type II error rate. }
- \item{step}{Number of permutations during one step. }
- \item{perm.max}{Maximum number of permutations. }
- \item{by}{Setting \code{by = "axis"} will assess significance for each
- constrained axis, and setting \code{by = "terms"} will assess
- significance for each term (sequentially from first to last), and
- setting \code{by = "margin"} will assess the marginal effects of the
- terms (each marginal term analysed in a model with all other
- variables).}
- \item{\dots}{Parameters passed to other functions.
- \code{anova.cca} passes all arguments to
- \code{permutest.cca}. In \code{anova} with \code{by = "axis"} you
- can use argument \code{cutoff} (defaults \code{1}) which stops
- permutations after exceeding the given level. }
-}
-\details{
-
- This function contains a deprecated version of \code{anova.cca}.
- The new function is completely rewritten. With the same random
- number seed and the same number of permutations, the results are
- mostly identical. The only difference is that marginal tests
- (\code{by = "margin"}) are implemented differently. The most
- important difference is that the new code is based on the
- \pkg{permute} package and uses the fixed number of permutations in
- all tests (cf. below). Both the new and old functions are based
- \code{\link{permutest.cca}}, and the function can pass extra
- arguments to \code{permutest.cca}.
-
- In \code{anova.cca} the number of permutations is controlled by
- targeted \dQuote{critical} \eqn{P} value (\code{alpha}) and accepted
- Type II or rejection error (\code{beta}). If the results of
- permutations differ from the targeted \code{alpha} at risk level
- given by \code{beta}, the permutations are terminated. If the
- current estimate of \eqn{P} does not differ significantly from
- \code{alpha} of the alternative hypothesis, the permutations are
- continued with \code{step} new permutations (at the first step, the
- number of permutations is \code{step - 1}). However, with
- \code{by="terms"} a fixed number of permutations will be used, and
- this is given by argument \code{permutations}, or if this is
- missing, by \code{step}.
-
-}
-
-\note{
- The function is deprecated and replaced with \code{\link{anova.cca}}.
-}
-\references{
- Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd
- English ed. Elsevier.
-
- Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the
- significance of canonical axes in redundancy analysis.
- \emph{Methods in Ecology and Evolution} 2, 269--277.
-}
-\author{Jari Oksanen}
-
-\keyword{ multivariate }
-\keyword{ htest }
-
Added: pkg/vegan/man/ccanova.Rd
===================================================================
--- pkg/vegan/man/ccanova.Rd (rev 0)
+++ pkg/vegan/man/ccanova.Rd 2013-12-03 17:03:28 UTC (rev 2799)
@@ -0,0 +1,72 @@
+\name{ccanova}
+\alias{ccanova}
+\alias{anova.prc}
+
+\title{Permutation Test for Constrained Correspondence Analysis,
+ Redundancy Analysis and Constrained Analysis of Principal Coordinates }
+\description{
+ This function is deprecated.
+}
+\usage{
+ccanova(object, alpha=0.05, beta=0.01, step=100, perm.max=9999,
+ by = NULL, ...)
+}
+
+\arguments{
+ \item{object}{A result object from \code{\link{cca}}. }
+ \item{alpha}{Targeted Type I error rate. }
+ \item{beta}{Accepted Type II error rate. }
+ \item{step}{Number of permutations during one step. }
+ \item{perm.max}{Maximum number of permutations. }
+ \item{by}{Setting \code{by = "axis"} will assess significance for each
+ constrained axis, and setting \code{by = "terms"} will assess
+ significance for each term (sequentially from first to last), and
+ setting \code{by = "margin"} will assess the marginal effects of the
+ terms (each marginal term analysed in a model with all other
+ variables).}
+ \item{\dots}{Parameters passed to other functions.
+ \code{anova.cca} passes all arguments to
+ \code{permutest.cca}. In \code{anova} with \code{by = "axis"} you
+ can use argument \code{cutoff} (defaults \code{1}) which stops
+ permutations after exceeding the given level. }
+}
+\details{
+
+ Function \code{ccanova} is a deprecated version of \code{anova.cca}.
+ The new \code{link{\anova.cca}} function is completely
+ rewritten. With the same random number seed and the same number of
+ permutations, the results are mostly identical. The only difference
+ is that marginal tests (\code{by = "margin"}) are implemented
+ differently. The most important difference is that the new code is
+ based on the \pkg{permute} package and uses the fixed number of
+ permutations in all tests (cf. below). Both the new and old
+ functions are based \code{\link{permutest.cca}}, and the function
+ can pass extra arguments to \code{permutest.cca}.
+
+ In \code{ccanova} the number of permutations is controlled by
+ targeted \dQuote{critical} \eqn{P} value (\code{alpha}) and accepted
+ Type II or rejection error (\code{beta}). If the results of
+ permutations differ from the targeted \code{alpha} at risk level
+ given by \code{beta}, the permutations are terminated. If the
+ current estimate of \eqn{P} does not differ significantly from
+ \code{alpha} of the alternative hypothesis, the permutations are
+ continued with \code{step} new permutations (at the first step, the
+ number of permutations is \code{step - 1}). However, with
+ \code{by="terms"} a fixed number of permutations will be used, and
+ this is given by argument \code{permutations}, or if this is
+ missing, by \code{step}.
+
+}
+
+\note{
+ The function is deprecated and replaced with \code{\link{anova.cca}}.
+}
+\references{
+ Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd
+ English ed. Elsevier.
+}
+\author{Jari Oksanen}
+
+\keyword{ multivariate }
+\keyword{ htest }
+
From noreply at r-forge.r-project.org Tue Dec 3 18:13:16 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 18:13:16 +0100 (CET)
Subject: [Vegan-commits] r2800 - in pkg/vegan: R inst man
Message-ID: <20131203171316.8400C184724@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 18:13:16 +0100 (Tue, 03 Dec 2013)
New Revision: 2800
Added:
pkg/vegan/R/anova.cca.R
pkg/vegan/R/anova.ccabyterm.R
pkg/vegan/man/anova.cca.Rd
Removed:
pkg/vegan/R/anovacca.R
pkg/vegan/R/anovacca.byterm.R
pkg/vegan/man/anovacca.Rd
Modified:
pkg/vegan/inst/ChangeLog
Log:
second step of new anova.cca: rename anovacca to anova.cca -- expect trouble
Copied: pkg/vegan/R/anova.cca.R (from rev 2796, pkg/vegan/R/anovacca.R)
===================================================================
--- pkg/vegan/R/anova.cca.R (rev 0)
+++ pkg/vegan/R/anova.cca.R 2013-12-03 17:13:16 UTC (rev 2800)
@@ -0,0 +1,90 @@
+`anova.cca` <-
+ function(object, ..., permutations = how(nperm=999), by = NULL,
+ model = c("reduced", "direct", "full"),
+ parallel = getOption("mc.cores"), strata = NULL,
+ cutoff = 1, scope = NULL)
+{
+ model <- match.arg(model)
+ ## permutations is either a single number, a how() structure or a
+ ## permutation matrix
+ if (length(permutations) == 1) {
+ nperm <- permutations
+ permutations <- how(nperm = nperm)
+ }
+ if (!is.null(strata)) {
+ if (!inherits(permutations, "how"))
+ stop("'strata' can be used only with simple permutation or with 'how()'")
+ if (!is.null(permutations$block))
+ stop("'strata' cannot be applied when 'blocks' are defined in 'how()'")
+ setBlocks(permutations) <- strata
+ }
+ ## now permutations is either a how() structure or a permutation
+ ## matrix. Make it to a matrix if it is "how"
+ if (inherits(permutations, "how")) {
+ permutations <- shuffleSet(nrow(object$CA$u),
+ control = permutations)
+ seed <- attr(permutations, "seed")
+ control <- attr(permutations, "control")
+ }
+ else # we got a permutation matrix and seed & control are unknown
+ seed <- control <- NULL
+ nperm <- nrow(permutations)
+ ## stop permutations block
+ ## see if this was a list of ordination objects
+ dotargs <- list(...)
+ ## we do not want to give dotargs to anova.ccalist, but we
+ ## evaluate 'parallel' and 'model' here
+ if (length(dotargs)) {
+ isCCA <- sapply(dotargs, function(z) inherits(z, "cca"))
+ if (any(isCCA)) {
+ dotargs <- dotargs[isCCA]
+ object <- c(list(object), dotargs)
+ sol <-
+ anova.ccalist(object,
+ permutations = permutations,
+ model = model,
+ parallel = parallel)
+ attr(sol, "Random.seed") <- seed
+ attr(sol, "control") <- control
+ return(sol)
+ }
+ }
+ ## We only have a single model: check if it is empty
+ if (is.null(object$CA) || is.null(object$CCA) ||
+ object$CCA$rank == 0 || object$CA$rank == 0)
+ return(anova.ccanull(object))
+ ## by cases
+ if (!is.null(by)) {
+ by <- match.arg(by, c("terms", "margin", "axis"))
+ sol <- switch(by,
+ "terms" = anova.ccabyterm(object,
+ permutations = permutations,
+ model = model, parallel = parallel),
+ "margin" = anova.ccabymargin(object,
+ permutations = permutations,
+ model = model, parallel = parallel,
+ scope = scope),
+ "axis" = anova.ccabyaxis(object,
+ permutations = permutations,
+ model = model, parallel = parallel,
+ cutoff = cutoff))
+ attr(sol, "Random.seed") <- seed
+ attr(sol, "control") <- control
+ return(sol)
+ }
+ ## basic overall test
+ tst <- permutest.cca(object, permutations = permutations, ...)
+ Fval <- c(tst$F.0, NA)
+ Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1)
+ Pval <- c(Pval, NA)
+ table <- data.frame(tst$df, tst$chi, Fval, Pval)
+ is.rda <- inherits(object, "rda")
+ colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
+ head <- paste0("Permutation test for ", tst$method, " under ",
+ tst$model, " model\n", howHead(control))
+ mod <- paste("Model:", c(object$call))
+ structure(table, heading = c(head, mod), Random.seed = seed,
+ control = control,
+ class = c("anova.cca", "anova", "data.frame"))
+}
Copied: pkg/vegan/R/anova.ccabyterm.R (from rev 2796, pkg/vegan/R/anovacca.byterm.R)
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R (rev 0)
+++ pkg/vegan/R/anova.ccabyterm.R 2013-12-03 17:13:16 UTC (rev 2800)
@@ -0,0 +1,171 @@
+### Implementation of by-cases for vegan 2.2 versions of
+### anova.cca. These are all internal functions that are not intended
+### to be called by users in normal sessions, but they should be
+### called from anova.cca (2.2). Therefore the user interface is rigid
+### and input is not checked. The 'permutations' should be a
+### permutation matrix.
+
+### by = terms builds models as a sequence of adding terms and submits
+### this to anova.ccalist
+
+`anova.ccabyterm` <-
+ function(object, permutations, model, parallel)
+{
+ ## We need term labels but without Condition() terms
+ trms <- terms(object)
+ trmlab <- attr(trms, "term.labels")
+ trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo),
+ "term.labels")]
+ ntrm <- length(trmlab)
+ m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-")))
+ mods <- list(m0)
+ for(i in seq_along(trmlab)) {
+ fla <- paste(". ~ . + ", trmlab[i])
+ mods[[i+1]] <- update(mods[[i]], fla)
+ }
+ ## The result
+ sol <- anova.ccalist(mods, permutations = permutations,
+ model = model, parallel = parallel)
+ ## Reformat
+ out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]),
+ c(sol[-1,4], sol[ntrm+1,2]),
+ c(sol[-1,5], NA),
+ c(sol[-1,6], NA))
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
+ rownames(out) <- c(trmlab, "Residual")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ model, " model\n",
+ "Terms added sequentially (first to last)\n",
+ howHead(attr(permutations, "control")))
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
+ class(out) <- c("anova","data.frame")
+ out
+}
+
+## by = margin: this is not a anova.ccalist case, but we omit each
+## term in turn and compare against the complete model.
+
+`anova.ccabymargin` <-
+ function(object, permutations, scope, ...)
+{
+ nperm <- nrow(permutations)
+ ## Refuse to handle models with missing data
+ if (!is.null(object$na.action))
+ stop("by = 'margin' models cannot handle missing data")
+ ## We need term labels but without Condition() terms
+ if (!is.null(scope) && is.character(scope))
+ trms <- scope
+ else
+ trms <- drop.scope(object)
+ trmlab <- trms[trms %in% attr(terms(object$terminfo),
+ "term.labels")]
+ if(length(trmlab) == 0)
+ stop("the scope was empty: no available marginal terms")
+ ## baseline: all terms
+ big <- permutest(object, permutations, ...)
+ dfbig <- big$df[2]
+ chibig <- big$chi[2]
+ scale <- big$den/dfbig
+ ## Collect all marginal models. This differs from old version
+ ## (vegan 2.0) where other but 'nm' were partialled out within
+ ## Condition(). Now we only fit the model without 'nm' and compare
+ ## the difference against the complete model.
+ mods <- lapply(trmlab, function(nm, ...)
+ permutest(update(object, paste(".~.-", nm)),
+ permutations, ...), ...)
+ ## Chande in df
+ Df <- sapply(mods, function(x) x$df[2]) - dfbig
+ ## F of change
+ Chisq <- sapply(mods, function(x) x$chi[2]) - chibig
+ Fstat <- (Chisq/Df)/(chibig/dfbig)
+ ## Simulated F-values
+ Fval <- sapply(mods, function(x) x$num)
+ ## 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$num, "+")
+ Fval <- sweep(Fval, 2, Df, "/")
+ Fval <- sweep(Fval, 1, scale, "/")
+ ## Simulated P-values
+ Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1)
+ ## Collect results to anova data.frame
+ out <- data.frame(c(Df, dfbig), c(Chisq, chibig),
+ c(Fstat, NA), c(Pval, NA))
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
+ rownames(out) <- c(trmlab, "Residual")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ mods[[1]]$model, " model\n",
+ "Marginal effects of terms\n",
+ howHead(attr(permutations, "control")))
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
+ class(out) <- c("anova", "data.frame")
+ out
+}
+
+### Marginal test for axes
+
+`anova.ccabyaxis` <-
+ function(object, permutations, model, parallel, cutoff = 1)
+{
+ nperm <- nrow(permutations)
+ ## Observed F-values and Df
+ eig <- object$CCA$eig
+ resdf <- nobs(object) - length(eig) - max(object$pCCA$rank, 0) - 1
+ Fstat <- eig/object$CA$tot.chi*resdf
+ Df <- rep(1, length(eig))
+ ## Marginal P-values
+ LC <- object$CCA$u
+ ## missing values?
+ if (!is.null(object$na.action))
+ LC <- napredict(structure(object$na.action,
+ class="exclude"), LC)
+ ## subset?
+ if (!is.null(object$subset)) {
+ tmp <- matrix(NA, nrow=length(object$subset),
+ ncol = ncol(LC))
+ tmp[object$subset,] <- LC
+ LC <- tmp
+ object <- update(object, subset = object$subset)
+ }
+ LC <- as.data.frame(LC)
+ fla <- reformulate(names(LC))
+ Pvals <- rep(NA, length(eig))
+ environment(object$terms) <- environment()
+ for (i in 1:length(eig)) {
+ part <- paste("~ . +Condition(",
+ paste(names(LC)[-i], collapse = "+"), ")")
+ upfla <- update(fla, part)
+ ## only one axis, and cannot partial out?
+ if (length(eig) == 1)
+ mod <- permutest(object, permutations, model = model,
+ parallel = parallel)
+ else
+ mod <-
+ permutest(update(object, upfla, data = LC),
+ permutations, model = model,
+ parallel = parallel)
+ Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1)
+ if (Pvals[i] > cutoff)
+ break
+ }
+ out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi),
+ c(Fstat, NA), c(Pvals,NA))
+ rownames(out) <- c(names(eig), "Residual")
+ isRDA <- inherits(object, "rda")
+ colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
+ "F", "Pr(>F)")
+ head <- paste0("Permutation test for ", object$method, " under ",
+ model, " model\n",
+ "Marginal tests for axes\n",
+ howHead(attr(permutations, "control")))
+ mod <- paste("Model:", c(object$call))
+ attr(out, "heading") <- c(head, mod)
+ class(out) <- c("anova", "data.frame")
+ out
+}
Deleted: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R 2013-12-03 17:03:28 UTC (rev 2799)
+++ pkg/vegan/R/anovacca.R 2013-12-03 17:13:16 UTC (rev 2800)
@@ -1,90 +0,0 @@
-`anovacca` <-
- function(object, ..., permutations = how(nperm=999), by = NULL,
- model = c("reduced", "direct", "full"),
- parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1, scope = NULL)
-{
- model <- match.arg(model)
- ## permutations is either a single number, a how() structure or a
- ## permutation matrix
- if (length(permutations) == 1) {
- nperm <- permutations
- permutations <- how(nperm = nperm)
- }
- if (!is.null(strata)) {
- if (!inherits(permutations, "how"))
- stop("'strata' can be used only with simple permutation or with 'how()'")
- if (!is.null(permutations$block))
- stop("'strata' cannot be applied when 'blocks' are defined in 'how()'")
- setBlocks(permutations) <- strata
- }
- ## now permutations is either a how() structure or a permutation
- ## matrix. Make it to a matrix if it is "how"
- if (inherits(permutations, "how")) {
- permutations <- shuffleSet(nrow(object$CA$u),
- control = permutations)
- seed <- attr(permutations, "seed")
- control <- attr(permutations, "control")
- }
- else # we got a permutation matrix and seed & control are unknown
- seed <- control <- NULL
- nperm <- nrow(permutations)
- ## stop permutations block
- ## see if this was a list of ordination objects
- dotargs <- list(...)
- ## we do not want to give dotargs to anova.ccalist, but we
- ## evaluate 'parallel' and 'model' here
- if (length(dotargs)) {
- isCCA <- sapply(dotargs, function(z) inherits(z, "cca"))
- if (any(isCCA)) {
- dotargs <- dotargs[isCCA]
- object <- c(list(object), dotargs)
- sol <-
- anova.ccalist(object,
- permutations = permutations,
- model = model,
- parallel = parallel)
- attr(sol, "Random.seed") <- seed
- attr(sol, "control") <- control
- return(sol)
- }
- }
- ## We only have a single model: check if it is empty
- if (is.null(object$CA) || is.null(object$CCA) ||
- object$CCA$rank == 0 || object$CA$rank == 0)
- return(anova.ccanull(object))
- ## by cases
- if (!is.null(by)) {
- by <- match.arg(by, c("terms", "margin", "axis"))
- sol <- switch(by,
- "terms" = anovacca.byterm(object,
- permutations = permutations,
- model = model, parallel = parallel),
- "margin" = anovacca.bymargin(object,
- permutations = permutations,
- model = model, parallel = parallel,
- scope = scope),
- "axis" = anovacca.byaxis(object,
- permutations = permutations,
- model = model, parallel = parallel,
- cutoff = cutoff))
- attr(sol, "Random.seed") <- seed
- attr(sol, "control") <- control
- return(sol)
- }
- ## basic overall test
- tst <- permutest.cca(object, permutations = permutations, ...)
- Fval <- c(tst$F.0, NA)
- Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1)
- Pval <- c(Pval, NA)
- table <- data.frame(tst$df, tst$chi, Fval, Pval)
- is.rda <- inherits(object, "rda")
- colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"),
- "F", "Pr(>F)")
- head <- paste0("Permutation test for ", tst$method, " under ",
- tst$model, " model\n", howHead(control))
- mod <- paste("Model:", c(object$call))
- structure(table, heading = c(head, mod), Random.seed = seed,
- control = control,
- class = c("anova.cca", "anova", "data.frame"))
-}
Deleted: pkg/vegan/R/anovacca.byterm.R
===================================================================
--- pkg/vegan/R/anovacca.byterm.R 2013-12-03 17:03:28 UTC (rev 2799)
+++ pkg/vegan/R/anovacca.byterm.R 2013-12-03 17:13:16 UTC (rev 2800)
@@ -1,171 +0,0 @@
-### Implementation of by-cases for vegan 2.2 versions of
-### anova.cca. These are all internal functions that are not intended
-### to be called by users in normal sessions, but they should be
-### called from anova.cca (2.2). Therefore the user interface is rigid
-### and input is not checked. The 'permutations' should be a
-### permutation matrix.
-
-### by = terms builds models as a sequence of adding terms and submits
-### this to anova.ccalist
-
-`anovacca.byterm` <-
- function(object, permutations, model, parallel)
-{
- ## We need term labels but without Condition() terms
- trms <- terms(object)
- trmlab <- attr(trms, "term.labels")
- trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo),
- "term.labels")]
- ntrm <- length(trmlab)
- m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-")))
- mods <- list(m0)
- for(i in seq_along(trmlab)) {
- fla <- paste(". ~ . + ", trmlab[i])
- mods[[i+1]] <- update(mods[[i]], fla)
- }
- ## The result
- sol <- anova.ccalist(mods, permutations = permutations,
- model = model, parallel = parallel)
- ## Reformat
- out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]),
- c(sol[-1,4], sol[ntrm+1,2]),
- c(sol[-1,5], NA),
- c(sol[-1,6], NA))
- isRDA <- inherits(object, "rda")
- colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
- "F", "Pr(>F)")
- rownames(out) <- c(trmlab, "Residual")
- head <- paste0("Permutation test for ", object$method, " under ",
- model, " model\n",
- "Terms added sequentially (first to last)\n",
- howHead(attr(permutations, "control")))
- mod <- paste("Model:", c(object$call))
- attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova","data.frame")
- out
-}
-
-## by = margin: this is not a anova.ccalist case, but we omit each
-## term in turn and compare against the complete model.
-
-`anovacca.bymargin` <-
- function(object, permutations, scope, ...)
-{
- nperm <- nrow(permutations)
- ## Refuse to handle models with missing data
- if (!is.null(object$na.action))
- stop("by = 'margin' models cannot handle missing data")
- ## We need term labels but without Condition() terms
- if (!is.null(scope) && is.character(scope))
- trms <- scope
- else
- trms <- drop.scope(object)
- trmlab <- trms[trms %in% attr(terms(object$terminfo),
- "term.labels")]
- if(length(trmlab) == 0)
- stop("the scope was empty: no available marginal terms")
- ## baseline: all terms
- big <- permutest(object, permutations, ...)
- dfbig <- big$df[2]
- chibig <- big$chi[2]
- scale <- big$den/dfbig
- ## Collect all marginal models. This differs from old version
- ## (vegan 2.0) where other but 'nm' were partialled out within
- ## Condition(). Now we only fit the model without 'nm' and compare
- ## the difference against the complete model.
- mods <- lapply(trmlab, function(nm, ...)
- permutest(update(object, paste(".~.-", nm)),
- permutations, ...), ...)
- ## Chande in df
- Df <- sapply(mods, function(x) x$df[2]) - dfbig
- ## F of change
- Chisq <- sapply(mods, function(x) x$chi[2]) - chibig
- Fstat <- (Chisq/Df)/(chibig/dfbig)
- ## Simulated F-values
- Fval <- sapply(mods, function(x) x$num)
- ## 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$num, "+")
- Fval <- sweep(Fval, 2, Df, "/")
- Fval <- sweep(Fval, 1, scale, "/")
- ## Simulated P-values
- Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1)
- ## Collect results to anova data.frame
- out <- data.frame(c(Df, dfbig), c(Chisq, chibig),
- c(Fstat, NA), c(Pval, NA))
- isRDA <- inherits(object, "rda")
- colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
- "F", "Pr(>F)")
- rownames(out) <- c(trmlab, "Residual")
- head <- paste0("Permutation test for ", object$method, " under ",
- mods[[1]]$model, " model\n",
- "Marginal effects of terms\n",
- howHead(attr(permutations, "control")))
- mod <- paste("Model:", c(object$call))
- attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova", "data.frame")
- out
-}
-
-### Marginal test for axes
-
-`anovacca.byaxis` <-
- function(object, permutations, model, parallel, cutoff = 1)
-{
- nperm <- nrow(permutations)
- ## Observed F-values and Df
- eig <- object$CCA$eig
- resdf <- nobs(object) - length(eig) - max(object$pCCA$rank, 0) - 1
- Fstat <- eig/object$CA$tot.chi*resdf
- Df <- rep(1, length(eig))
- ## Marginal P-values
- LC <- object$CCA$u
- ## missing values?
- if (!is.null(object$na.action))
- LC <- napredict(structure(object$na.action,
- class="exclude"), LC)
- ## subset?
- if (!is.null(object$subset)) {
- tmp <- matrix(NA, nrow=length(object$subset),
- ncol = ncol(LC))
- tmp[object$subset,] <- LC
- LC <- tmp
- object <- update(object, subset = object$subset)
- }
- LC <- as.data.frame(LC)
- fla <- reformulate(names(LC))
- Pvals <- rep(NA, length(eig))
- environment(object$terms) <- environment()
- for (i in 1:length(eig)) {
- part <- paste("~ . +Condition(",
- paste(names(LC)[-i], collapse = "+"), ")")
- upfla <- update(fla, part)
- ## only one axis, and cannot partial out?
- if (length(eig) == 1)
- mod <- permutest(object, permutations, model = model,
- parallel = parallel)
- else
- mod <-
- permutest(update(object, upfla, data = LC),
- permutations, model = model,
- parallel = parallel)
- Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1)
- if (Pvals[i] > cutoff)
- break
- }
- out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi),
- c(Fstat, NA), c(Pvals,NA))
- rownames(out) <- c(names(eig), "Residual")
- isRDA <- inherits(object, "rda")
- colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"),
- "F", "Pr(>F)")
- head <- paste0("Permutation test for ", object$method, " under ",
- model, " model\n",
- "Marginal tests for axes\n",
- howHead(attr(permutations, "control")))
- mod <- paste("Model:", c(object$call))
- attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova", "data.frame")
- out
-}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-12-03 17:03:28 UTC (rev 2799)
+++ pkg/vegan/inst/ChangeLog 2013-12-03 17:13:16 UTC (rev 2800)
@@ -4,9 +4,10 @@
Version 2.1-40 (opened December 3, 2013)
- * anova.cca: start deprecation of old anova.cca and rename it to
- ccanova. Vegan should fail all tests while deprecation is
- incomplete and new code is not yet in use.
+ * anova.cca: Function is now based on the new code, and the old
+ (deprecated) code is called ccanova. Except several functions to
+ fail while they depend on the old interface (certainly add1.cca,
+ drop1.cca, ordistep, ordiR2step).
Version 2.1-39 (closed December 3, 2013)
Copied: pkg/vegan/man/anova.cca.Rd (from rev 2798, pkg/vegan/man/anovacca.Rd)
===================================================================
--- pkg/vegan/man/anova.cca.Rd (rev 0)
+++ pkg/vegan/man/anova.cca.Rd 2013-12-03 17:13:16 UTC (rev 2800)
@@ -0,0 +1,179 @@
+\name{anova.cca}
+\alias{anova.cca}
+%\alias{anova.ccanull}
+%\alias{anova.ccabyaxis}
+%\alias{anova.ccabyterm}
+%\alias{anova.ccabymargin}
+%\alias{anova.prc}
+\alias{permutest}
+%\alias{permutest.default}
+\alias{permutest.cca}
+
+\title{Permutation Test for Constrained Correspondence Analysis,
+ Redundancy Analysis and Constrained Analysis of Principal Coordinates }
+
+\description{
+ The function performs an ANOVA like permutation test for Constrained
+ Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis
+ (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA,
+ \code{\link{capscale}}) to assess the significance of constraints.
+}
+
+\usage{
+\method{anova}{cca}(object, ..., permutations = how(nperm=999),
+ by = NULL, model = c("reduced", "direct", "full"),
+ parallel = getOption("mc.cores"), strata = NULL,
+ cutoff = 1, scope = NULL)
+\method{permutest}{cca}(x, permutations = how(nperm = 99),
+ model = c("reduced", "direct"), first = FALSE, strata = NULL,
+ parallel = getOption("mc.cores"), ...)
+}
+
+\arguments{
+
+ \item{object}{One or several result objects from \code{\link{cca}},
+ \code{\link{rda}} or \code{\link{capscale}}. If there are several
+ result objects, they are compared against each other in the ordre
+ they were supplied. For a single object, a test specified in
+ \code{by} or an overal test is given.}
+
+ \item{x}{A single ordination result object.}
+
+ \item{permutations}{Either a \code{\link[permute]{how}} result
+ defining permutations, or a permutation matrix with each row giving
+ the permutation indices, or the number of permutations for simple
+ permutations. See \code{\link{permutations}} for details.}
+
+ \item{by}{Setting \code{by = "axis"} will assess significance for
+ each constrained axis, and setting \code{by = "terms"} will assess
+ significance for each term (sequentially from first to last), and
+ setting \code{by = "margin"} will assess the marginal effects of
+ the terms (each marginal term analysed in a model with all other
+ variables)}
+
+ \item{model}{Permutation model: \code{model="direct"} permutes
+ community data, and \code{model="reduced"} permutes residuals
+ of the community data after Conditions (partial model).}
+
+ \item{parallel}{Use parallel processing with the given number of
+ cores.}
+
+ \item{strata}{An integer vector or factor specifying the strata for
+ permutation. If supplied, observations are permuted only within
+ the specified strata. It is an error to use this when
+ \code{permutations} is a matrix, or a \code{\link[permute]{how}}
+ defines \code{blocks}. This is a legacy argument that will be
+ deprecated in the future: use
+ \code{permutations = how(\dots, blocks)} instead. }
+
+ \item{cutoff}{Only effective with \code{by="axis"} where stops
+ permutations after an axis exceeds the \code{cutoff}.}
+
+ \item{scope}{Only effective with \code{by="margin"} where it can be
+ used to select the marginal terms for testing. The default is to
+ test all marginal terms in \code{\link{drop.scope}}.}
+
+ \item{\dots}{Parameters passed to other functions. \code{anova.cca}
+ passes all arguments to \code{permutest.cca}. In \code{anova} with
+ \code{by = "axis"} you can use argument \code{cutoff} (defaults
+ \code{1}) which stops permutations after exceeding the given
+ level. }
+}
+
+\details{
+
+ Functions \code{anova.cca} and \code{permutest.cca} implement
+ ANOVA like permutation tests for the joint effect of constraints in
+ \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}.
+ Functions \code{anova.cca} and \code{permutest.cca} differ in
+ printout style and in interface. Function \code{permutest.cca} is
+ the proper workhorse, but \code{anova.cca} passes all parameters to
+ \code{permutest.cca}.
+
+ Function \code{anova} can analyse a sequence of constrained
+ ordination models. The analysis is based on the differences in
+ residual deviances in permutations of nested models.
+
+ The default test is for the sum of all constrained eigenvalues.
+ Setting \code{first = TRUE} will perform a test for the first
+ constrained eigenvalue. Argument \code{first} can be set either in
+ \code{anova.cca} or in \code{permutest.cca}. It is also possible to
+ perform significance tests for each axis or for each term
+ (constraining variable) using argument \code{by} in
+ \code{anova.cca}. Setting \code{by = "axis"} will perform separate
+ significance tests for each constrained axis. All previous
+ constrained axes will be used as conditions (\dQuote{partialled
+ out}) and a test for the first constrained eigenvalues is
+ performed (Legendre et al. 2011).
+ You can stop permutation tests after exceeding a given
+ significance level with argument \code{cutoff} to speed up
+ calculations in large models. Setting \code{by = "terms"} will
+ perform separate significance test for each term (constraining
+ variable). The terms are assessed sequentially from first to last,
+ and the order of the terms will influence their
+ significances. Setting \code{by = "margin"} will perform separate
+ significance test for each marginal term in a model with all other
+ terms. The marginal test also accepts a \code{scope} argument for
+ the \code{\link{drop.scope}} which can be a character vector of term
+ labels that are analysed, or a fitted model of lower scope. The
+ marginal effects are also known as \dQuote{Type III} effects, but
+ the current function only evaluates marginal terms. It will, for
+ instance, ignore main effects that are included in interaction
+ terms. In calculating pseudo-\eqn{F}, all terms are compared to the
+ same residual of the full model.
+
+ Community data are permuted with choice \code{model="direct"},
+ and residuals after partial CCA/ RDA/ dbRDA with choice
+ \code{model="reduced"} (default). If there is no partial CCA/
+ RDA/ dbRDA stage, \code{model="reduced"} simply permutes the data
+ and is equivalent to \code{model="direct"}. The test statistic is
+ \dQuote{pseudo-\eqn{F}}, which is the ratio of constrained and
+ unconstrained total Inertia (Chi-squares, variances or something
+ similar), each divided by their respective ranks. If there are no
+ conditions (\dQuote{partial} terms), the sum of all eigenvalues
+ remains constant, so that pseudo-\eqn{F} and eigenvalues would give
+ equal results. In partial CCA/ RDA/ dbRDA, the effect of
+ conditioning variables (\dQuote{covariables}) is removed before
+ permutation, and these residuals are added to the non-permuted
+ fitted values of partial CCA (fitted values of \code{X ~ Z}).
+ Consequently, the total Chi-square is not fixed, and test based on
+ pseudo-\eqn{F} would differ from the test based on plain
+ eigenvalues. CCA is a weighted method, and environmental data are
+ re-weighted at each permutation step using permuted weights. }
+
+\value{
+ The function \code{anova.cca} calls \code{permutest.cca} and fills an
+ \code{\link{anova}} table.
+}
+
+\note{
+ Some cases of \code{anova} need access to the original data on
+ constraints (at least \code{by = "term"} and \code{by = "margin"}),
+ and they may fail if data are unavailable.
+}
+\references{
+ Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd
+ English ed. Elsevier.
+
+ Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the
+ significance of canonical axes in redundancy analysis.
+ \emph{Methods in Ecology and Evolution} 2, 269--277.
+}
+\author{Jari Oksanen}
+
+\seealso{\code{\link{anova.cca}}, \code{\link{cca}},
+ \code{\link{rda}}, \code{\link{capscale}} to get something to
+ analyse. Function \code{\link{drop1.cca}} calls \code{anova.cca}
+ with \code{by = "margin"}, and \code{\link{add1.cca}} an analysis
+ for single terms additions, which can be used in automatic or
+ semiautomatic model building (see \code{\link{deviance.cca}}). }
+
+\examples{
+data(varespec)
+data(varechem)
+vare.cca <- cca(varespec ~ Al + P + K, varechem)
+## overall test
+anova(vare.cca)
+}
+\keyword{ multivariate }
+\keyword{ htest }
Deleted: pkg/vegan/man/anovacca.Rd
===================================================================
--- pkg/vegan/man/anovacca.Rd 2013-12-03 17:03:28 UTC (rev 2799)
+++ pkg/vegan/man/anovacca.Rd 2013-12-03 17:13:16 UTC (rev 2800)
@@ -1,179 +0,0 @@
-\name{anovacca}
-\alias{anovacca}
-%\alias{anova.ccanull}
-%\alias{anova.ccabyaxis}
-%\alias{anova.ccabyterm}
-%\alias{anova.ccabymargin}
-%\alias{anova.prc}
-\alias{permutest}
-%\alias{permutest.default}
-\alias{permutest.cca}
-
-\title{Permutation Test for Constrained Correspondence Analysis,
- Redundancy Analysis and Constrained Analysis of Principal Coordinates }
-
-\description{
- The function performs an ANOVA like permutation test for Constrained
- Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis
- (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA,
- \code{\link{capscale}}) to assess the significance of constraints.
-}
-
-\usage{
-anovacca(object, ..., permutations = how(nperm=999),
- by = NULL, model = c("reduced", "direct", "full"),
- parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1, scope = NULL)
-\method{permutest}{cca}(x, permutations = how(nperm = 99),
- model = c("reduced", "direct"), first = FALSE, strata = NULL,
- parallel = getOption("mc.cores"), ...)
-}
-
-\arguments{
-
- \item{object}{One or several result objects from \code{\link{cca}},
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/vegan -r 2800
From noreply at r-forge.r-project.org Tue Dec 3 18:34:58 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 3 Dec 2013 18:34:58 +0100 (CET)
Subject: [Vegan-commits] r2801 - in pkg/vegan: . R man
Message-ID: <20131203173458.816F718477A@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-03 18:34:58 +0100 (Tue, 03 Dec 2013)
New Revision: 2801
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/add1.cca.R
pkg/vegan/R/ccanova.R
pkg/vegan/R/drop1.cca.R
pkg/vegan/R/ordiR2step.R
pkg/vegan/R/ordistep.R
pkg/vegan/man/add1.cca.Rd
pkg/vegan/man/ccanova.Rd
Log:
stage 3 of new anova.cca: start adapting functions dependent on anova.cca and fix things flagged in R CMD build
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/NAMESPACE 2013-12-03 17:34:58 UTC (rev 2801)
@@ -30,7 +30,7 @@
vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores,
wcmdscale, wisconsin)
## Export temporary function later intended to replace anova.cca()
-export(anovacca) ## <-- REMOVE THIS WHEN anova.cca IS UPGRADED <--!!!
+export(ccanova) ## <-- REMOVE THIS WHEN ccanova IS REMOVED <--!!!
## export pasteCall for 'permute'
export(pasteCall)
## export anova.cca for 'BiodiversityR': this should be fixed there
Modified: pkg/vegan/R/add1.cca.R
===================================================================
--- pkg/vegan/R/add1.cca.R 2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/R/add1.cca.R 2013-12-03 17:34:58 UTC (rev 2801)
@@ -1,6 +1,6 @@
`add1.cca`<-
function(object, scope, test = c("none", "permutation"),
- pstep = 100, perm.max = 200, ...)
+ permutations = how(nperm = 199), ...)
{
if (inherits(object, "prc"))
stop("'step'/'add1' cannot be used for 'prc' objects")
@@ -27,7 +27,7 @@
else
nfit <- update(object,
as.formula(paste(". ~ . +", tt)))
- tmp <- anova(nfit, step = pstep, perm.max = perm.max, ...)
+ tmp <- anova(nfit, permutations = permutations, ...)
adds[i+1,] <- unlist(tmp[1,3:5])
}
colnames(adds) <- colnames(tmp)[3:5]
Modified: pkg/vegan/R/ccanova.R
===================================================================
--- pkg/vegan/R/ccanova.R 2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/R/ccanova.R 2013-12-03 17:34:58 UTC (rev 2801)
@@ -1,4 +1,4 @@
-`anova.cca` <-
+`ccanova` <-
function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999,
by = NULL, ...)
{
Modified: pkg/vegan/R/drop1.cca.R
===================================================================
--- pkg/vegan/R/drop1.cca.R 2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/R/drop1.cca.R 2013-12-03 17:34:58 UTC (rev 2801)
@@ -1,6 +1,6 @@
`drop1.cca` <-
function(object, scope, test = c("none", "permutation"),
- pstep = 100, perm.max = 200, ...)
+ permutations = how(nperm = 199), ...)
{
if (inherits(object, "prc"))
stop("'step'/'drop1' cannot be used for 'prc' objects")
@@ -13,8 +13,8 @@
scope <- rn
else if (!is.character(scope))
scope <- drop.scope(scope)
- adds <- anova(object, by = "margin", step = pstep,
- perm.max = perm.max, scope = scope, ...)
+ adds <- anova(object, by = "margin", scope = scope,
+ permutations = permutations, ...)
nr <- nrow(adds)
out <- cbind(out, rbind(NA, adds[rn,3:5]))
class(out) <- cl
Modified: pkg/vegan/R/ordiR2step.R
===================================================================
--- pkg/vegan/R/ordiR2step.R 2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/R/ordiR2step.R 2013-12-03 17:34:58 UTC (rev 2801)
@@ -4,7 +4,7 @@
`ordiR2step` <-
function(object, scope, direction = c("both", "forward"),
- Pin = 0.05, R2scope = TRUE, pstep = 100, perm.max = 1000,
+ Pin = 0.05, R2scope = TRUE, permutations = how(nperm=499),
trace = TRUE, ...)
{
direction <- match.arg(direction)
@@ -78,7 +78,7 @@
if (R2scope) R2.adds[best] <= R2.all else TRUE) {
## Second criterion: added variable is significant
tst <- add1(object, scope = adds[best], test="permu",
- pstep = pstep, perm.max = perm.max,
+ permutations = permutations,
alpha = Pin, trace = FALSE, ...)
if (trace) {
print(tst[-1,])
@@ -95,7 +95,7 @@
}
}
if (NROW(anotab) > 0) {
- anotab <- rbind(anotab, " This version is adapted to the changes in permute
+package version 0.8-0 and no more triggers NOTEs in package
+checks. This release may be the last of the 2.0 series, and the
+next vegan release is scheduled to be a major release with
+newly designed The Kempton and Taylor algorithm was found unreliable in
+ vegan News
+Changes in version 2.0-10
+
+
+
+GENERAL
+
+
+
+
+
+
+
+oecosimu and community pattern simulation,
+support for parallel processing, and full support of the
+permute package. If you are interested in these
+developments, you may try the development versions of
+vegan in
+R-Forge or
+GitHub and report the
+problems and user experience to us. BUG FIXES
+
+
+
+
+
+
+
+
+envfit function assumed that all external variables
+were either numeric or factors, and failed if they were, say,
+character strings. Now only numeric variables are taken as
+continuous vectors, and all other variables (character strings,
+logical) are coerced to factors if possible. The function also
+should work with degenerate data, like only one level of a
+factor or a constant value of a continuous environmental
+variable.
+nestednodf with quantitative data was not
+consistent with binary models, and the fill was wrongly
+calculated with quantitative data.
+oecosimu now correctly adapts displayed quantiles
+of simulated values to the alternative test direction.
+renyiaccum plotting failed if only one level of
+diversity scale was used.
+NEW FEATURES
+
+
+
+
+
+
+
+
+
fisherfit and fisher.alpha, and now the estimation
+of Fisher alpha is only based on the number of
+species and the number of individuals. The estimation of
+standard errors and profile confidence intervals also had to be
+scrapped.
+renyiaccum, specaccum and
+tsallisaccum functions gained subset argument.
+renyiaccum can now add a collector curve to
+to the analysis. The collector curve is the diversity
+accumulation in the order of the sampling units. With an
+interesting ordering or sampling units this allows comparing
+actual species accumulations with the expected randomized
+accumulation.
+specaccum can now perform weighted accumulation
+using the sampling effort as weights.
+Changes in version 2.0-9
From noreply at r-forge.r-project.org Mon Dec 9 09:09:23 2013
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Mon, 9 Dec 2013 09:09:23 +0100 (CET)
Subject: [Vegan-commits] r2813 - branches/2.0 pkg/vegan
Message-ID: <20131209080924.04A0F180602@r-forge.r-project.org>
Author: jarioksa
Date: 2013-12-09 09:09:23 +0100 (Mon, 09 Dec 2013)
New Revision: 2813
Modified:
branches/2.0/DESCRIPTION
pkg/vegan/DESCRIPTION
Log:
vegan actually depends on R >= 2.15.0: paste0()
Modified: branches/2.0/DESCRIPTION
===================================================================
--- branches/2.0/DESCRIPTION 2013-12-08 15:19:45 UTC (rev 2812)
+++ branches/2.0/DESCRIPTION 2013-12-09 08:09:23 UTC (rev 2813)
@@ -1,12 +1,12 @@
Package: vegan
Title: Community Ecology Package
Version: 2.0-10
-Date: December 5, 2013
+Date: December 10, 2013
Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre,
Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos,
M. Henry H. Stevens, Helene Wagner
Maintainer: Jari Oksanen vectorfit.
nestednodf with quantitative data was not