[Vegan-commits] r494 - in pkg: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 10 21:54:23 CEST 2008


Author: jarioksa
Date: 2008-09-10 21:54:23 +0200 (Wed, 10 Sep 2008)
New Revision: 494

Added:
   pkg/R/add1.cca.R
   pkg/R/drop1.cca.R
   pkg/man/add1.cca.Rd
Modified:
   pkg/DESCRIPTION
   pkg/inst/ChangeLog
   pkg/man/anova.cca.Rd
   pkg/man/deviance.cca.Rd
Log:
add1.cca & drop1.cca: new functions that optionally implement permutation tests, and close the hole of getting parametric LRT

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-09-05 12:24:41 UTC (rev 493)
+++ pkg/DESCRIPTION	2008-09-10 19:54:23 UTC (rev 494)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.14-11
-Date: September 5, 2008
+Version: 1.14-12
+Date: September 10, 2008
 Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson, 
    Peter Solymos, M. Henry H. Stevens, Helene Wagner  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>

Added: pkg/R/add1.cca.R
===================================================================
--- pkg/R/add1.cca.R	                        (rev 0)
+++ pkg/R/add1.cca.R	2008-09-10 19:54:23 UTC (rev 494)
@@ -0,0 +1,32 @@
+`add1.cca`<-
+    function(object, scope, test = c("none", "permutation"),
+             perm.max = 200, ...)
+{
+    test <- match.arg(test)
+    ## Default add1
+    out <- NextMethod("add1", object, test = "none", ...)
+    cl <- class(out)
+    ## Loop over terms in 'scope' and do anova.cca
+    if (test == "permutation") {
+        if (!is.character(scope)) 
+            scope <- add.scope(object, update.formula(object, scope))
+        ns <- length(scope)
+        adds <- matrix(0, ns+1, 3)
+        adds[1, ] <- NA
+        for (i in 1:ns) {
+            tt <- scope[i]
+            if (!is.null(object$CCA))
+                nfit <- update(object,
+                               as.formula(paste(". ~  Condition(.) + ", tt)))
+            else
+                nfit <- update(object,
+                               as.formula(paste(". ~ . +", tt)))
+            tmp <- anova(nfit, perm.max = perm.max, ...)
+            adds[i+1,] <- unlist(tmp[1,3:5])
+        }
+        colnames(adds) <- colnames(tmp)[3:5]
+        out <- cbind(out, adds)
+        class(out) <- cl
+    }
+    out
+}

Added: pkg/R/drop1.cca.R
===================================================================
--- pkg/R/drop1.cca.R	                        (rev 0)
+++ pkg/R/drop1.cca.R	2008-09-10 19:54:23 UTC (rev 494)
@@ -0,0 +1,15 @@
+`drop1.cca` <-
+    function(object, scope, test = c("none", "permutation"),
+             perm.max = 200, ...)
+{
+    test <- match.arg(test)
+    out <- NextMethod("drop1", object, test="none", ...)
+    cl <- class(out)
+    if (test == "permutation") {
+        adds <- anova(object, by = "margin", perm.max = perm.max, ...)
+        nr <- nrow(adds)
+        out <- cbind(out, rbind(NA, adds[-nr,3:5]))
+        class(out) <- cl
+    }
+    out
+}

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-09-05 12:24:41 UTC (rev 493)
+++ pkg/inst/ChangeLog	2008-09-10 19:54:23 UTC (rev 494)
@@ -3,8 +3,19 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 1.14-11 (opened September 5, 2008)
+Version 1.14-12 (opened September 10, 2008)
 
+	* add1.cca, drop1.cca: new functions that also implement
+	permutation tests with argument test = "permutation", but only use
+	default methods with test = "none". Function drop1.cca uses
+	anova.cca(..., by = "margin"), and add1.cca implements a new type of
+	analysis for single term additions. The immediate reason for
+	implementing these tests was that I found out that step(..., test
+	= "Chisq") worked(!) producing parametric likelihood ratio tests,
+	and this hole had to be closed before users notice this.
+	
+Version 1.14-11 (closed September 10, 2008)
+
 	* anova.cca/permutest.cca: default permutation model changed from
 	"direct" to "reduced" after Pierre Legendre's simulation test
 	demonstrated slightly better Type I error for "reduced" models in

Added: pkg/man/add1.cca.Rd
===================================================================
--- pkg/man/add1.cca.Rd	                        (rev 0)
+++ pkg/man/add1.cca.Rd	2008-09-10 19:54:23 UTC (rev 494)
@@ -0,0 +1,70 @@
+\name{add1.cca}
+\alias{add1.cca}
+\alias{drop1.cca}
+
+\title{Add or Drop  Single Terms to a Constrained Ordination Model }
+\description{
+Compute all single terms that can be added or dropped from a
+constrained ordination model.
+}
+\usage{
+\method{add1}{cca}(object, scope, test = c("none", "permutation"),
+    perm.max = 200, ...)
+\method{drop1}{cca}(object, scope, test = c("none", "permutation"), 
+    perm.max = 200, ...)
+}
+
+\arguments{
+  \item{object}{ A constrained ordination object from
+  \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}. }
+  \item{scope}{ A formula giving the terms to be considered for adding
+  or dropping; see \code{\link{add1}} for details.}
+  \item{test}{ Should a permutation test added using \code{\link{anova.cca}}. }
+  \item{perm.max}{ Maximum number of permutation in \code{\link{anova.cca}}. }
+  \item{\dots}{Other arguments passed to \code{\link{add1.default}},
+  \code{\link{drop1.default}}, and \code{\link{anova.cca}}.}
+}
+
+\details{ 
+  With argument \code{test = "none"} the functions will only call
+  \code{\link{add1.default}} or \code{\link{drop1.default}}. With
+  argument \code{test = "permutation"} the functions will add test
+  results from \code{\link{anova.cca}}. Function \code{drop1.cca} will
+  call \code{\link{anova.cca}} with argument \code{by = "margin"}.
+  Function \code{add1.cca} will implement a test for single term
+  additions that is not directly available in \code{\link{anova.cca}}.
+
+  Functions are used implicity in \code{\link{step}}. The
+  \code{\link{deviance.cca}} and \code{\link{deviance.rda}} used in
+  \code{\link{step}} have no firm basis, and setting argument
+  \code{test = "permutation"} may help in getting useful insight into
+  validity of model building. Meticulous use of \code{add1.cca} and
+  \code{drop1.cca} will allow more judicious model building.
+
+  The default \code{perm.max} is set to a low value, because
+  permutation tests can take a long time. It should be sufficient to
+  give a impression on the significances of the terms, but higher
+  values of \code{perm.max} should be used if \eqn{P} values really
+  are important.  
+}
+
+\value{
+  Returns a similar object as \code{\link{add1}} and \code{\link{drop1}}.
+}
+
+\author{Jari Oksanen}
+
+\seealso{ \code{\link{add1}}, \code{\link{drop1}} and
+  \code{\link{anova.cca}} for basic methods. You probably need these
+  functions with \code{\link{step}}. Functions
+  \code{\link{deviance.cca}} and \code{\link{extractAIC.cca}} are used
+  to produce the other arguments than test results in the
+  output. Functions \code{\link{cca}}, \code{\link{rda}} and
+  \code{\link{capscale}} produce result objects for these functions.}
+\examples{
+data(varespec)
+data(varechem)
+step(rda(varespec ~  1, varechem), reformulate(names(varechem)), test="perm")
+}
+\keyword{multivariate }
+\keyword{ models}

Modified: pkg/man/anova.cca.Rd
===================================================================
--- pkg/man/anova.cca.Rd	2008-09-05 12:24:41 UTC (rev 493)
+++ pkg/man/anova.cca.Rd	2008-09-10 19:54:23 UTC (rev 494)
@@ -134,7 +134,12 @@
   ed. Elsevier.
 }
 \author{Jari  Oksanen}
-\seealso{\code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}}. }
+\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}}. }
 
 \examples{
 data(varespec)

Modified: pkg/man/deviance.cca.Rd
===================================================================
--- pkg/man/deviance.cca.Rd	2008-09-05 12:24:41 UTC (rev 493)
+++ pkg/man/deviance.cca.Rd	2008-09-10 19:54:23 UTC (rev 494)
@@ -58,7 +58,11 @@
   variables with the highest eigenvalues are not necessarily the most
   significant in permutation tests in \code{\link{anova.cca}}). If you
   also have multi-class factors, the value of \code{k} will have a
-  capricious effect in model building.
+  capricious effect in model building. The \code{\link{step}} function
+  will pass arguments to \code{\link{add1.cca}} and
+  \code{\link{drop1.cca}}, and setting \code{test = "permutation"}
+  will provide permutation tests of each deletion and addition which
+  can help in judging the validity of the model building.
  
 }
 \value{
@@ -80,7 +84,8 @@
 }
 
 \seealso{\code{\link{cca}}, \code{\link{rda}}, \code{\link{anova.cca}},
-    \code{\link{step}}, \code{\link{extractAIC}}.}
+    \code{\link{step}}, \code{\link{extractAIC}},
+    \code{\link{add1.cca}}, \code{\link{drop1.cca}}. }
 \examples{
 # The deviance of correspondence analysis equals Chi-square
 data(dune)



More information about the Vegan-commits mailing list