[Vegan-commits] r2694 - in pkg/vegan: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 10 15:20:43 CET 2013
Author: jarioksa
Date: 2013-11-10 15:20:42 +0100 (Sun, 10 Nov 2013)
New Revision: 2694
Added:
pkg/vegan/R/anovacca.R
pkg/vegan/man/anovacca.Rd
Modified:
pkg/vegan/DESCRIPTION
pkg/vegan/NAMESPACE
pkg/vegan/inst/ChangeLog
Log:
start migration to permute-based anova.cca: add working function anovacca to replace anova.cca
Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION 2013-11-09 04:08:25 UTC (rev 2693)
+++ pkg/vegan/DESCRIPTION 2013-11-10 14:20:42 UTC (rev 2694)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 2.1-38
-Date: November 5, 2013
+Version: 2.1-39
+Date: November 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
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2013-11-09 04:08:25 UTC (rev 2693)
+++ pkg/vegan/NAMESPACE 2013-11-10 14:20:42 UTC (rev 2694)
@@ -29,7 +29,8 @@
treedist, treedive, treeheight, tsallisaccum, tsallis, varpart,
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 pasteCall for 'permute'
export(pasteCall)
## export anova.cca for 'BiodiversityR': this should be fixed there
Added: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R (rev 0)
+++ pkg/vegan/R/anovacca.R 2013-11-10 14:20:42 UTC (rev 2694)
@@ -0,0 +1,31 @@
+`anovacca` <-
+ function(object, ..., permutations = how(nperm=999), by = NULL)
+{
+ if (is.null(object$CA) || is.null(object$CCA) ||
+ object$CCA$rank == 0 || object$CA$rank == 0)
+ return(anova.ccanull(object))
+ if (!is.null(by)) {
+ by <- match.arg(by, c("axis", "terms", "margin"))
+ .NotYetUsed("by")
+ }
+ seed <- NULL
+ tst <- permutest.cca(object, permutations = permutations, ...)
+ if (is.null(seed))
+ seed <- tst$Random.seed
+ 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)
+ 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"))
+}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-11-09 04:08:25 UTC (rev 2693)
+++ pkg/vegan/inst/ChangeLog 2013-11-10 14:20:42 UTC (rev 2694)
@@ -2,8 +2,19 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 2.1-38 (opened November 5, 2013)
+Version 2.1-39 (opened November 10, 2013)
+ * anova.cca: started to rewrite the anova.cca family of functions
+ for permute package. At the first stage, a temporary development
+ function anovacca was created. The user interface was changed, and
+ the function no more adapts the number of iterations for the
+ P-value, and arguments 'step' and 'perm.max' were removed.
+ Instead, permute package is used to create a permutation matrix
+ used in all cases with fixed number of permutations. At the first
+ stage, only the overall test is provided.
+
+Version 2.1-38 (closed November 10, 2013)
+
* DESCRIPTION: depends on permute >= 0.7-5, where the
permute::how() result object can be updated.
Added: pkg/vegan/man/anovacca.Rd
===================================================================
--- pkg/vegan/man/anovacca.Rd (rev 0)
+++ pkg/vegan/man/anovacca.Rd 2013-11-10 14:20:42 UTC (rev 2694)
@@ -0,0 +1,157 @@
+\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.
+
+ 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)
+}
+
+\arguments{
+
+ \item{object}{A result object from \code{\link{cca}},
+ \code{\link{rda}} or \code{\link{capscale}}. }
+
+ \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). Not yet implemented.}
+
+ \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 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.
+
+ 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{
+ The function \code{anovacca} 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"}.
+}
+\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
+anovacca(vare.cca)
+}
+\keyword{ multivariate }
+\keyword{ htest }
More information about the Vegan-commits
mailing list