[Vegan-commits] r2800 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 3 18:13:16 CET 2013
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
More information about the Vegan-commits
mailing list