[Vegan-commits] r2801 - in pkg/vegan: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 3 18:34:58 CET 2013


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, "<All variables>" = c(R2.all, rep(NA, 5)))
+        anotab <- rbind(anotab, "<All variables>" = c(R2.all, rep(NA, 4)))
         class(anotab) <- c("anova", class(anotab))
         object$anova <- anotab
     }

Modified: pkg/vegan/R/ordistep.R
===================================================================
--- pkg/vegan/R/ordistep.R	2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/R/ordistep.R	2013-12-03 17:34:58 UTC (rev 2801)
@@ -1,6 +1,6 @@
 `ordistep` <-
     function(object, scope, direction =c("both", "backward", "forward"),
-             Pin = 0.05, Pout = 0.1, pstep = 100, perm.max = 1000,
+             Pin = 0.05, Pout = 0.1, permutations = how(nperm = 199),
              steps=50, trace = TRUE, ...)
 {
     if (!inherits(object, "cca"))
@@ -43,17 +43,18 @@
         change <- NULL
         ## Consider dropping
         if (backward && length(scope$drop)) {
-            aod <- drop1(object, scope = scope$drop, test="perm", pstep = pstep,
-                         perm.max = perm.max, alpha = Pout, trace = trace, ...)
+            aod <- drop1(object, scope = scope$drop, test="perm",
+                         permutations = permutations,
+                         alpha = Pout, trace = trace, ...)
             aod <- aod[-1,]
-            o <- order(-aod[,5], aod[,4], aod[,2])
+            o <- order(-aod[,4], aod[,2])
             aod <- aod[o,]
             rownames(aod) <- paste("-", rownames(aod), sep = " ")
             if (trace) {
                 cat("\n")
                 print(aod)
             }
-            if (is.na(aod[1,5]) || aod[1,5] > Pout) {
+            if (is.na(aod[1,4]) || aod[1,4] > Pout) {
                 anotab <- rbind(anotab, aod[1,])
                 change <- rownames(aod)[1]
                 object <- eval.parent(update(object, paste("~  .", change)))
@@ -70,14 +71,14 @@
             aod <- add1(object, scope = scope$add, test = "perm", pstep = pstep,
                         perm.max = perm.max, alpha = Pin, trace = trace, ...)
             aod <- aod[-1,]
-            o <- order(aod[,5], aod[,4], aod[,2])
+            o <- order(aod[,4], aod[,2])
             aod <- aod[o,]
             rownames(aod) <- paste("+", rownames(aod), sep = " ")
             if (trace) {
                 cat("\n")
                 print(aod)
             }
-            if (!is.na(aod[1,5]) && aod[1,5] <= Pin) {
+            if (!is.na(aod[1,4]) && aod[1,4] <= Pin) {
                 anotab <- rbind(anotab, aod[1,])
                 change <- rownames(aod)[1]
                 object <- eval.parent(update(object, paste( "~  .",change)))

Modified: pkg/vegan/man/add1.cca.Rd
===================================================================
--- pkg/vegan/man/add1.cca.Rd	2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/man/add1.cca.Rd	2013-12-03 17:34:58 UTC (rev 2801)
@@ -9,9 +9,9 @@
 }
 \usage{
 \method{add1}{cca}(object, scope, test = c("none", "permutation"),
-    pstep = 100, perm.max = 200, ...)
+    permutations = how(nperm=199), ...)
 \method{drop1}{cca}(object, scope, test = c("none", "permutation"), 
-    pstep = 100, perm.max = 200, ...)
+    permutations = how(nperm=199), ...)
 }
 
 \arguments{
@@ -20,9 +20,12 @@
   \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 be added using \code{\link{anova.cca}}. }
-  \item{pstep}{Number of permutations in one step, passed as argument
-  \code{step} to \code{\link{anova.cca}}.}
-  \item{perm.max}{ Maximum number of permutation in \code{\link{anova.cca}}. }
+ 
+ \item{permutations}{Permutation scheme as defined in
+   \code{\link[permute]{ho}}; the default defines a simple
+   permutations (and could also be expressed as a single number). Any
+   structure accepted by \code{\link{anova.cca}} acn be used.}
+
   \item{\dots}{Other arguments passed to \code{\link{add1.default}},
   \code{\link{drop1.default}}, and \code{\link{anova.cca}}.}
 }

Modified: pkg/vegan/man/ccanova.Rd
===================================================================
--- pkg/vegan/man/ccanova.Rd	2013-12-03 17:13:16 UTC (rev 2800)
+++ pkg/vegan/man/ccanova.Rd	2013-12-03 17:34:58 UTC (rev 2801)
@@ -33,7 +33,7 @@
 \details{
   
   Function \code{ccanova} is a deprecated version of \code{anova.cca}.
-  The new \code{link{\anova.cca}} function is completely
+  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



More information about the Vegan-commits mailing list