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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 19 16:23:07 CET 2012


Author: jarioksa
Date: 2012-11-19 16:23:07 +0100 (Mon, 19 Nov 2012)
New Revision: 2330

Modified:
   pkg/vegan/DESCRIPTION
   pkg/vegan/R/ordiR2step.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordistep.Rd
Log:
ordiR2step gained arg 'R2scope' to turn off testing against adj-R2 of the scope

Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION	2012-10-15 15:53:34 UTC (rev 2329)
+++ pkg/vegan/DESCRIPTION	2012-11-19 15:23:07 UTC (rev 2330)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 2.1-21
-Date: October 8, 2012
+Version: 2.1-22
+Date: November 19, 2012
 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/R/ordiR2step.R
===================================================================
--- pkg/vegan/R/ordiR2step.R	2012-10-15 15:53:34 UTC (rev 2329)
+++ pkg/vegan/R/ordiR2step.R	2012-11-19 15:23:07 UTC (rev 2330)
@@ -4,7 +4,7 @@
 
 `ordiR2step` <-
     function(object, scope, direction = c("both", "forward"),
-             Pin = 0.05, pstep = 100, perm.max = 1000,
+             Pin = 0.05, R2scope = TRUE, pstep = 100, perm.max = 1000,
              trace = TRUE, ...)
 {
     direction <- match.arg(direction)
@@ -23,9 +23,12 @@
         scope <- delete.response(formula(scope))
     if (!inherits(scope, "formula"))
         scope <- reformulate(scope)
-    R2.all <- RsquareAdj(update(object, scope))
+    if (R2scope)
+        R2.all <- RsquareAdj(update(object, scope))
+    else
+        R2.all <- list(adj.r.squared = NA)
     ## Check that the full model can be evaluated
-    if (is.na(R2.all$adj.r.squared)) {
+    if (is.na(R2.all$adj.r.squared) && R2scope) {
         if (R2.all$r.squared > 0.999)
             stop("the upper scope cannot be fitted (too many terms?)")
         else
@@ -75,7 +78,8 @@
         ## See if the best should be kept
         ## First criterion: R2.adj improves and is still lower or
         ## equal than for the full model of the scope
-        if (R2.adds[best] > R2.previous && R2.adds[best] <= R2.all) {
+        if (R2.adds[best] > R2.previous &&
+            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,

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-10-15 15:53:34 UTC (rev 2329)
+++ pkg/vegan/inst/ChangeLog	2012-11-19 15:23:07 UTC (rev 2330)
@@ -2,8 +2,22 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 2.1-21 (opened October 8, 2012)
+Version 2.1-22 (opened November 19, 2012)
 
+	* ordiR2step: gained argument 'R2scope' (default TRUE) which can
+	be used to turn off the criterion of stopping when the adj-R2 of
+	the current model exceeds that of scope.  This option allows model
+	building when the 'scope' would be overdetermined (number of
+	predictors higher than number of observations). Pierre Legendre
+	needed this option for some checks with huge AEM/PCNM scopes.
+
+	It should be checked how the function works with partial RDA: we
+	have introduces RsquareAdj() for partial RDA, but the current
+	testing still assumes that those models do not have adj-R2 (like
+	was the case when ordiR2step() was written).
+
+Version 2.1-21 (closed November 19, 2012)
+
 	* New version opened with the CRAN release of vegan 2.0-5 on Oct
 	8, 2012.
 

Modified: pkg/vegan/man/ordistep.Rd
===================================================================
--- pkg/vegan/man/ordistep.Rd	2012-10-15 15:53:34 UTC (rev 2329)
+++ pkg/vegan/man/ordistep.Rd	2012-11-19 15:23:07 UTC (rev 2330)
@@ -19,7 +19,7 @@
    Pin = 0.05, Pout = 0.1, pstep = 100, perm.max = 1000, steps = 50,
    trace = TRUE, ...)
 ordiR2step(object, scope, direction = c("both", "forward"),
-   Pin = 0.05, pstep = 100, perm.max = 1000,
+   Pin = 0.05, R2scope = TRUE, pstep = 100, perm.max = 1000,
    trace = TRUE, ...)
 }
 %- maybe also 'usage' for other objects documented here.
@@ -45,6 +45,12 @@
   the model, or dropping (\code{Pout}) from the model. Term is added if
   \eqn{P \le}{P <=} \code{Pin}, and removed if \eqn{P >} \code{Pout}. 
 }
+
+  \item{R2scope}{
+  Use adjusted \eqn{R^2}{R2} as the stopping criterion: only models with
+  lower adjusted \eqn{R^2}{R2} than scope are accepted.
+  }
+
   \item{pstep}{
   Number of permutations in one step. See \code{\link{add1.cca}}.
 }
@@ -90,12 +96,16 @@
   stopping when the adjusted \eqn{R^2}{R2} starts to decrease, or the
   adjusted \eqn{R^2}{R2} of the \code{scope} is exceeded, or the
   selected permutation \eqn{P}-value is exceeded (Blanchet et
-  al. 2008). The \code{direction} has choices \code{"forward"} and
-  \code{"both"}, but it is very excepctional that a term is dropped with
-  the adjusted \eqn{R^2}{R2} criterion.  Function uses adjusted
-  \eqn{R^2}{R2} as the criterion, and it cannot be used if the criterion
-  cannot be calculated.  Therefore it is unavailable for
-  \code{\link{cca}}.
+  al. 2008). The second criterion is ignored with option
+  \code{R2step = FALSE}, and the third criterion can be ignored setting
+  \code{Pin = 1} (or higher).  The \code{direction} has choices
+  \code{"forward"} and \code{"both"}, but it is very excepctional that a
+  term is dropped with the adjusted \eqn{R^2}{R2} criterion.  Function
+  uses adjusted \eqn{R^2}{R2} as the criterion, and it cannot be used if
+  the criterion cannot be calculated.  Therefore it is unavailable for
+  \code{\link{cca}}.  Adjusted \eqn{R^2}{R2} cannot be calculated if the
+  number of predictors is higher than the number of observations, but
+  such models can be analysed with \code{R2scope = FALSE}.
 
   Functions \code{ordistep} (based on \eqn{P} values) and \code{ordiR2step}
   (based on adjusted \eqn{R^2}{R2} and hence on eigenvalues) can select



More information about the Vegan-commits mailing list