[Vegan-commits] r1306 - in pkg/vegan: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 17 11:40:42 CEST 2010
Author: jarioksa
Date: 2010-09-17 11:40:41 +0200 (Fri, 17 Sep 2010)
New Revision: 1306
Modified:
pkg/vegan/DESCRIPTION
pkg/vegan/R/ordiR2step.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/ordistep.Rd
Log:
ordiR2step gained 'direction' argument with 'both' & 'forward'
Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION 2010-09-17 09:37:51 UTC (rev 1305)
+++ pkg/vegan/DESCRIPTION 2010-09-17 09:40:41 UTC (rev 1306)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 1.18-11
-Date: August 31, 2010
+Version: 1.18-12
+Date: September 17, 2010
Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre,
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 2010-09-17 09:37:51 UTC (rev 1305)
+++ pkg/vegan/R/ordiR2step.R 2010-09-17 09:40:41 UTC (rev 1306)
@@ -3,9 +3,11 @@
### Blanchet, Legendre & Borcard: Ecology 89, 2623--2623; 2008.
`ordiR2step` <-
- function(object, scope, Pin = 0.05, pstep = 100,
- perm.max = 1000, trace = TRUE, ...)
+ function(object, scope, direction = c("both", "forward"),
+ Pin = 0.05, pstep = 100, perm.max = 1000,
+ trace = TRUE, ...)
{
+ direction <- match.arg(direction)
if (missing(scope))
stop("needs scope")
## Works only for rda(): cca() does not have (yet) R2.adjusted
@@ -33,25 +35,34 @@
## Step forward and continue as long as R2.adj improves and R2.adj
## remains below R2.adj < R2.all
R2.previous <- R2.0
+ drops <- NULL
repeat {
if (trace) {
cat("Step: R2.adj=", R2.previous, "\n")
cat(pasteCall(formula(object)), "\n")
}
adds <- add.scope(object, scope)
- ## Nothing to add, and we're done: break
- if (length(adds) == 0)
+ if (direction == "both")
+ drops <- drop.scope(object)
+ ## Nothing to add or drop, and we're done: break
+ if (length(adds) == 0 && length(drops) == 0)
break
- R2.adds <- numeric(length(adds))
- names(R2.adds) <- adds
+ R2.adds <- numeric(length(adds) + length(drops))
+ if (length(adds))
+ adds <- paste("+", adds)
+ if (length(drops))
+ drops <- paste("-", drops)
+ names(R2.adds) <- c(adds, drops)
## Loop over add scope
- for (trm in seq_along(adds)) {
- fla <- paste("~ . + ", adds[trm])
- R2.adds[trm] <- RsquareAdj(update(object, fla))$adj.r.squared
+ for (trm in seq_along(R2.adds)) {
+ fla <- paste(". ~ .", names(R2.adds[trm]))
+ R2.tmp <- RsquareAdj(update(object, fla))$adj.r.squared
+ if (!length(R2.tmp))
+ R2.tmp <- 0
+ R2.adds[trm] <- R2.tmp
}
best <- which.max(R2.adds)
if (trace) {
- names(R2.adds) <- paste("+", names(R2.adds))
out <- sort(c("<All variables>" = R2.all, "<none>" = R2.previous,
R2.adds), decreasing = TRUE)
out <- as.matrix(out)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2010-09-17 09:37:51 UTC (rev 1305)
+++ pkg/vegan/inst/ChangeLog 2010-09-17 09:40:41 UTC (rev 1306)
@@ -2,8 +2,14 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 1.18-11 (opened August 31, 2010)
+Version 1.18-12 (opened September 17, 2010)
+ * ordiR2step: gained argument 'direction = c("both", "response")',
+ and iwth "both" gives also adjusted R2 when dropping terms. I have
+ not yet seen a case where a terms is dropped.
+
+Version 1.18-11 (closed September 17, 2010)
+
* diversity: example says that rarefy(x, 2) - 1 is the same as
unbiased Simpson of a true random sample of Hurlbert (1971,
eq. 5). Added after several wishes to have this function.
Modified: pkg/vegan/man/ordistep.Rd
===================================================================
--- pkg/vegan/man/ordistep.Rd 2010-09-17 09:37:51 UTC (rev 1305)
+++ pkg/vegan/man/ordistep.Rd 2010-09-17 09:40:41 UTC (rev 1306)
@@ -18,7 +18,8 @@
ordistep(object, scope, direction = c("both", "backward", "forward"),
Pin = 0.05, Pout = 0.1, pstep = 100, perm.max = 1000, steps = 50,
trace = TRUE, ...)
-ordiR2step(object, scope, Pin = 0.05, pstep = 100, perm.max = 1000,
+ordiR2step(object, scope, direction = c("both", "forward"),
+ Pin = 0.05, pstep = 100, perm.max = 1000,
trace = TRUE, ...)
}
%- maybe also 'usage' for other objects documented here.
@@ -85,14 +86,17 @@
is often sensible to have \code{Pout} \eqn{>} \code{Pin} in stepwise
models to avoid cyclic adds and drops of single terms.
- Function \code{ordiR2step} implements the forward selection to
- maximize adjusted \eqn{R^2}{R2} (function \code{\link{RsquareAdj}}) at
- every step, and 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). 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}}.
+ Function \code{ordiR2step} builds model so that it maximizes adjusted
+ \eqn{R^2}{R2} (function \code{\link{RsquareAdj}}) at every step, and
+ 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}}.
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