[Vegan-commits] r2333 - in branches/2.0: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Dec 2 16:28:44 CET 2012
Author: jarioksa
Date: 2012-12-02 16:28:43 +0100 (Sun, 02 Dec 2012)
New Revision: 2333
Modified:
branches/2.0/R/msoplot.R
branches/2.0/R/ordiR2step.R
branches/2.0/inst/ChangeLog
branches/2.0/man/mso.Rd
branches/2.0/man/ordistep.Rd
Log:
merge 2329-31: msoplot() gained 'legend' and ordiR2step() gained 'R2scope'
Modified: branches/2.0/R/msoplot.R
===================================================================
--- branches/2.0/R/msoplot.R 2012-11-30 09:17:54 UTC (rev 2332)
+++ branches/2.0/R/msoplot.R 2012-12-02 15:28:43 UTC (rev 2333)
@@ -1,5 +1,6 @@
`msoplot` <-
- function (x, alpha = 0.05, explained = FALSE, ylim = NULL, ...)
+ function (x, alpha = 0.05, explained = FALSE, ylim = NULL,
+ legend = "topleft", ...)
{
object.cca <- x
if (is.data.frame(object.cca$vario)) {
@@ -34,7 +35,8 @@
lines(vario$Dist, vario$Sum, type = "b", lty = 2,
pch = 3, ...)
## Legend
- legend("topleft", c(label[c(2,3:b)+3], ci.lab, sign.lab),
+ legend(legend,
+ legend=c(label[c(2,3:b)+3], ci.lab, sign.lab),
lty=c(c(1,2,1,1,1)[2:b], 1, if(hasSig) NA),
pch=c(3, (6:(b+3))-6, NA, if(hasSig) 15)
)
@@ -54,8 +56,8 @@
text(x = c(vario$Dist), y = par("usr")[3], pos = 3,
label = c(vario$n), cex = 0.8)
abline(v = max(object$H)/2, lty = 3, ...)
- legend("topleft",
- c("Total variance","Global variance estimate",
+ legend(legend,
+ legend=c("Total variance","Global variance estimate",
if(hasSig) "Sign. autocorrelation"),
lty=c(1,5, if(hasSig) NA),
pch = if(hasSig) c(NA,NA,15) else NULL)
Modified: branches/2.0/R/ordiR2step.R
===================================================================
--- branches/2.0/R/ordiR2step.R 2012-11-30 09:17:54 UTC (rev 2332)
+++ branches/2.0/R/ordiR2step.R 2012-12-02 15:28:43 UTC (rev 2333)
@@ -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,14 +23,13 @@
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 (R2.all$r.squared > 0.999)
- stop("the upper scope cannot be fitted (too many terms?)")
- else
- stop("upper scope cannot be fitted (Condition() in scope?)")
- }
+ if (is.na(R2.all$adj.r.squared) && R2scope)
+ stop("the upper scope cannot be fitted (too many terms?)")
R2.all <- R2.all$adj.r.squared
## Collect data to anotab returned as the 'anova' object
anotab <- list()
@@ -75,7 +74,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: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog 2012-11-30 09:17:54 UTC (rev 2332)
+++ branches/2.0/inst/ChangeLog 2012-12-02 15:28:43 UTC (rev 2333)
@@ -4,6 +4,9 @@
Version 2.0-6 (opened October 8, 2012)
+ * merge 2330,1: ordiR2step() gained arg 'R2scope' and handles
+ partial RDA.
+ * merge 2328,9: add 'legend' arg to msoplot().
* merge 2325: fix rotation of axes in 2-d plot.procrustes().
* merge 2319, 2323: clamtest bug fixes and clarifications.
* merge 2318: dispindmorista gains p-values of output.
Modified: branches/2.0/man/mso.Rd
===================================================================
--- branches/2.0/man/mso.Rd 2012-11-30 09:17:54 UTC (rev 2332)
+++ branches/2.0/man/mso.Rd 2012-12-02 15:28:43 UTC (rev 2333)
@@ -14,7 +14,7 @@
\usage{
mso(object.cca, object.xy, grain = 1, round.up = FALSE, permutations = FALSE)
-msoplot(x, alpha = 0.05, explained = FALSE, ylim = NULL, ...)
+msoplot(x, alpha = 0.05, explained = FALSE, ylim = NULL, legend = "topleft", ...)
}
\arguments{
\item{object.cca}{ An object of class cca, created by the \code{\link{cca}} or
@@ -40,6 +40,9 @@
\item{explained}{ If false, suppresses the plotting of the variogram
of explained variance.}
\item{ylim}{Limits for y-axis.}
+ \item{legend}{The x and y co-ordinates to be used to position the legend.
+ They can be specified by keyword or in any way which is accepted
+ by \code{\link{legend}}.}
\item{\dots}{Other arguments passed to functions.}
}
\details{
Modified: branches/2.0/man/ordistep.Rd
===================================================================
--- branches/2.0/man/ordistep.Rd 2012-11-30 09:17:54 UTC (rev 2332)
+++ branches/2.0/man/ordistep.Rd 2012-12-02 15:28:43 UTC (rev 2333)
@@ -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