[Vegan-commits] r2962 - in pkg/vegan: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 17 12:03:56 CEST 2015
Author: jarioksa
Date: 2015-09-17 12:03:56 +0200 (Thu, 17 Sep 2015)
New Revision: 2962
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/anova.cca.R
pkg/vegan/R/anova.ccabyterm.R
pkg/vegan/R/anova.ccalist.R
pkg/vegan/R/permustats.R
pkg/vegan/inst/NEWS.Rd
pkg/vegan/man/anova.cca.Rd
pkg/vegan/man/permustats.Rd
Log:
Merge branch 'cran-2.3' into r-forge-svn-local
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/NAMESPACE 2015-09-17 10:03:56 UTC (rev 2962)
@@ -254,6 +254,7 @@
S3method(permustats, permutest.betadisper)
S3method(permustats, permutest.cca)
S3method(permustats, protest)
+S3method(permustats, anova.cca)
## these return an error: no permutation data
S3method(permustats, CCorA)
S3method(permustats, envfit)
Modified: pkg/vegan/R/anova.cca.R
===================================================================
--- pkg/vegan/R/anova.cca.R 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/R/anova.cca.R 2015-09-17 10:03:56 UTC (rev 2962)
@@ -74,6 +74,6 @@
tst$model, " model\n", howHead(control))
mod <- paste("Model:", c(object$call))
structure(table, heading = c(head, mod), Random.seed = seed,
- control = control,
+ control = control, F.perm = tst$F.perm,
class = c("anova.cca", "anova", "data.frame"))
}
Modified: pkg/vegan/R/anova.ccabyterm.R
===================================================================
--- pkg/vegan/R/anova.ccabyterm.R 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/R/anova.ccabyterm.R 2015-09-17 10:03:56 UTC (rev 2962)
@@ -17,9 +17,9 @@
trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo),
"term.labels")]
ntrm <- length(trmlab)
- m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-")))
+ m0 <- update(object, paste(".~.-", paste(trmlab, collapse = "-")))
mods <- list(m0)
- for(i in seq_along(trmlab)) {
+ for (i in seq_along(trmlab)) {
fla <- paste(". ~ . + ", trmlab[i])
mods[[i+1]] <- update(mods[[i]], fla)
}
@@ -46,7 +46,8 @@
howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova","data.frame")
+ attr(out, "F.perm") <- attr(sol, "F.perm")
+ class(out) <- c("anova.cca", "anova","data.frame")
out
}
@@ -68,7 +69,7 @@
trms <- drop.scope(object)
trmlab <- trms[trms %in% attr(terms(object$terminfo),
"term.labels")]
- if(length(trmlab) == 0)
+ if (length(trmlab) == 0)
stop("the scope was empty: no available marginal terms")
## baseline: all terms
big <- permutest(object, permutations, ...)
@@ -91,7 +92,7 @@
Fval <- sapply(mods, function(x) x$num)
## Had we an empty model we need to clone the denominator
if (length(Fval) == 1)
- Fval <- matrix(Fval, nrow=nperm)
+ Fval <- matrix(Fval, nrow = nperm)
Fval <- sweep(-Fval, 1, big$num, "+")
Fval <- sweep(Fval, 2, Df, "/")
Fval <- sweep(Fval, 1, scale, "/")
@@ -115,7 +116,8 @@
howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova", "data.frame")
+ attr(out, "F.perm") <- Fval
+ class(out) <- c("anova.cca", "anova", "data.frame")
out
}
@@ -136,10 +138,10 @@
## missing values?
if (!is.null(object$na.action))
LC <- napredict(structure(object$na.action,
- class="exclude"), LC)
+ class = "exclude"), LC)
## subset?
if (!is.null(object$subset)) {
- tmp <- matrix(NA, nrow=length(object$subset),
+ tmp <- matrix(NA, nrow = length(object$subset),
ncol = ncol(LC))
tmp[object$subset,] <- LC
LC <- tmp
@@ -148,6 +150,7 @@
LC <- as.data.frame(LC)
fla <- reformulate(names(LC))
Pvals <- rep(NA, length(eig))
+ F.perm <- matrix(ncol = length(eig), nrow = nperm)
environment(object$terms) <- environment()
for (i in seq_along(eig)) {
part <- paste("~ . +Condition(",
@@ -162,7 +165,8 @@
permutest(update(object, upfla, data = LC),
permutations, model = model,
parallel = parallel)
- Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1)
+ Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1) / (nperm + 1)
+ F.perm[ , i] <- mod$F.perm
if (Pvals[i] > cutoff)
break
}
@@ -183,6 +187,7 @@
howHead(attr(permutations, "control")))
mod <- paste("Model:", c(object$call))
attr(out, "heading") <- c(head, mod)
- class(out) <- c("anova", "data.frame")
+ attr(out, "F.perm") <- F.perm
+ class(out) <- c("anova.cca", "anova", "data.frame")
out
}
Modified: pkg/vegan/R/anova.ccalist.R
===================================================================
--- pkg/vegan/R/anova.ccalist.R 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/R/anova.ccalist.R 2015-09-17 10:03:56 UTC (rev 2962)
@@ -27,8 +27,8 @@
## 4. Terms must be nested
trms <- lapply(object, function(z) labels(terms(z)))
o <- order(sapply(trms, length))
- for(i in 2:nmodels)
- if(!all(trms[[o[i-1]]] %in% trms[[o[i]]]))
+ for (i in 2:nmodels)
+ if (!all(trms[[o[i-1]]] %in% trms[[o[i]]]))
stop("models must be nested")
## Check permutation matrix
@@ -65,7 +65,7 @@
pfvals <- apply(pfvals, 1, diff)
## dropped to vector?
if (!is.matrix(pfvals))
- pfvals <- matrix(pfvals, nrow=1, ncol=nperm)
+ pfvals <- matrix(pfvals, nrow = 1, ncol = nperm)
pfvals <- sweep(pfvals, 1, df, "/")
pfvals <- sweep(pfvals, 2, pscale, "/")
pval <- rowSums(sweep(pfvals, 1, fval - EPS, ">="))
@@ -90,5 +90,7 @@
howHead(attr(permutations, "control")))
topnote <- paste("Model ", format(1L:nmodels), ": ", formulae,
sep = "", collapse = "\n")
- structure(table, heading=c(head,topnote), class = c("anova", "data.frame"))
+ structure(table, heading = c(head,topnote),
+ F.perm = t(pfvals),
+ class = c("anova.cca", "anova", "data.frame"))
}
Modified: pkg/vegan/R/permustats.R
===================================================================
--- pkg/vegan/R/permustats.R 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/R/permustats.R 2015-09-17 10:03:56 UTC (rev 2962)
@@ -147,10 +147,10 @@
function(x, ...)
{
structure(list(
- "statistic" = structure(x$statistic, names="R"),
+ "statistic" = structure(x$statistic, names = "R"),
"permutations" = x$perm,
"alternative" = "greater"),
- class="permustats")
+ class = "permustats")
}
`permustats.adonis` <-
@@ -162,27 +162,27 @@
"statistic" = structure(tab$F.Model[k], names = rownames(tab)[k]),
"permutations" = x$f.perms,
"alternative" = "greater"),
- class="permustats")
+ class = "permustats")
}
`permustats.mantel` <-
function(x, ...)
{
structure(list(
- "statistic" = structure(x$statistic, names="r"),
+ "statistic" = structure(x$statistic, names = "r"),
"permutations" = x$perm,
"alternative" = "greater"),
- class="permustats")
+ class = "permustats")
}
`permustats.mrpp` <-
function(x, ...)
{
structure(list(
- "statistic" = structure(x$delta, names="delta"),
+ "statistic" = structure(x$delta, names = "delta"),
"permutations" = x$boot.deltas,
"alternative" = "less"),
- class="permustats")
+ class = "permustats")
}
`permustats.oecosimu` <-
@@ -192,7 +192,7 @@
"statistic" = x$oecosimu$statistic,
"permutations" = t(x$oecosimu$simulated),
"alternative" = x$oecosimu$alternative),
- class="permustats")
+ class = "permustats")
}
`permustats.ordiareatest` <-
@@ -212,7 +212,7 @@
"statistic" = structure(x$F.0, names = "F"),
"permutations" = x$F.perm,
"alternative" = "greater"),
- class="permustats")
+ class = "permustats")
}
`permustats.protest` <-
@@ -222,7 +222,7 @@
"statistic" = structure(x$t0, names = "r"),
"permutations" = x$t,
"alternative" = "greater"),
- class="permustats")
+ class = "permustats")
}
### the following do not return permutation data
@@ -268,5 +268,20 @@
structure(list("statistic" = x$statistic,
"permutations" = x$perm,
"alternative" = alt),
- class ="permustats")
+ class = "permustats")
}
+
+`permustats.anova.cca` <-
+ function(x, ...)
+{
+ if (is.null(attr(x, "F.perm")))
+ stop("no permutation data available")
+ F.perm <- attr(x, "F.perm")
+ k <- !is.na(x$F)
+ F.0 <- x$F[k]
+ structure(list(
+ "statistic" = structure(F.0, names = rownames(x)[k]),
+ "permutations" = F.perm,
+ "alternative" = "greater"),
+ class = "permustats")
+}
\ No newline at end of file
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/inst/NEWS.Rd 2015-09-17 10:03:56 UTC (rev 2962)
@@ -47,12 +47,30 @@
input data are integers that can be interpreted as counts on
individuals and all sampling units have some species. Unchecked
bad inputs were the reason for problems reported in
- \href{http://stackoverflow.com/questions/30856909/error-while-using-rarecurve-in-r}{Stackoverflow (Error while using rarecurve)}.
+ \href{http://stackoverflow.com/questions/30856909/error-while-using-rarecurve-in-r}{Stackoverflow}.
}
+ } % bug fixes
- }
+ \subsection{NEW FEATURES AND FUNCTIONS}{
+ \itemize{
+
+ \item Scaling of ordination axes in \code{cca}, \code{rda} and
+ \code{capscale} can now be expressed with descriptive strings
+ \code{"none"}, \code{"sites"}, \code{"species"} or
+ \code{"symmetric"} to tell which kind of scores should be scaled by
+ eigenvalues. These can be further modified with arguments
+ \code{hill} in \code{cca} and \code{correlation} in \code{rda}. The
+ old numeric scaling can still be used.
+ \item The permutation data can be extracted from \code{anova}
+ results of constrained ordination (\code{cca}, \code{rda},
+ \code{capscale}) and further analysed with \code{permustats}
+ function.
+
+ }
+ } % new features and functions
+
}
\section{Changes in version 2.3-0}{
Modified: pkg/vegan/man/anova.cca.Rd
===================================================================
--- pkg/vegan/man/anova.cca.Rd 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/man/anova.cca.Rd 2015-09-17 10:03:56 UTC (rev 2962)
@@ -145,7 +145,10 @@
\value{
The function \code{anova.cca} calls \code{permutest.cca} and fills an
- \code{\link{anova}} table.
+ \code{\link{anova}} table. Additional attributes are
+ \code{Random.seed} (the random seeds used),
+ \code{control} (the permutation design, see \link[permute]{how}) and
+ \code{F.perm} (the permuted test statistics).
}
\note{
Modified: pkg/vegan/man/permustats.Rd
===================================================================
--- pkg/vegan/man/permustats.Rd 2015-09-16 11:20:43 UTC (rev 2961)
+++ pkg/vegan/man/permustats.Rd 2015-09-17 10:03:56 UTC (rev 2962)
@@ -1,3 +1,4 @@
+\encoding{UTF-8}
\name{permustats}
\alias{permustats}
\alias{permustats.adonis}
@@ -2,2 +3,3 @@
\alias{permustats.anosim}
+\alias{permustats.anova.cca}
\alias{permustats.CCorA}
@@ -91,13 +93,11 @@
arguments to their underlying functions; see their documentation.
The \code{permustats} can extract permutation statistics from the
- results of \code{\link{adonis}}, \code{\link{anosim}},
- \code{\link{mantel}}, \code{\link{mantel.partial}},
+ results of \code{\link{adonis}}, \code{\link{anosim}},
+ \code{\link{anova.cca}}, \code{\link{mantel}}, \code{\link{mantel.partial}},
\code{\link{mrpp}}, \code{\link{oecosimu}}, \code{\link{ordiareatest}},
\code{\link{permutest.cca}}, \code{\link{protest}}, and
- \code{\link{permutest.betadisper}}. NB, there is no \code{permustats}
- method for \code{\link{anova.cca}}, but only for
- \code{\link{permutest.cca}}.
+ \code{\link{permutest.betadisper}}.
}
@@ -115,7 +115,7 @@
Jari Oksanen with contributions from Gavin L. Simpson
(\code{permustats.permutest.betadisper} method and related
modifications to \code{summary.permustats} and the \code{print}
- method.
+ method) and Eduard \enc{Szöcs}{Szoecs} (\code{permustats.anova.cca).}
}
\seealso{
More information about the Vegan-commits
mailing list