From noreply at r-forge.r-project.org Wed Oct 1 09:51:49 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 1 Oct 2014 09:51:49 +0200 (CEST)
Subject: [Vegan-commits] r2890 - pkg/vegan/R
Message-ID: <20141001075149.B9234187290@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-01 09:51:49 +0200 (Wed, 01 Oct 2014)
New Revision: 2890
Modified:
pkg/vegan/R/permutest.betadisper.R
Log:
Squashed commit of the following:
commit 951be045be7286ce35160f36562b795b2bec7f96
Merge: 1ca9538 47f3482
Author: Gavin Simpson
Date: Tue Sep 30 10:22:12 2014 -0600
Merge pull request #49 from gavinsimpson/master
fix a bug in calculation of p value in group pairwise permutation test
commit 47f348283bff6c9d8939b2780b62fcde15e1ed84
Author: Gavin Simpson
Date: Tue Sep 30 10:01:53 2014 -0600
fix a bug in calculation of p value in group pairwise permutation test introduced in c6b76f1
Modified: pkg/vegan/R/permutest.betadisper.R
===================================================================
--- pkg/vegan/R/permutest.betadisper.R 2014-09-30 07:24:02 UTC (rev 2889)
+++ pkg/vegan/R/permutest.betadisper.R 2014-10-01 07:51:49 UTC (rev 2890)
@@ -121,9 +121,10 @@
df <- apply(combin, 2, function(z) {
length(x$distances[group == z[1]]) +
length(x$distance[group == z[2]]) - 2})
+ pairp <- (colSums(sweep(abs(Tstats), 2, abs(T0), '>=')) + 1) /
+ (NROW(Tstats) + 1)
pairwise <- list(observed = 2 * pt(-abs(T0), df),
- permuted = apply(Tstats, 2,
- function(z) (sum(abs(z) >= abs(z[1])) + 1) / (length(z) + 1)))
+ permuted = pairp)
names(pairwise$observed) <- names(pairwise$permuted) <-
apply(combin, 2, paste, collapse = "-")
} else {
From noreply at r-forge.r-project.org Thu Oct 2 07:24:17 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Thu, 2 Oct 2014 07:24:17 +0200 (CEST)
Subject: [Vegan-commits] r2891 - in pkg/vegan: . R man tests/Examples
Message-ID: <20141002052417.B43191872C5@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-02 07:24:17 +0200 (Thu, 02 Oct 2014)
New Revision: 2891
Removed:
pkg/vegan/R/scoverage.R
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/nestedchecker.R
pkg/vegan/R/nesteddisc.R
pkg/vegan/R/nestedn0.R
pkg/vegan/R/nestedtemp.R
pkg/vegan/R/simulate.rda.R
pkg/vegan/man/decostand.Rd
pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
Squashed commit of the following:
commit c36a60df653b55f05f218b47a714f236a8734cfd
Author: Jari Oksanen
Date: Thu Oct 2 08:21:53 2014 +0300
update tests/Examples
commit 51db4dab9329ca8fd26dfe8476b4cad15c5a6ec2
Merge: 2ac73ea f6ad372
Author: Gavin Simpson
Date: Wed Oct 1 15:53:29 2014 -0600
Merge pull request #50 from jarioksa/revert-scoverage
remove scoverage()
commit f6ad3723b084ab0abdad89132c524c6457f1a3bd
Author: Jari Oksanen
Date: Wed Oct 1 23:11:24 2014 +0300
remove scoverage()
If this function is resurrected, it should be documented independently
and not with the decostand.
commit 2ac73ea242b5388ba935dd9efe5bc904ed8af509
Author: Jari Oksanen
Date: Wed Oct 1 15:02:53 2014 +0300
simulate.[rda,cca,capscale] only work with constrained ordination
Earlier they gave results, but these were wrong because fitted
component did not exist, and wrong component was used for them.
Now check and stop informatively.
commit 087a7250d12ee08e543696cfa84ebe84bbcd5ea5
Author: Jari Oksanen
Date: Wed Oct 1 12:01:32 2014 +0300
Update tests/Examples
commit fddbfc7c683d6a8f58e4838c20b07c2ddb22bde7
Author: Jari Oksanen
Date: Wed Oct 1 11:56:41 2014 +0300
nestedness indices return named statistics
commit 951be045be7286ce35160f36562b795b2bec7f96
Merge: 1ca9538 47f3482
Author: Gavin Simpson
Date: Tue Sep 30 10:22:12 2014 -0600
Merge pull request #49 from gavinsimpson/master
fix a bug in calculation of p value in group pairwise permutation test
commit 47f348283bff6c9d8939b2780b62fcde15e1ed84
Author: Gavin Simpson
Date: Tue Sep 30 10:01:53 2014 -0600
fix a bug in calculation of p value in group pairwise permutation test introduced in c6b76f1
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/NAMESPACE 2014-10-02 05:24:17 UTC (rev 2891)
@@ -22,7 +22,7 @@
pcnm, permatfull, permatswap, permustats, permutest,
poolaccum, postMDS, prc, prestondistr, prestonfit, procrustes,
protest, radfit, radlattice, rankindex, rarefy, rarecurve, raupcrick,
-rda, renyiaccum, renyi, rrarefy, scores, scoverage,
+rda, renyiaccum, renyi, rrarefy, scores,
showvarparts, simper, spandepth,
spantree, specaccum, specnumber, specpool2vect, specpool, spenvcor,
stepacross, stressplot, swan, tabasco, taxa2dist, taxondive, tolerance,
Modified: pkg/vegan/R/nestedchecker.R
===================================================================
--- pkg/vegan/R/nestedchecker.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/nestedchecker.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -4,6 +4,7 @@
cb <- sum(designdist(comm, "(A-J)*(B-J)", "binary"))
sppairs <- ncol(comm)*(ncol(comm)-1)/2
out <- list("C.score" = cb/sppairs, statistic = cb)
+ names(out$statistic) <- "checkerboards"
class(out) <- "nestedchecker"
out
}
Modified: pkg/vegan/R/nesteddisc.R
===================================================================
--- pkg/vegan/R/nesteddisc.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/nesteddisc.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -65,6 +65,7 @@
}
}
out <- list(statistic=Ad, ties = ties, order = k[x])
+ names(out$statistic) <- "discrepancy"
class(out) <- "nesteddisc"
out
}
Modified: pkg/vegan/R/nestedn0.R
===================================================================
--- pkg/vegan/R/nestedn0.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/nestedn0.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -8,6 +8,7 @@
for (i in 1:ncol(comm))
n0[i] <- sum(comm[,i] == 0 & R > spmin[i])
out <- list(spmin = spmin, n0 = n0, statistic = sum(n0))
+ names(out$statistic) <- "N0"
class(out) <- "nestedn0"
out
}
Modified: pkg/vegan/R/nestedtemp.R
===================================================================
--- pkg/vegan/R/nestedtemp.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/nestedtemp.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -88,6 +88,7 @@
temp <- 100*sum(u)/prod(dim(comm))/0.04145
out <- list(comm = comm, u = u, r = r, c = c, p = p,
fill=fill, statistic = temp, smooth=smo)
+ names(out$statistic) <- "temperature"
class(out) <- "nestedtemp"
out
}
Deleted: pkg/vegan/R/scoverage.R
===================================================================
--- pkg/vegan/R/scoverage.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/scoverage.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -1,14 +0,0 @@
-scoverage <- function(x, coverage.limit = 10) {
- x <- as.matrix(x)
- n <- rowSums(x)
- if (any(n <= 0))
- stop("negative or zero row totals not allowed")
- ## check if comm contains integer, especially for singletons
- if (any(x[x>0] < 1))
- warning("<1 non integer values detected: analysis might not be meaningful")
- if (abs(sum(x) - sum(as.integer(x))) > 10^-6)
- warning("non integer values detected")
- C1 <- 1 - rowSums(x==1) / n
- a <- decostand(x, "total")
- ifelse(x < coverage.limit, a * C1, a)
-}
Modified: pkg/vegan/R/simulate.rda.R
===================================================================
--- pkg/vegan/R/simulate.rda.R 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/R/simulate.rda.R 2014-10-02 05:24:17 UTC (rev 2891)
@@ -2,6 +2,12 @@
function(object, nsim = 1, seed = NULL, indx = NULL, rank = "full",
correlated = FALSE, ...)
{
+ ## Fail if there is no constrained component (it could be possible
+ ## to change the function to handle unconstrained ordination, too,
+ ## when rank < "full", but that would require redesign)
+ if (is.null(object$CCA))
+ stop("function can be used only with constrained ordination")
+
## Handle RNG: code directly from stats::simulate.lm
if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE))
runif(1)
@@ -29,7 +35,7 @@
nsim, nrow(indx)))
## Proper simulation: very similar for simulate.lm, but produces
## an array of response matrices
-
+
ftd <- predict(object, type = "response", rank = rank)
## pRDA: add partial Fit to the constrained
if (!is.null(object$pCCA))
@@ -91,6 +97,9 @@
function(object, nsim = 1, seed = NULL, indx = NULL, rank = "full",
correlated = FALSE, ...)
{
+ ## Fail if no CCA
+ if (is.null(object$CCA))
+ stop("function can be used only with constrained ordination")
## Handle RNG: code directly from stats::simulate.lm
if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE))
runif(1)
@@ -183,6 +192,9 @@
function(object, nsim = 1, seed = NULL, indx = NULL, rank = "full",
correlated = FALSE, ...)
{
+ ## Fail if no CCA component
+ if (is.null(object$CCA))
+ stop("function can be used only with constrained ordination")
if (is.null(indx) && correlated)
warning("argument 'correlated' does not work and will be ignored")
## Handle RNG: code directly from stats::simulate.lm
Modified: pkg/vegan/man/decostand.Rd
===================================================================
--- pkg/vegan/man/decostand.Rd 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/man/decostand.Rd 2014-10-02 05:24:17 UTC (rev 2891)
@@ -2,7 +2,6 @@
\name{decostand}
\alias{decostand}
\alias{wisconsin}
-\alias{scoverage}
\title{Standardization Methods for Community Ecology}
\description{
@@ -11,10 +10,7 @@
}
\usage{
decostand(x, method, MARGIN, range.global, logbase = 2, na.rm=FALSE, ...)
-
wisconsin(x)
-
-scoverage(x, coverage.limit = 10)
}
\arguments{
@@ -28,8 +24,6 @@
\code{x}. }
\item{logbase}{The logarithm base used in \code{method = "log"}.}
\item{na.rm}{Ignore missing values in row or column standardizations.}
- \item{coverage.limit}{Integer, the sample coverage based correction
- is applied to rare species with counts below this limit.}
\item{\dots}{Other arguments to the function (ignored).}
}
\details{
@@ -86,16 +80,6 @@
data. If there are empty sites or species (or constant with
\code{method = "range"}), many standardization will change these into
\code{NaN}.
-
- \code{scoverage} calculates sample relative frequencies
- (divide by row total, \code{method = "total"} in \code{decostand})
- for species with abundances larger than or equal to \code{coverage.limit}.
- The sample coverage based correction proposed by Turing (see Good 1953)
- is calculated for species with abundances smaller than
- \code{coverage.limit}. The correction is based on the number of
- singleton species in each row.
- The function expects nonnegative integer values in the community matrix
- with no empty rows.
}
\value{
Returns the standardized data frame, and adds an attribute
@@ -103,8 +87,7 @@
\code{"method"}.
}
\author{Jari Oksanen, Etienne \enc{Lalibert?}{Laliberte}
- (\code{method = "log"}),
- Peter Solymos (\code{scoverage}).}
+ (\code{method = "log"}).}
\note{Common transformations can be made with standard \R functions.}
\references{
@@ -113,10 +96,6 @@
dispersion as a measure of beta diversity. \emph{Ecology Letters}
\strong{9}, 683--693.
- Good, I. J. 1953. The population frequencies of species and the
- estimation of population parameters. \emph{Biometrika}
- \strong{40}, 237--264.
-
Legendre, P. & Gallagher, E.D. (2001) Ecologically meaningful
transformations for ordination of species data. \emph{Oecologia}
\strong{129}, 271--280.
@@ -136,9 +115,6 @@
## Use wcmdscale for weighted analysis and identical results.
sptrans <- decostand(varespec, "chi.square")
plot(procrustes(rda(sptrans), cca(varespec)))
-
-data(mite)
-sptrans <- scoverage(mite)
}
\keyword{ multivariate}
\keyword{ manip }
Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-01 07:51:49 UTC (rev 2890)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-02 05:24:17 UTC (rev 2891)
@@ -160,7 +160,7 @@
Formula:
y ~ poly(x1, 1) + poly(x2, 1)
-
+
Total model degrees of freedom 3
REML score: -3.185099
@@ -1106,7 +1106,7 @@
Pairwise comparisons:
(Observed p-value below diagonal, permuted p-value above diagonal)
grazed ungrazed
-grazed 0.56
+grazed 0.05
ungrazed 0.04295
>
> ## Tukey's Honest Significant Differences
@@ -2164,7 +2164,7 @@
>
> ### Name: decostand
> ### Title: Standardization Methods for Community Ecology
-> ### Aliases: decostand wisconsin scoverage
+> ### Aliases: decostand wisconsin
> ### Keywords: multivariate manip
>
> ### ** Examples
@@ -2191,11 +2191,8 @@
> sptrans <- decostand(varespec, "chi.square")
> plot(procrustes(rda(sptrans), cca(varespec)))
>
-> data(mite)
-> sptrans <- scoverage(mite)
>
>
->
> cleanEx()
> nameEx("designdist")
> ### * designdist
@@ -4192,8 +4189,8 @@
Checkerboard Units : 2767
C-score (species mean): 2.258776
- statistic z mean 2.5% 50% 97.5% Pr(sim.)
-statistic 2767 0.84129 2698.1 2584.4 2676.0 2858.1 0.39
+ statistic z mean 2.5% 50% 97.5% Pr(sim.)
+checkerboards 2767 0.84129 2698.1 2584.4 2676.0 2858.1 0.39
> ## Another Null model and standardized checkerboard score
> oecosimu(sipoo, nestedchecker, "r00", statistic = "C.score")
oecosimu object
@@ -4335,8 +4332,8 @@
Checkerboard Units : 2767
C-score (species mean): 2.258776
- statistic z mean 2.5% 50% 97.5% Pr(sim.)
-statistic 2767 -17.768 8034.6 7529.9 8052.0 8518.5 0.01 **
+ statistic z mean 2.5% 50% 97.5% Pr(sim.)
+checkerboards 2767 -17.768 8034.6 7529.9 8052.0 8518.5 0.01 **
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
> ## sequential model, one-sided test, a vector statistic
@@ -4905,7 +4902,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4922,7 +4919,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
6.45 total = 7.45
@@ -4953,7 +4950,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4968,7 +4965,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE)
-
+
Estimated degrees of freedom:
4.43 total = 5.43
@@ -4997,7 +4994,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -5013,7 +5010,7 @@
Formula:
y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE)
-
+
Estimated degrees of freedom:
3 total = 4
@@ -5030,7 +5027,7 @@
Formula:
y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE,
FALSE))
-
+
Estimated degrees of freedom:
2.99 total = 3.99
@@ -5049,7 +5046,7 @@
Formula:
y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE,
TRUE))
-
+
Estimated degrees of freedom:
11 total = 12
@@ -5190,7 +5187,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.71 total = 9.71
@@ -5203,7 +5200,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
7.18 total = 8.18
@@ -5216,7 +5213,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.32 total = 9.32
@@ -5554,7 +5551,7 @@
Pairwise comparisons:
(Observed p-value below diagonal, permuted p-value above diagonal)
grazed ungrazed
-grazed 0.56
+grazed 0.05
ungrazed 0.04295
>
> ## Tukey's Honest Significant Differences
@@ -7862,7 +7859,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
1.28 total = 2.28
@@ -8418,7 +8415,7 @@
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 34.229 8.176 39.961 0 0
+Time elapsed: 34.698 8.183 40.373 0 0
> grDevices::dev.off()
null device
1
From noreply at r-forge.r-project.org Fri Oct 3 15:15:29 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Fri, 3 Oct 2014 15:15:29 +0200 (CEST)
Subject: [Vegan-commits] r2892 - in pkg/vegan: R man tests/Examples
Message-ID: <20141003131529.D52CF186948@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-03 15:15:29 +0200 (Fri, 03 Oct 2014)
New Revision: 2892
Removed:
pkg/vegan/man/scores.hclust.Rd
Modified:
pkg/vegan/R/permutest.betadisper.R
pkg/vegan/man/reorder.hclust.Rd
pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
Squashed commit of the following:
commit fba9b24cc98f984254544db5cd87cdb224098588
Author: Gavin Simpson
Date: Thu Oct 2 23:16:46 2014 -0600
Update test example output
commit 8d70932789980c484b108c14f7166f0bac24f3ff
Merge: 8086446 a439b75
Author: Gavin Simpson
Date: Thu Oct 2 22:43:57 2014 -0600
Merge pull request #45 from jarioksa/fix-no-of-permutations-in-permutest.beadisper
@jarioksa has convinced me of the benefits of treating permutations following Phipson, B. & Smyth, G. K. Permutation P-values should never be zero: calculating exact P-values when permutations are randomly drawn. Stat. Appl. Genet. Mol. Biol. 9, Article39 (2010). permutest.betadisper: no. of permutations counted without observed stat
commit 8086446245adb253f6cf8bbd749c21195dff2dc8
Author: Jari Oksanen
Date: Thu Oct 2 16:34:17 2014 +0300
update tests/Examples
commit a439b751ed64b32c1234a6993c726153f8f8f6cf
Author: Jari Oksanen
Date: Fri Sep 26 12:00:39 2014 +0300
permutest.betadisper: no. of permutations counted without observed stat
Although we put the observed value among permutations, the number
of permutations should be given without that observed statistic
(like done in all other vegan functions).
Modified: pkg/vegan/R/permutest.betadisper.R
===================================================================
--- pkg/vegan/R/permutest.betadisper.R 2014-10-02 05:24:17 UTC (rev 2891)
+++ pkg/vegan/R/permutest.betadisper.R 2014-10-03 13:15:29 UTC (rev 2892)
@@ -131,7 +131,7 @@
pairwise <- NULL
}
- retval <- cbind(mod.aov[, 1:4], c(nperm + 1, NA), c(pval, NA))
+ retval <- cbind(mod.aov[, 1:4], c(nperm, NA), c(pval, NA))
dimnames(retval) <- list(c("Groups", "Residuals"),
c("Df", "Sum Sq", "Mean Sq", "F", "N.Perm",
"Pr(>F)"))
Modified: pkg/vegan/man/reorder.hclust.Rd
===================================================================
--- pkg/vegan/man/reorder.hclust.Rd 2014-10-02 05:24:17 UTC (rev 2891)
+++ pkg/vegan/man/reorder.hclust.Rd 2014-10-03 13:15:29 UTC (rev 2892)
@@ -1,6 +1,7 @@
\name{reorder.hclust}
\alias{reorder.hclust}
\alias{rev.hclust}
+\alias{scores.hclust}
\title{
Reorder a Hierarchical Clustering Tree
@@ -21,6 +22,7 @@
\method{reorder}{hclust}(x, wts,
agglo.FUN = c("mean", "min", "max", "sum", "uwmean"), ...)
\method{rev}{hclust}(x)
+\method{scores}{hclust}(x, display = "internal", ...)
}
\arguments{
@@ -33,6 +35,10 @@
\item{agglo.FUN}{
a function for weights agglomeration, see below.
}
+ \item{display}{
+ return \code{"internal"} nodes or \code{"terminal"} nodes (also
+ called \code{"leaves"}).
+}
\item{\dots}{
additional arguments (ignored).
}
@@ -55,8 +61,13 @@
The function accepts only a limited list of \code{agglo.FUN}
functions for assessing the value of \code{wts} for groups. The
ordering is always ascending, but the order of leaves can be
- reversed with \code{rev}.
+ reversed with \code{rev}.
+ Function \code{scores} finds the coordinates of nodes as a two-column
+ matrix. For terminal nodes (leaves) this the value at which the item
+ is merged to the tree, and the labels can still \code{hang} below this
+ level (see \code{\link{plot.hclust}}).
+
}
\value{
@@ -81,11 +92,18 @@
alternative implementation.
}
\examples{
+## reorder by water content of soil
data(mite, mite.env)
hc <- hclust(vegdist(wisconsin(sqrt(mite))))
ohc <- with(mite.env, reorder(hc, WatrCont))
plot(hc)
plot(ohc)
+
+## label leaves by the observed value, and each branching point
+## (internal node) by the cluster mean
+with(mite.env, plot(ohc, labels=round(WatrCont), cex=0.7))
+ordilabel(scores(ohc), label=round(ohc$value), cex=0.7)
+
## Slightly different from reordered 'dendrogram' which ignores group
## sizes in assessing means.
den <- as.dendrogram(hc)
Deleted: pkg/vegan/man/scores.hclust.Rd
===================================================================
--- pkg/vegan/man/scores.hclust.Rd 2014-10-02 05:24:17 UTC (rev 2891)
+++ pkg/vegan/man/scores.hclust.Rd 2014-10-03 13:15:29 UTC (rev 2892)
@@ -1,70 +0,0 @@
-\name{scores.hclust}
-\alias{scores.hclust}
-
-\title{
- Coordinates of Leaves and Internal Nodes in a hclust Tree
-}
-
-\description{ The function finds the coordinates that will be used for
- internal nodes and leaves when an \code{\link{hclust}} object is
- plotted. These help in annotating the plotted dendrogram. }
-
-\usage{
-\method{scores}{hclust}(x, display = "internal", ...)
-}
-
-\arguments{
- \item{x}{
- An \code{\link{hclust}} result object.
-}
- \item{display}{
- Return \code{"internal"} nodes or \code{"terminal"} nodes (also
- called \code{"leaves"}.
-}
- \item{\dots}{
- Other arguments passed to the function (ignored).
-}
-}
-
-\details{
-
- The function returns the coordinates of nodes in an
- \code{\link{hclust}} plot as two-column matrix. First column called
- \code{x} gives the horizontal coordinates which for \eqn{n} terminal
- nodes (leaves) is an integer sequence \eqn{1..n}. The second column
- called \code{height} gives the merge value. For terminal nodes
- (leaves) this the value at which the item is merged to the tree, and
- in plots the labels can still hang below this level, as defined by
- the argument \code{hang} in \code{\link{plot.hclust}}.
-
- The function only works with \code{\link{hclust}} objects; it does
- not work with \code{\link{dendrogram}}.
-
-}
-
-\value{
- A two-column matrix of coordinates.
-}
-
-\author{
- Jari Oksanen.
-}
-
-\note{
- This function may be removed as useless.
-}
-
-
-\seealso{
- \code{\link{hclust}}, \code{\link{plot.hclust}}.
-}
-\examples{
-## Show values that were used in reordering a tree
-data(mite, mite.env)
-hc <- hclust(vegdist(mite))
-hc <- with(mite.env, reorder(hc, WatrCont))
-with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7))
-ordilabel(scores(hc), label=round(hc$value), cex=0.7)
-}
-\keyword{ multivariate }
-
Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-02 05:24:17 UTC (rev 2891)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-03 13:15:29 UTC (rev 2892)
@@ -1,5 +1,5 @@
-R Under development (unstable) (2014-09-30 r66697) -- "Unsuffered Consequences"
+R version 3.1.1 Patched (2014-09-17 r66626) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
@@ -160,7 +160,7 @@
Formula:
y ~ poly(x1, 1) + poly(x2, 1)
-
+
Total model degrees of freedom 3
REML score: -3.185099
@@ -1098,7 +1098,7 @@
Response: Distances
Df Sum Sq Mean Sq F N.Perm Pr(>F)
-Groups 1 0.07931 0.079306 4.6156 100 0.04 *
+Groups 1 0.07931 0.079306 4.6156 99 0.04 *
Residuals 22 0.37801 0.017182
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
@@ -1255,7 +1255,7 @@
Response: Distances
Df Sum Sq Mean Sq F N.Perm Pr(>F)
-Groups 1 0.039979 0.039979 2.4237 100 0.19
+Groups 1 0.039979 0.039979 2.4237 99 0.19
Residuals 18 0.296910 0.016495
> anova(mod2)
Analysis of Variance Table
@@ -1298,7 +1298,7 @@
Response: Distances
Df Sum Sq Mean Sq F N.Perm Pr(>F)
-Groups 1 0.033468 0.033468 3.1749 100 0.1
+Groups 1 0.033468 0.033468 3.1749 99 0.1
Residuals 18 0.189749 0.010542
> anova(mod3)
Analysis of Variance Table
@@ -1556,8 +1556,6 @@
> ## Avoid negative eigenvalues with additive constant
> capscale(varespec ~ N + P + K + Condition(Al), varechem,
+ dist="bray", add =TRUE)
-Warning in cmdscale(X, k = k, eig = TRUE, add = add) :
- only 22 of the first 23 eigenvalues are > 0
Call: capscale(formula = varespec ~ N + P + K + Condition(Al), data =
varechem, distance = "bray", add = TRUE)
@@ -3667,7 +3665,7 @@
Run 6 stress 0.107471
Run 7 stress 0.1067169
... New best solution
-... procrustes: rmse 4.525314e-06 max resid 1.281822e-05
+... procrustes: rmse 4.525315e-06 max resid 1.281822e-05
*** Solution reached
> sol
@@ -4833,38 +4831,20 @@
Call: mite.hel ~ WatrCont + Shrub + Substrate + Topo
R2.adjusted
- 0.4367038
+ SubsDens 0.4367038
+ 0.4367038
0.4004249
- Topo 0.3653551
- Shrub 0.3591790
- Substrate 0.3525851
- WatrCont 0.3145444
- Df AIC F Pr(>F)
-+ SubsDens 1 -94.489 4.7999 0.002 **
----
-Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
-
-Step: R2.adj= 0.4367038
-Call: mite.hel ~ WatrCont + Shrub + Substrate + Topo + SubsDens
-
- R2.adjusted
- 0.4367038
- 0.4367038
-- Shrub 0.4079297
-- SubsDens 0.4004249
-- Substrate 0.3951235
-- Topo 0.3901844
-- WatrCont 0.3357858
-
> step.res$anova # Summary table
R2.adj Df AIC F Pr(>F)
+ WatrCont 0.26085 1 -84.336 25.3499 0.002 **
+ Shrub 0.31775 2 -88.034 3.8360 0.002 **
+ Substrate 0.36536 6 -87.768 1.8251 0.002 **
+ Topo 0.40042 1 -90.924 4.5095 0.004 **
-+ SubsDens 0.43670 1 -94.489 4.7999 0.002 **
0.43670
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
@@ -4902,7 +4882,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4919,7 +4899,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
6.45 total = 7.45
@@ -4950,7 +4930,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4965,7 +4945,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE)
-
+
Estimated degrees of freedom:
4.43 total = 5.43
@@ -4981,7 +4961,7 @@
> ## or via plot.gam directly
> library(mgcv)
Loading required package: nlme
-This is mgcv 1.8-2. For overview type 'help("mgcv-package")'.
+This is mgcv 1.8-3. For overview type 'help("mgcv-package")'.
> plot.gam(fit, cex = 2, pch = 1, col = "blue")
> ## 'col' effects all objects drawn...
>
@@ -4994,7 +4974,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -5010,7 +4990,7 @@
Formula:
y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE)
-
+
Estimated degrees of freedom:
3 total = 4
@@ -5027,7 +5007,7 @@
Formula:
y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE,
FALSE))
-
+
Estimated degrees of freedom:
2.99 total = 3.99
@@ -5046,7 +5026,7 @@
Formula:
y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE,
TRUE))
-
+
Estimated degrees of freedom:
11 total = 12
@@ -5187,7 +5167,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.71 total = 9.71
@@ -5200,7 +5180,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
7.18 total = 8.18
@@ -5213,7 +5193,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.32 total = 9.32
@@ -5543,7 +5523,7 @@
Response: Distances
Df Sum Sq Mean Sq F N.Perm Pr(>F)
-Groups 1 0.07931 0.079306 4.6156 100 0.04 *
+Groups 1 0.07931 0.079306 4.6156 99 0.04 *
Residuals 22 0.37801 0.017182
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
@@ -6003,8 +5983,8 @@
[2,] 0.1154641 0.9933117
Translation of averages:
- [,1] [,2]
-[1,] 3.038945e-17 1.218602e-17
+ [,1] [,2]
+[1,] -3.278601e-18 9.393617e-18
Scaling of target:
[1] 0.6727804
@@ -6218,16 +6198,23 @@
>
> ### Name: reorder.hclust
> ### Title: Reorder a Hierarchical Clustering Tree
-> ### Aliases: reorder.hclust rev.hclust
+> ### Aliases: reorder.hclust rev.hclust scores.hclust
> ### Keywords: multivariate
>
> ### ** Examples
>
+> ## reorder by water content of soil
> data(mite, mite.env)
> hc <- hclust(vegdist(wisconsin(sqrt(mite))))
> ohc <- with(mite.env, reorder(hc, WatrCont))
> plot(hc)
> plot(ohc)
+>
+> ## label leaves by the observed value, and each branching point
+> ## (internal node) by the cluster mean
+> with(mite.env, plot(ohc, labels=round(WatrCont), cex=0.7))
+> ordilabel(scores(ohc), label=round(ohc$value), cex=0.7)
+>
> ## Slightly different from reordered 'dendrogram' which ignores group
> ## sizes in assessing means.
> den <- as.dendrogram(hc)
@@ -6281,28 +6268,6 @@
>
>
> cleanEx()
-> nameEx("scores.hclust")
-> ### * scores.hclust
->
-> flush(stderr()); flush(stdout())
->
-> ### Name: scores.hclust
-> ### Title: Coordinates of Leaves and Internal Nodes in a hclust Tree
-> ### Aliases: scores.hclust
-> ### Keywords: multivariate
->
-> ### ** Examples
->
-> ## Show values that were used in reordering a tree
-> data(mite, mite.env)
-> hc <- hclust(vegdist(mite))
-> hc <- with(mite.env, reorder(hc, WatrCont))
-> with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7))
-> ordilabel(scores(hc), label=round(hc$value), cex=0.7)
->
->
->
-> cleanEx()
> nameEx("screeplot.cca")
> ### * screeplot.cca
>
@@ -7146,7 +7111,7 @@
Anthodor 1.0199113 7.575379e-01
Bellpere 1.1104145 9.067794e-01
Bromhord 1.0381512 5.515502e-01
-Chenalbu 0.6033850 6.883383e-15
+Chenalbu 0.6033850 3.996803e-15
Cirsarve 1.3186022 1.010898e-09
Comapalu 2.1945688 5.677653e-01
Eleopalu 1.7007903 8.292822e-01
@@ -7859,7 +7824,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
1.28 total = 2.28
@@ -8381,13 +8346,13 @@
> ## Eigevalues are numerically similar
> ca$CA$eig - ord$eig
CA1 CA2 CA3 CA4 CA5
- 2.220446e-16 -1.276756e-15 -1.054712e-15 1.942890e-16 1.387779e-16
+ 1.110223e-16 -6.106227e-16 2.775558e-16 -1.110223e-16 2.775558e-16
CA6 CA7 CA8 CA9 CA10
- 1.387779e-16 -1.387779e-17 -1.387779e-16 2.359224e-16 2.775558e-17
+-2.775558e-17 -1.387779e-16 -2.636780e-16 1.942890e-16 -6.938894e-18
CA11 CA12 CA13 CA14 CA15
- 1.387779e-16 0.000000e+00 3.469447e-17 2.775558e-17 1.561251e-17
+ 1.387779e-16 4.857226e-17 7.632783e-17 3.469447e-18 1.734723e-17
CA16 CA17 CA18 CA19
- 0.000000e+00 1.734723e-18 1.127570e-17 1.196959e-16
+ 0.000000e+00 -1.734723e-18 -2.602085e-17 4.336809e-18
> ## Configurations are similar when site scores are scaled by
> ## eigenvalues in CA
> procrustes(ord, ca, choices=1:19, scaling = 1)
@@ -8415,7 +8380,7 @@
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 34.698 8.183 40.373 0 0
+Time elapsed: 104.001 1.198 105.469 0 0
> grDevices::dev.off()
null device
1
From noreply at r-forge.r-project.org Tue Oct 7 11:50:19 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 7 Oct 2014 11:50:19 +0200 (CEST)
Subject: [Vegan-commits] r2893 - pkg/vegan/R
Message-ID: <20141007095019.53DA21874BC@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-07 11:50:19 +0200 (Tue, 07 Oct 2014)
New Revision: 2893
Modified:
pkg/vegan/R/getPermuteMatrix.R
pkg/vegan/R/vegan-deprecated.R
Log:
Squashed commit of the following:
commit ea6dcea6a34dc8b52624bb17b08a43de5bb82af7
Author: Jari Oksanen
Date: Tue Oct 7 10:48:27 2014 +0300
Do not yet warn on commsimulator deprecation
We do not yet warn on commsimulator deprecation in vegan 2.2-0
but only in the next release to give other packages time to
adapt. There were thousands of warnings in CRAN packages
bipartite and metacom.
commit dde0dd6c726f0781b8ffabe8cdc402e939546bb8
Author: Jari Oksanen
Date: Mon Oct 6 14:50:11 2014 +0300
allow missing 'strata' in permutations
getPermuteMatrix used 'strata=NULL' to define there are no
strata. Vegan functions were adopted to this, but this broke
CRAN packages cocorresp and mpmcorrelogram. The fix was so simple
and obvious that it is almost annoying.
Modified: pkg/vegan/R/getPermuteMatrix.R
===================================================================
--- pkg/vegan/R/getPermuteMatrix.R 2014-10-03 13:15:29 UTC (rev 2892)
+++ pkg/vegan/R/getPermuteMatrix.R 2014-10-07 09:50:19 UTC (rev 2893)
@@ -15,7 +15,7 @@
perm <- how(nperm = perm)
}
## apply 'strata'
- if (!is.null(strata)) {
+ if (!missing(strata) && !is.null(strata)) {
if (!inherits(perm, "how")) # 'perm' is a matrix
stop("'strata' can be used only with simple permutation or with 'how()'")
if (!is.null(getBlocks(perm)))
Modified: pkg/vegan/R/vegan-deprecated.R
===================================================================
--- pkg/vegan/R/vegan-deprecated.R 2014-10-03 13:15:29 UTC (rev 2892)
+++ pkg/vegan/R/vegan-deprecated.R 2014-10-07 09:50:19 UTC (rev 2893)
@@ -3,7 +3,8 @@
"commsimulator" <-
function (x, method, thin = 1)
{
- .Deprecated("nullmodel", package="vegan")
+ ## Do not yet warn on deprecation to allow smooth transition
+ ##.Deprecated("nullmodel", package="vegan")
method <- match.arg(method,
c("r0","r1","r2","r00","c0","swap", "tswap",
"backtrack", "quasiswap"))
From noreply at r-forge.r-project.org Tue Oct 7 20:18:57 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Tue, 7 Oct 2014 20:18:57 +0200 (CEST)
Subject: [Vegan-commits] r2894 - www
Message-ID: <20141007181857.2CDF9187693@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-07 20:18:56 +0200 (Tue, 07 Oct 2014)
New Revision: 2894
Modified:
www/NEWS.html
Log:
first NEWS about vegan 2.2-0
Modified: www/NEWS.html
===================================================================
--- www/NEWS.html 2014-10-07 09:50:19 UTC (rev 2893)
+++ www/NEWS.html 2014-10-07 18:18:56 UTC (rev 2894)
@@ -8,6 +8,156 @@
vegan News
+Changes in version 2.2-0
+
+
+
+GENERAL
+
+
+
+
+
+
+
+INSTALLATION
+
+
+
+
+
+
+
+NEW FUNCTIONS
+
+
+
+ Dispersion weighting dispweight plus a new method
+for generalized dispersion weigthing gdispweight.
+
+
+-
hclust support functions reorder, rev
+and scores.
+
+
+-
permustats to extract and inspect permutation
+results with support functions summary, density,
+densityplot, qqnorm and qqmath.
+
+
+-
stressplot functions.
+
+
+
+
+
+
+BUG FIXES
+
+
+
+
+NEW FEATURES
+
+
+
+-
anova.cca functions re-written, and added an option
+of analysing a sequence of models against each other.
+
+
+-
simulate functions for cca and rda
+can return several simulations in a nullmodel compatible
+object. The functions can produce simulations with correlated
+errors (also for capscale).
+
+
+-
bioenv can use Manhattan, Gower and Mahalanobis
+distances in addition to Euclidean. New helper function
+bioenvdist can extract the dissimilarities applied in
+best model or any other model.
+
+
+-
MDSrotate can rotate to multidimensional target.
+
+
+-
nestednodf gained new option for defining weighted
+nestedness statistic.
+
+
+-
rankindex can use Manhattan, Gower and Mahalanobis
+distance in addition to Euclidean.
+
+
+-
spantree gained a support function as.hclust
+to change the minimum spannig tree into an hclust tree.
+
+
+-
fitspecaccum can do weighted analysis.
+
+
+-
vegdist gained Mahalanobis distance.
+
+
+ Nomenclature updated in plant community
+data. varespec and dune use 8-character names (4
+from genus + 4 from species epithet). New data set on
+phylogenetic distances for dune.
+
+
+ User configurable plots for rarecurve.
+
+
+
+
+
+
+DEPRECATED AND DEFUNCT
+
+
+
+-
strata deprecated in permutations. It is still
+accepted but will be phased out in next releases. Use how
+of permute package.
+
+
+-
cca, rda and capscale do not return
+scores scaled by eigenvalues: use scores function to
+extract scaled results.
+
+
+-
commsimulator is deprecated. Replace
+commsimulator(x, method) with simulate(nullmodel(x,
+ method)).
+
+
+-
density and densityplot for permutation
+results: use density(permustats(<permutation-object)).
+
+
+-
ordirgl with its support functions, other rgl
+functions and ordiplot3d were moved to the vegan3d
+package.
+
+
+
+
+
+
Changes in version 2.0-10
From noreply at r-forge.r-project.org Wed Oct 8 09:43:05 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 8 Oct 2014 09:43:05 +0200 (CEST)
Subject: [Vegan-commits] r2895 - in pkg/vegan: R inst man
Message-ID: <20141008074305.594FD1866B0@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-08 09:43:04 +0200 (Wed, 08 Oct 2014)
New Revision: 2895
Modified:
pkg/vegan/R/ade2vegancca.R
pkg/vegan/R/capscale.R
pkg/vegan/R/cca.default.R
pkg/vegan/R/rda.default.R
pkg/vegan/inst/NEWS.Rd
pkg/vegan/man/cca.object.Rd
Log:
Squashed commit of the following:
commit 16d74e39dd745c445cb862aae860ddbc83d25a57
Author: Jari Oksanen
Date: Tue Oct 7 21:06:02 2014 +0300
skeleton of NEWS about vegan 2.2-0
commit 70e5542754fbf3c67cf55bc19db42b61708ec0b8
Merge: ea6dcea 54aa57f
Author: Gavin Simpson
Date: Tue Oct 7 08:37:56 2014 -0600
Merge pull request #51 from jarioksa/remove-u.eig-etc
Remove u.eig etc
commit 54aa57fa08c06424a8d0ad7aa4575f5de52352e0
Author: Jari Oksanen
Date: Sun Oct 5 20:15:40 2014 +0300
man/cca.object tells about imaginary.u.eig scores in capscale
commit 971a7f602364109e13cfb21e21216c067c6f8cf8
Author: Jari Oksanen
Date: Sun Oct 5 08:44:48 2014 +0300
man/cca.object.Rd updated to new cca object without .eig scores
There is a note about changes which here are suggested to be
effective in vegan 2.2-0.
commit c4ab85b43a13d0ac1a61aae7ac9c63e60b494368
Author: Jari Oksanen
Date: Sun Oct 5 08:43:46 2014 +0300
neither ade2vegancca returns u.eig, v.eig, wa.eig
commit 5f33e5be3092f5102d4e7b33d11990a66fa3b8e6
Author: Jari Oksanen
Date: Sun Oct 5 08:39:38 2014 +0300
remove v.eig item from capscale result
wa.eig and u.eig already disappeared with rda changes.
The result still has CA$imaginary.u.eig (scaled scores for
imaginary axes). These are the only scores returned for
imaginary axes.
commit 96d8bdf0695ac0254b8233fb48f585a764130251
Author: Jari Oksanen
Date: Sun Oct 5 08:14:13 2014 +0300
remove u.eig etc from rda
commit 761afcb0a6895a530b74334f0ffa0c727483b425
Author: Jari Oksanen
Date: Sun Oct 5 07:56:11 2014 +0300
remove u.eig, v.eig and wa.eig items from cca.default
The cca.object was documented in vegan 1.6-10 (Sep 26, 2005), and
in that document we warn that there is "no guarantee" that these
itmems will be kept in future release. In commit bddfea39 (Mar 5, 2013)
we use harsher tone and said that the "item will be removed". However,
that harsher text has not been in any release version so that this
may be an abrupt change.
Modified: pkg/vegan/R/ade2vegancca.R
===================================================================
--- pkg/vegan/R/ade2vegancca.R 2014-10-07 18:18:56 UTC (rev 2894)
+++ pkg/vegan/R/ade2vegancca.R 2014-10-08 07:43:04 UTC (rev 2895)
@@ -1,4 +1,3 @@
-
`ade2vegancca` <-
function(object)
{
@@ -6,16 +5,14 @@
CCA <- list(eig = object$eig,
u = as.matrix(object$l1),
v = as.matrix(object$c1),
- u.eig = as.matrix(object$li),
- v.eig = as.matrix(object$co),
- wa.eig = as.matrix(object$ls),
+ wa = sweep(as.matrix(object$ls), 2,
+ 1/sqrt(object$eig[1:nf]), "*"),
biplot = as.matrix(object$cor)[-1,],
rank = object$rank,
tot.chi = sum(object$eig),
QR = NA,
envcentre = NA,
Xbar = NA)
- CCA$wa <- sweep(CCA$wa.eig, 2, 1/sqrt(object$eig[1:nf]), "*")
out <- list(call = object$call,
grand.total = NA,
rowsum = object$lw,
Modified: pkg/vegan/R/capscale.R
===================================================================
--- pkg/vegan/R/capscale.R 2014-10-07 18:18:56 UTC (rev 2894)
+++ pkg/vegan/R/capscale.R 2014-10-08 07:43:04 UTC (rev 2895)
@@ -124,20 +124,20 @@
if (!is.null(sol$pCCA) && sol$pCCA$rank > 0)
comm <- qr.resid(sol$pCCA$QR, comm)
if (!is.null(sol$CCA) && sol$CCA$rank > 0) {
- sol$CCA$v.eig <- t(comm) %*% sol$CCA$u/sqrt(k)
- sol$CCA$v <- decostand(sol$CCA$v.eig, "normalize", MARGIN = 2)
+ v.eig <- t(comm) %*% sol$CCA$u/sqrt(k)
+ sol$CCA$v <- decostand(v.eig, "normalize", MARGIN = 2)
comm <- qr.resid(sol$CCA$QR, comm)
}
if (!is.null(sol$CA) && sol$CA$rank > 0) {
- sol$CA$v.eig <- t(comm) %*% sol$CA$u/sqrt(k)
- sol$CA$v <- decostand(sol$CA$v.eig, "normalize", MARGIN = 2)
+ v.eig <- t(comm) %*% sol$CA$u/sqrt(k)
+ sol$CA$v <- decostand(v.eig, "normalize", MARGIN = 2)
}
} else {
## input data were dissimilarities, and no 'comm' defined:
## species scores make no sense and are made NA
- sol$CA$v.eig[] <- sol$CA$v[] <- NA
+ sol$CA$v[] <- NA
if (!is.null(sol$CCA))
- sol$CCA$v.eig[] <- sol$CCA$v[] <- NA
+ sol$CCA$v[] <- NA
sol$colsum <- NA
}
if (!is.null(sol$CCA) && sol$CCA$rank > 0)
Modified: pkg/vegan/R/cca.default.R
===================================================================
--- pkg/vegan/R/cca.default.R 2014-10-07 18:18:56 UTC (rev 2894)
+++ pkg/vegan/R/cca.default.R 2014-10-08 07:43:04 UTC (rev 2895)
@@ -68,11 +68,9 @@
1, 1/sqrt(rowsum), "*")
CCA$v <- sweep(as.matrix(sol$v[, 1:rank, drop = FALSE]),
1, 1/sqrt(colsum), "*")
- CCA$u.eig <- sweep(CCA$u, 2, sol$d[1:rank], "*")
- CCA$v.eig <- sweep(CCA$v, 2, sol$d[1:rank], "*")
- CCA$wa.eig <- sweep(Xbar %*% sol$v[, 1:rank, drop = FALSE],
- 1, 1/sqrt(rowsum), "*")
- CCA$wa <- sweep(CCA$wa.eig, 2, 1/sol$d[1:rank], "*")
+ wa.eig <- sweep(Xbar %*% sol$v[, 1:rank, drop = FALSE],
+ 1, 1/sqrt(rowsum), "*")
+ CCA$wa <- sweep(wa.eig, 2, 1/sol$d[1:rank], "*")
oo <- Q$pivot
if (!is.null(pCCA$rank))
oo <- oo[-(1:pCCA$rank)] - ncol(Z.r)
@@ -92,15 +90,14 @@
QR = Q, Xbar = Xbar)
u <- matrix(0, nrow=nrow(sol$u), ncol=0)
v <- matrix(0, nrow=nrow(sol$v), ncol=0)
- CCA$u <- CCA$u.eig <- CCA$wa <- CCA$wa.eig <- u
- CCA$v <- CCA$v.eig <- v
+ CCA$u <- CCA$wa <- u
+ CCA$v <- v
CCA$biplot <- matrix(0, 0, 0)
CCA$alias <- colnames(Y.r)
}
Xbar <- qr.resid(Q, Xbar)
if (exists("exclude.spec")) {
attr(CCA$v, "na.action") <- exclude.spec
- attr(CCA$v.eig, "na.action") <- exclude.spec
}
}
@@ -119,8 +116,6 @@
1, 1/sqrt(rowsum), "*")
CA$v <- sweep(as.matrix(sol$v[, 1:rank, drop = FALSE]),
1, 1/sqrt(colsum), "*")
- CA$u.eig <- sweep(CA$u, 2, sol$d[1:rank], "*")
- CA$v.eig <- sweep(CA$v, 2, sol$d[1:rank], "*")
CA$rank <- rank
CA$tot.chi <- sum(CA$eig)
CA$Xbar <- Xbar
@@ -128,12 +123,11 @@
} else { # zero rank: no residual component
CA <- list(eig = 0, rank = rank, tot.chi = 0,
Xbar = Xbar)
- CA$u <- CA$u.eig <- matrix(0, nrow(sol$u), 0)
- CA$v <- CA$v.eig <- matrix(0, nrow(sol$v), 0)
+ CA$u <- matrix(0, nrow(sol$u), 0)
+ CA$v <- matrix(0, nrow(sol$v), 0)
}
if (exists("exclude.spec")) {
attr(CA$v, "na.action") <- exclude.spec
- attr(CA$v.eig, "na.action") <- exclude.spec
}
call <- match.call()
call[[1]] <- as.name("cca")
Modified: pkg/vegan/R/rda.default.R
===================================================================
--- pkg/vegan/R/rda.default.R 2014-10-07 18:18:56 UTC (rev 2894)
+++ pkg/vegan/R/rda.default.R 2014-10-08 07:43:04 UTC (rev 2895)
@@ -51,13 +51,9 @@
CCA <- list(eig = sol$d[1:rank]^2)
CCA$u <- as.matrix(sol$u)[, 1:rank, drop = FALSE]
CCA$v <- as.matrix(sol$v)[, 1:rank, drop = FALSE]
- CCA$u.eig <- sweep(as.matrix(CCA$u), 2, sol$d[1:rank],
- "*")
- CCA$v.eig <- sweep(as.matrix(CCA$v), 2, sol$d[1:rank],
- "*")
- CCA$wa.eig <- Xbar %*% sol$v[, 1:rank, drop = FALSE]
- CCA$wa.eig <- CCA$wa.eig/sqrt(NR)
- CCA$wa <- sweep(CCA$wa.eig, 2, 1/sol$d[1:rank], "*")
+ wa.eig <- Xbar %*% sol$v[, 1:rank, drop = FALSE]
+ wa.eig <- wa.eig/sqrt(NR)
+ CCA$wa <- sweep(wa.eig, 2, 1/sol$d[1:rank], "*")
oo <- Q$pivot
if (!is.null(pCCA$rank))
oo <- oo[-(1:pCCA$rank)] - ncol(Z.r)
@@ -78,8 +74,8 @@
QR = Q, Xbar = Xbar)
u <- matrix(0, nrow=nrow(sol$u), ncol=0)
v <- matrix(0, nrow=nrow(sol$v), ncol=0)
- CCA$u <- CCA$u.eig <- CCA$wa <- CCA$wa.eig <- u
- CCA$v <- CCA$v.eig <- v
+ CCA$u <- CCA$wa <- u
+ CCA$v <- v
CCA$biplot <- matrix(0, 0, 0)
CCA$alias <- colnames(Y.r)
}
@@ -98,18 +94,14 @@
CA <- list(eig = (sol$d[1:rank]^2))
CA$u <- as.matrix(sol$u)[, 1:rank, drop = FALSE]
CA$v <- as.matrix(sol$v)[, 1:rank, drop = FALSE]
- CA$u.eig <- sweep(as.matrix(CA$u), 2, sol$d[1:rank],
- "*")
- CA$v.eig <- sweep(as.matrix(CA$v), 2, sol$d[1:rank],
- "*")
CA$rank <- rank
CA$tot.chi <- sum(CA$eig)
CA$Xbar <- Xbar
} else { # zero rank: no residual component
CA <- list(eig = 0, rank = rank, tot.chi = 0,
Xbar = Xbar)
- CA$u <- CA$u.eig <- matrix(0, nrow(sol$u), 0)
- CA$v <- CA$v.eig <- matrix(0, nrow(sol$v), 0)
+ CA$u <- matrix(0, nrow(sol$u), 0)
+ CA$v <- matrix(0, nrow(sol$v), 0)
}
call <- match.call()
call[[1]] <- as.name("rda")
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-10-07 18:18:56 UTC (rev 2894)
+++ pkg/vegan/inst/NEWS.Rd 2014-10-08 07:43:04 UTC (rev 2895)
@@ -2,6 +2,120 @@
\title{vegan News}
\encoding{UTF-8}
+\section{Changes in version 2.2-0}{
+
+ \subsection{GENERAL}{
+ \itemize{
+
+ \item Parallel processing
+
+ \item Restricted permutations
+
+ \item New null models
+
+ } %end itemize
+ } % end general
+
+ \subsection{INSTALLATION}{
+ \itemize{
+
+ \item Changes in NAMESPACE and passes tests
+
+ \item Split \pkg{vegan3d}
+
+ } %end itemize
+ } % end installation
+
+ \subsection{NEW FUNCTIONS}{
+ \itemize{
+
+ \item Dispersion weighting \code{dispweight} plus a new method
+ for generalized dispersion weigthing \code{gdispweight}.
+
+ \item \code{hclust} support functions \code{reorder}, \code{rev}
+ and \code{scores}.
+
+ \item \code{permustats} to extract and inspect permutation
+ results with support functions \code{summary}, \code{density},
+ \code{densityplot}, \code{qqnorm} and \code{qqmath}.
+
+ \item \code{stressplot} functions.
+
+ } % end itemize
+ } % end new functions
+
+ \subsection{BUG FIXES}{
+ } % end bug fixes
+
+ \subsection{NEW FEATURES}{
+ \itemize{
+
+ \item \code{anova.cca} functions re-written, and added an option
+ of analysing a sequence of models against each other.
+
+ \item \code{simulate} functions for \code{cca} and \code{rda}
+ can return several simulations in a \code{nullmodel} compatible
+ object. The functions can produce simulations with correlated
+ errors (also for \code{capscale}).
+
+ \item \code{bioenv} can use Manhattan, Gower and Mahalanobis
+ distances in addition to Euclidean. New helper function
+ \code{bioenvdist} can extract the dissimilarities applied in
+ best model or any other model.
+
+ \item \code{MDSrotate} can rotate to multidimensional target.
+
+ \item \code{nestednodf} gained new option for defining weighted
+ nestedness statistic.
+
+ \item \code{rankindex} can use Manhattan, Gower and Mahalanobis
+ distance in addition to Euclidean.
+
+ \item \code{spantree} gained a support function \code{as.hclust}
+ to change the minimum spannig tree into an \code{hclust} tree.
+
+ \item \code{fitspecaccum} can do weighted analysis.
+
+ \item \code{vegdist} gained Mahalanobis distance.
+
+ \item Nomenclature updated in plant community
+ data. \code{varespec} and \code{dune} use 8-character names (4
+ from genus + 4 from species epithet). New data set on
+ phylogenetic distances for \code{dune}.
+
+ \item User configurable plots for \code{rarecurve}.
+
+ } %end itemize
+ } % end new features
+
+ \subsection{DEPRECATED AND DEFUNCT}{
+ \itemize{
+
+ \item \code{strata} deprecated in permutations. It is still
+ accepted but will be phased out in next releases. Use \code{how}
+ of \pkg{permute} package.
+
+ \item \code{cca}, \code{rda} and \code{capscale} do not return
+ scores scaled by eigenvalues: use \code{scores} function to
+ extract scaled results.
+
+ \item \code{commsimulator} is deprecated. Replace
+ \code{commsimulator(x, method)} with \code{simulate(nullmodel(x,
+ method))}.
+
+ \item \code{density} and \code{densityplot} for permutation
+ results: use \code{density(permustats(
Author: jarioksa
Date: 2014-10-09 10:25:19 +0200 (Thu, 09 Oct 2014)
New Revision: 2896
Modified:
pkg/vegan/inst/ChangeLog
pkg/vegan/inst/NEWS.Rd
Log:
Squashed commit of the following:
commit 53c612015bd1acbb54f189800c62f48c48744ca7
Author: Jari Oksanen
Date: Wed Oct 8 14:27:22 2014 +0300
ChangeLog heading to the github time
commit af070de7f5246f53e732d6ca86c9137aa2cc77be
Author: Jari Oksanen
Date: Wed Oct 8 14:19:08 2014 +0300
compile ChangeLog from git logs, long afterwards
I am not sure if we need to keep ChangeLog. This needs a bit care,
because ChangeLog is essentially linear and git is a web. However,
I collected major changes from git logs to still have a ChangeLog
of major events.
commit a143de91c4d840952bdcb638119bfb9245b148f1
Author: Jari Oksanen
Date: Wed Oct 8 11:05:18 2014 +0300
more NEWS picked from the ChangeLog
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2014-10-08 07:43:04 UTC (rev 2895)
+++ pkg/vegan/inst/ChangeLog 2014-10-09 08:25:19 UTC (rev 2896)
@@ -1,9 +1,38 @@
-$Date$
+VEGAN DEVEL VERSIONS at https://github.com/vegandevs/vegan
-VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
+Version 2.1-43 (opened September 11, 2014)
-Version 2.1-43
+ * cca, rda, capscale: remove u.eig, v.eig and wa.eig items or
+ scores scaled by eigenvectors. We have had a warning of their
+ eventual removal since vegan 1.6-8, and now we finally did
+ so. Scaling of scores happens when scores() function access
+ normalized score items of the results.
+ * commsimulator: commented out deprecation warning at the moment,
+ because this triggered warnings in CRAN packages bipartite and
+ metacom. Contacted the maintainers of these packages, and will put
+ back the warning in 2.2-1.
+
+ * getPermuteMatrix: works also when 'strata' are
+ missing. Triggered an error in CRAN package mpmcorrelogram.
+
+ * permustats: new function to extract permutation results from
+ vegan objects, with support functions summary, density,
+ densityplot, qqnorm and qqmath. Deprecated previous density and
+ densityplot methods directly accessing the same results.
+
+ * ordirgl, ordiplot3d: 3D functions using rgl or scatterplot3d
+ packages were removed from vegan and moved to a new CRAN package
+ vegan3d (released Oct 7, 2014).
+
+ * scores.hclust: combined documentation with other hclust methods.
+
+ * scoverage: removed from vegan.
+
+ * dispweight: veganified so that uses nullmodels. Added
+ gdispweight(): a new generalized method taking any glm() formula
+ instead of one grouping.
+
* betadisper Permutation tests via the `permutest()` method
are now parallelised. The number of cores to parallelise over
is specified by argument `parallel` in common with the
@@ -13,8 +42,13 @@
was specified using `control` which is not an argument to the
`permutest()` method for `betadisper()`.
-Version 2.1-42 (opened September 4, 2014)
+ * ccanova: removed from vegan. These were backup functions of old
+ anova.cca, and were completely rewritten for new vegan.
+ * metaMDSrotate: made defunct (replaced with MDSrotate).
+
+Version 2.1-42 (closed September 11, 2014)
+
* Opened a new version to prepare release 2.2-0.
* Moved main development from R-Forge to GitHub.com.
@@ -25,9 +59,9 @@
* getPermuteMatrix: routines have a common API based on the new
function.
+
+Version 2.1-41 (closed September 4, 2014)
-Version 2.1-41 (closed September 4, 2014)
-
* ordiellipse, ordihull, ordispider: can now handle (omit) NA
cases in 'groups'. They were able to omit to NA cases in scores,
but having NA in 'groups' triggered really cryptic error
@@ -69,7 +103,7 @@
* cascadeKM: Calinski index for one group will now be NA instead
of randomly chosen Inf, -Inf or NaN which can cause confusion (see
- http://stackoverflow.com/questions/21022848/r-produces-different-result-after-io-on-file
+ http://stackoverflow.com/questions/21022848/r-produces-different-result-after-io-on-file
* ordiellipse: failed if all points were on a line. Now handles
these cases by drawing a line trhough the points, and issuing a
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-10-08 07:43:04 UTC (rev 2895)
+++ pkg/vegan/inst/NEWS.Rd 2014-10-09 08:25:19 UTC (rev 2896)
@@ -45,6 +45,20 @@
} % end new functions
\subsection{BUG FIXES}{
+ \itemize{
+
+ \item \code{ordiellipse} can handle points exactly on a line,
+ including only two points.
+
+ \item plotting \code{radfit} results for several species failed if
+ any of the communities had no species or had only one species.
+
+ \item \code{RsquareAdj} for \code{capscale} with negative
+ eigenvalues will now report \code{NA}.
+
+ \item \code{simper} failed when a group had only a single member.
+
+ }% end itemize
} % end bug fixes
\subsection{NEW FEATURES}{
@@ -63,11 +77,20 @@
\code{bioenvdist} can extract the dissimilarities applied in
best model or any other model.
+ \item \code{cascadeKM} of only one group will be \code{NA} instead
+ of a random value.
+
\item \code{MDSrotate} can rotate to multidimensional target.
\item \code{nestednodf} gained new option for defining weighted
nestedness statistic.
+ \item \code{ordiellipse}, \code{ordihull} and \code{ordiellipse}
+ can handle missing values in \code{groups}.
+
+ \item \code{ordispider} can now use spatial medians instead of
+ means.
+
\item \code{rankindex} can use Manhattan, Gower and Mahalanobis
distance in addition to Euclidean.
@@ -76,6 +99,14 @@
\item \code{fitspecaccum} can do weighted analysis.
+ \item \code{tabasco} uses now \code{reorder.hclust} for
+ \code{hclust} for better ordering than previously when it cast
+ trees to \code{dendrogram} objects.
+
+ \item \code{treedive} and \code{treedist} default now to
+ \code{match.force = TRUE} and can be silenced with
+ \code{verbose = FALSE}.
+
\item \code{vegdist} gained Mahalanobis distance.
\item Nomenclature updated in plant community
From noreply at r-forge.r-project.org Sat Oct 11 07:31:35 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sat, 11 Oct 2014 07:31:35 +0200 (CEST)
Subject: [Vegan-commits] r2897 - www
Message-ID: <20141011053135.1A7801879EB@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-11 07:31:34 +0200 (Sat, 11 Oct 2014)
New Revision: 2897
Modified:
www/NEWS.html
Log:
update NEWS
Modified: www/NEWS.html
===================================================================
--- www/NEWS.html 2014-10-09 08:25:19 UTC (rev 2896)
+++ www/NEWS.html 2014-10-11 05:31:34 UTC (rev 2897)
@@ -69,6 +69,24 @@
BUG FIXES
+
+
+-
ordiellipse can handle points exactly on a line,
+including only two points.
+
+
+ plotting radfit results for several species failed if
+any of the communities had no species or had only one species.
+
+
+-
RsquareAdj for capscale with negative
+eigenvalues will now report NA.
+
+
+-
simper failed when a group had only a single member.
+
+
+
@@ -83,7 +101,8 @@
simulate functions for cca and rda
can return several simulations in a nullmodel compatible
object. The functions can produce simulations with correlated
-errors (also for capscale).
+errors (also for capscale) in parametric simulation with
+Gaussian error.
bioenv can use Manhattan, Gower and Mahalanobis
@@ -92,24 +111,55 @@
best model or any other model.
+ cascadeKM of only one group will be NA instead
+of a random value.
+
+
+ metaMDS(..., trace = 2) will show convergence
+information with the default monoMDS engine.
+
+
MDSrotate can rotate to multidimensional target.
- nestednodf gained new option for defining weighted
-nestedness statistic.
+
nestednodf gained new option for defining
+alternatives of weighted nestedness statistic.
+ ordiellipse, ordihull and ordiellipse
+can handle missing values in groups.
+
+
+ ordispider can now use spatial medians instead of
+means.
+
+
rankindex can use Manhattan, Gower and Mahalanobis
distance in addition to Euclidean.
+ User can set colours and line types in unction
+rarecurve for plotting rarefaction curves.
+
+
spantree gained a support function as.hclust
to change the minimum spannig tree into an hclust tree.
- fitspecaccum can do weighted analysis.
+
fitspecaccum can do weighted analysis. Gained
+lines method.
+ tabasco uses now reorder.hclust for
+hclust for better ordering than previously when it cast
+trees to dendrogram objects.
+
+
+ treedive and treedist default now to
+match.force = TRUE and can be silenced with
+verbose = FALSE.
+
+
vegdist gained Mahalanobis distance.
From noreply at r-forge.r-project.org Sun Oct 12 18:07:27 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Sun, 12 Oct 2014 18:07:27 +0200 (CEST)
Subject: [Vegan-commits] r2898 - www
Message-ID: <20141012160727.53E451879FF@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-12 18:07:26 +0200 (Sun, 12 Oct 2014)
New Revision: 2898
Modified:
www/NEWS.html
Log:
NEWS
Modified: www/NEWS.html
===================================================================
--- www/NEWS.html 2014-10-11 05:31:34 UTC (rev 2897)
+++ www/NEWS.html 2014-10-12 16:07:26 UTC (rev 2898)
@@ -16,13 +16,72 @@
- Parallel processing
+
Several vegan functions can now use parallel
+processing for slow and repeating calculations. All these
+functions have argument parallel. The argument can be an
+integer giving the number of parallel processes. In unix-alikes
+(Mac OS, Linux) this will launch "multicore" processing
+and in Windows it will set up "snow" clusters as desribed
+in the documentation of parallel package. If option
+"mc.cores" is set to an integer > 1, this will be used to
+automatically start parallel processing. Finally, the argument
+can also be a previously set up "snow" cluster which will
+be used both in Windows and in unix-alikes. Vegan vignette
+on Design decision explains the implementation (use
+vegandocs("decission"), and parallel package has more
+extensive documentation on parallel processing in R.
+The following function use parallel processing in analysing
+permutatin statistics: adonis, anosim,
+anova.cca (and permutest.cca), mantel (and
+mantel.partial), mrpp, permutest.betadisper
+and simper. In addition, bioenv can compare
+several candidate sets of models in paralle, metaMDS can
+launch several random starts in parallel, and oecosimu
+can evaluate test statistics for several null models in
+parallel.
+
- Restricted permutations
+
All permutation tests are based on the permute
+package which offers strong tools for restricted
+permutation. All these functions have argument
+permutations. The default usage of simple non-restricted
+permutations is achieved by giving a single integer number as
+its argument. Restricted permutations can be defined using the
+how function of the permute package. Finally, the
+argument can be a permutation matrix where rows define
+permutations. It is possible to use external or user constructed
+permutations.
+See help(permutations) for a brief introduction on
+permutations in vegan, and permute package for the
+full documention. The vignette of the permute package can
+be read from vegan with command
+vegandocs("permutations").
+
+The following functions use the permute package:
+CCorA, adonis, anosim, anova.cca
+(plus associated permutest.cca, add1.cca,
+drop1.cca, ordistep, ordiR2step),
+envfit (plus associated factorfit and
+vectorfit), mantel (and mantel.partial),
+mrpp, mso, permutest.betadisper,
+protest and simper.
+
- New null models
+
Community null model generation has been completely
+redesigned and rewritten. The communities are constructed with
+new nullmodel function and defined in a low level
+commsim function. The actual null models are generated
+with a simulate function that builds an array of null
+models. The new null models include a wide array of quantitative
+models in addition to the old binary models, and users can plug
+in their own generating functions. The basic tool invoking and
+analysing null models is oecosimu. The null models are
+often used only for the analysis of nestedness, but the
+implementation in oecosimu allows analysing any
+statistic, and null models are better seen as an alternative to
+permutation tests.
@@ -33,10 +92,15 @@
- Changes in NAMESPACE and passes tests
+
-
vegan package dependencies and namespace imports
+were adapted to changes in R, and no more trigger warnings and
+notes in package tests.
- Split vegan3d
+
Three-dimensional ordination graphics using
+scatterplot3d for static plots and rgl for dynamic
+plots were removed from vegan and moved to a companion
+package vegan3d. The package is available in CRAN.
@@ -47,20 +111,44 @@
- Dispersion weighting dispweight plus a new method
-for generalized dispersion weigthing gdispweight.
+
Function dispweight implements dispersion weighting
+of Clarke et al. (Marine Ecology Progress Series, 320,
+11–27). In addition, we implemented a new method for
+generalized dispersion weighting gdispweight. Both
+methods downweight species that are significantly
+over-dispersed.
--
hclust support functions reorder, rev
-and scores.
+
New hclust support functions reorder,
+rev and scores. Functions reorder and
+rev are similar as these functions for dendrogram
+objects. However, reorder can use (and defaults to)
+weighted mean. In weighted mean the node average is always the
+mean of member leaves, whereas the dendrogram uses always
+the unweighted means of joined branches.
-
permustats to extract and inspect permutation
results with support functions summary, density,
-densityplot, qqnorm and qqmath.
+densityplot, qqnorm and qqmath. The
+density and qqnorm are standard R tools that
+only work with one statistic, and densityplot and
+qqmath are lattice graphics that work with
+univariate and multivariate statistics. The results of following
+functions can be extracted: anosim, adonis,
+mantel (and mantel.partial), mrpp,
+oecosimu, permustest.cca (but not the
+corresponding anova methods),
+permutest.betadisper, and protest.
--
stressplot functions.
+
-
stressplot functions display the ordination
+distances at given number of dimensions against original
+distances. These are a generalization of stressplot for
+metaMDS, and always use the inherent distances of each
+ordination method. The functions are available for the results
+capscale, cca, princomp, prcomp,
+rda, and wcmdscale.
@@ -71,6 +159,10 @@
+-
cascadeKM of only one group will be NA instead
+of a random value.
+
+
-
ordiellipse can handle points exactly on a line,
including only two points.
@@ -80,7 +172,8 @@
RsquareAdj for capscale with negative
-eigenvalues will now report NA.
+eigenvalues will now report NA instead of using biased
+method of rda results.
simper failed when a group had only a single member.
@@ -94,8 +187,11 @@
--
anova.cca functions re-written, and added an option
-of analysing a sequence of models against each other.
+
-
anova.cca functions were re-written to use the
+permute package. Old results may not be exactly
+reproduced, and models with missing data may fail in several
+cases. There is a new option of analysing a sequence of models
+against each other.
-
simulate functions for cca and rda
@@ -106,24 +202,29 @@
-
bioenv can use Manhattan, Gower and Mahalanobis
-distances in addition to Euclidean. New helper function
-bioenvdist can extract the dissimilarities applied in
-best model or any other model.
+distances in addition to the default Euclidean. New helper
+function bioenvdist can extract the dissimilarities
+applied in best model or any other model.
--
cascadeKM of only one group will be NA instead
-of a random value.
-
-
-
metaMDS(..., trace = 2) will show convergence
information with the default monoMDS engine.
--
MDSrotate can rotate to multidimensional target.
+
Function MDSrotate can rotate a k-dimensional
+ordination to k-1 variables. When these variables are
+correlated (like usually is the case), the vectors can also be
+correlated to previously rotated dimensions, but will be
+uncorrelated to all later ones.
--
nestednodf gained new option for defining
-alternatives of weighted nestedness statistic.
+
-
vegan 2.0-10 changed the weighted nestednodf
+so that weighted analysis of binary data was equivalent to
+binary analysis. However, this broke the equivalence to the
+original method. Now the function has an argument wbinary
+to select the method of analysis. The problem was reported and a
+fix submitted by Vanderlei Debastiani (Universidade Federal do
+Rio Grande do Sul, Brasil).
-
ordiellipse, ordihull and ordiellipse
@@ -135,7 +236,7 @@
-
rankindex can use Manhattan, Gower and Mahalanobis
-distance in addition to Euclidean.
+distance in addition to the default Euclidean.
User can set colours and line types in unction
@@ -151,8 +252,8 @@
-
tabasco uses now reorder.hclust for
-hclust for better ordering than previously when it cast
-trees to dendrogram objects.
+hclust object for better ordering than previously when it
+cast trees to dendrogram objects.
-
treedive and treedist default now to
@@ -163,10 +264,13 @@
-
vegdist gained Mahalanobis distance.
- Nomenclature updated in plant community
-data. varespec and dune use 8-character names (4
+
Nomenclature updated in plant community data with the help
+of Taxonstand and taxize packages. The taxonomy of
+the dune data was adapted to the same sources and APG
+III. varespec and dune use 8-character names (4
from genus + 4 from species epithet). New data set on
-phylogenetic distances for dune.
+phylogenetic distances for dune was extracted from Zanne
+et al. (Nature, 2014).
User configurable plots for rarecurve.
@@ -180,7 +284,7 @@
--
strata deprecated in permutations. It is still
+
-
strata are deprecated in permutations. It is still
accepted but will be phased out in next releases. Use how
of permute package.
@@ -196,13 +300,9 @@
-
density and densityplot for permutation
-results: use density(permustats(<permutation-object)).
+results: use permustats with its density and
+densityplot method.
-
--
ordirgl with its support functions, other rgl
-functions and ordiplot3d were moved to the vegan3d
-package.
-
From noreply at r-forge.r-project.org Mon Oct 13 10:59:00 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Mon, 13 Oct 2014 10:59:00 +0200 (CEST)
Subject: [Vegan-commits] r2899 - in pkg/vegan: . inst
Message-ID: <20141013085900.3F2481873AC@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-13 10:58:59 +0200 (Mon, 13 Oct 2014)
New Revision: 2899
Added:
pkg/vegan/.gitattributes
pkg/vegan/appveyor.yml
Modified:
pkg/vegan/.Rbuildignore
pkg/vegan/README.md
pkg/vegan/inst/NEWS.Rd
Log:
Squashed commit of the following:
commit 6b293572804d0dc653a53e5a847524b0fcc673ff
Merge: 4d10697 e6fedc7
Author: Jari Oksanen
Date: Sun Oct 12 19:04:32 2014 +0300
Merge pull request #55 from jarioksa/NEWS
News
commit e6fedc707a3d0d2503d410a31af2579463d204be
Author: Jari Oksanen
Date: Sun Oct 12 19:01:27 2014 +0300
First draft of complete release NEWS
commit 4d10697b90ada025c36b0d3022a5dad2841dc2e6
Author: Gavin Simpson
Date: Sat Oct 11 14:00:07 2014 -0600
add appveyor badge to README.md
commit 769d9a145770f7450e5f0cbf05f3c321f25c0388
Author: Gavin Simpson
Date: Sat Oct 11 13:58:04 2014 -0600
add appveyor CI support
commit f988022a5335011a013f933c688a973b2d717e21
Author: Jari Oksanen
Date: Sat Oct 11 11:04:37 2014 +0300
more flesh to NEWS
commit 0d019be1a56809519f527ea2a22ef7de3af44240
Author: Jari Oksanen
Date: Sat Oct 11 08:57:27 2014 +0300
more flesh to the NEWS skeleton
commit 93fd83cc7f7723c78b0b26676608e092cd994901
Author: Jari Oksanen
Date: Sat Oct 11 08:28:46 2014 +0300
Pick NEWS from diff -U2 vegan_2.0-10/R vegan_2.2-0/R
commit 16d74e39dd745c445cb862aae860ddbc83d25a57
Author: Jari Oksanen
Date: Tue Oct 7 21:06:02 2014 +0300
skeleton of NEWS about vegan 2.2-0
Modified: pkg/vegan/.Rbuildignore
===================================================================
--- pkg/vegan/.Rbuildignore 2014-10-12 16:07:26 UTC (rev 2898)
+++ pkg/vegan/.Rbuildignore 2014-10-13 08:58:59 UTC (rev 2899)
@@ -1,3 +1,5 @@
LICENSE
^\.travis\.yml$
+^travis-tool\.sh
+^appveyor\.yml$
Added: pkg/vegan/.gitattributes
===================================================================
--- pkg/vegan/.gitattributes (rev 0)
+++ pkg/vegan/.gitattributes 2014-10-13 08:58:59 UTC (rev 2899)
@@ -0,0 +1,5 @@
+* text=auto
+data/* binary
+src/* text=lf
+R/* text=lf
+
Modified: pkg/vegan/README.md
===================================================================
--- pkg/vegan/README.md 2014-10-12 16:07:26 UTC (rev 2898)
+++ pkg/vegan/README.md 2014-10-13 08:58:59 UTC (rev 2899)
@@ -4,4 +4,4 @@
Linux | Windows
------------|------------
-[](https://travis-ci.org/vegandevs/vegan) |
+[](https://travis-ci.org/vegandevs/vegan) | [](https://ci.appveyor.com/project/gavinsimpson/vegan/branch/master)
Added: pkg/vegan/appveyor.yml
===================================================================
--- pkg/vegan/appveyor.yml (rev 0)
+++ pkg/vegan/appveyor.yml 2014-10-13 08:58:59 UTC (rev 2899)
@@ -0,0 +1,44 @@
+# DO NOT CHANGE the "init" and "install" sections below
+
+environment:
+ R_CHECK_ARGS: --no-build-vignettes --no-manual
+
+# Download script file from GitHub
+init:
+ ps: |
+ $ErrorActionPreference = "Stop"
+ Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
+ Import-Module '..\appveyor-tool.ps1'
+
+install:
+ ps: Bootstrap
+
+# Adapt as necessary starting from here
+
+build_script:
+ - travis-tool.sh install_deps
+
+test_script:
+ - travis-tool.sh run_tests
+
+on_failure:
+ - travis-tool.sh dump_logs
+
+artifacts:
+ - path: '*.Rcheck\**\*.log'
+ name: Logs
+
+ - path: '*.Rcheck\**\*.out'
+ name: Logs
+
+ - path: '*.Rcheck\**\*.fail'
+ name: Logs
+
+ - path: '*.Rcheck\**\*.Rout'
+ name: Logs
+
+ - path: '\*_*.tar.gz'
+ name: Bits
+
+ - path: '\*_*.zip'
+ name: Bits
Modified: pkg/vegan/inst/NEWS.Rd
===================================================================
--- pkg/vegan/inst/NEWS.Rd 2014-10-12 16:07:26 UTC (rev 2898)
+++ pkg/vegan/inst/NEWS.Rd 2014-10-13 08:58:59 UTC (rev 2899)
@@ -7,11 +7,70 @@
\subsection{GENERAL}{
\itemize{
- \item Parallel processing
+ \item Several \pkg{vegan} functions can now use parallel
+ processing for slow and repeating calculations. All these
+ functions have argument \code{parallel}. The argument can be an
+ integer giving the number of parallel processes. In unix-alikes
+ (Mac OS, Linux) this will launch \code{"multicore"} processing
+ and in Windows it will set up \code{"snow"} clusters as desribed
+ in the documentation of \pkg{parallel} package. If \code{option}
+ \code{"mc.cores"} is set to an integer > 1, this will be used to
+ automatically start parallel processing. Finally, the argument
+ can also be a previously set up \code{"snow"} cluster which will
+ be used both in Windows and in unix-alikes. \pkg{Vegan} vignette
+ on Design decision explains the implementation (use
+ \code{vegandocs("decission")}, and \pkg{parallel} package has more
+ extensive documentation on parallel processing in \R.
- \item Restricted permutations
+ The following function use parallel processing in analysing
+ permutatin statistics: \code{adonis}, \code{anosim},
+ \code{anova.cca} (and \code{permutest.cca}), \code{mantel} (and
+ \code{mantel.partial}), \code{mrpp}, \code{permutest.betadisper}
+ and \code{simper}. In addition, \code{bioenv} can compare
+ several candidate sets of models in paralle, \code{metaMDS} can
+ launch several random starts in parallel, and \code{oecosimu}
+ can evaluate test statistics for several null models in
+ parallel.
- \item New null models
+ \item All permutation tests are based on the \pkg{permute}
+ package which offers strong tools for restricted
+ permutation. All these functions have argument
+ \code{permutations}. The default usage of simple non-restricted
+ permutations is achieved by giving a single integer number as
+ its argument. Restricted permutations can be defined using the
+ \code{how} function of the \pkg{permute} package. Finally, the
+ argument can be a permutation matrix where rows define
+ permutations. It is possible to use external or user constructed
+ permutations.
+
+ See \code{help(permutations)} for a brief introduction on
+ permutations in \pkg{vegan}, and \pkg{permute} package for the
+ full documention. The vignette of the \pkg{permute} package can
+ be read from \pkg{vegan} with command
+ \code{vegandocs("permutations")}.
+
+ The following functions use the \pkg{permute} package:
+ \code{CCorA}, \code{adonis}, \code{anosim}, \code{anova.cca}
+ (plus associated \code{permutest.cca}, \code{add1.cca},
+ \code{drop1.cca}, \code{ordistep}, \code{ordiR2step}),
+ \code{envfit} (plus associated \code{factorfit} and
+ \code{vectorfit}), \code{mantel} (and \code{mantel.partial}),
+ \code{mrpp}, \code{mso}, \code{permutest.betadisper},
+ \code{protest} and \code{simper}.
+
+ \item Community null model generation has been completely
+ redesigned and rewritten. The communities are constructed with
+ new \code{nullmodel} function and defined in a low level
+ \code{commsim} function. The actual null models are generated
+ with a \code{simulate} function that builds an array of null
+ models. The new null models include a wide array of quantitative
+ models in addition to the old binary models, and users can plug
+ in their own generating functions. The basic tool invoking and
+ analysing null models is \code{oecosimu}. The null models are
+ often used only for the analysis of nestedness, but the
+ implementation in \code{oecosimu} allows analysing any
+ statistic, and null models are better seen as an alternative to
+ permutation tests.
} %end itemize
} % end general
@@ -19,9 +78,14 @@
\subsection{INSTALLATION}{
\itemize{
- \item Changes in NAMESPACE and passes tests
+ \item \pkg{vegan} package dependencies and namespace imports
+ were adapted to changes in \R, and no more trigger warnings and
+ notes in package tests.
- \item Split \pkg{vegan3d}
+ \item Three-dimensional ordination graphics using
+ \pkg{scatterplot3d} for static plots and \pkg{rgl} for dynamic
+ plots were removed from \pkg{vegan} and moved to a companion
+ package \pkg{vegan3d}. The package is available in CRAN.
} %end itemize
} % end installation
@@ -29,17 +93,41 @@
\subsection{NEW FUNCTIONS}{
\itemize{
- \item Dispersion weighting \code{dispweight} plus a new method
- for generalized dispersion weigthing \code{gdispweight}.
+ \item Function \code{dispweight} implements dispersion weighting
+ of Clarke et al. (\emph{Marine Ecology Progress Series}, 320,
+ 11--27). In addition, we implemented a new method for
+ generalized dispersion weighting \code{gdispweight}. Both
+ methods downweight species that are significantly
+ over-dispersed.
- \item \code{hclust} support functions \code{reorder}, \code{rev}
- and \code{scores}.
+ \item New \code{hclust} support functions \code{reorder},
+ \code{rev} and \code{scores}. Functions \code{reorder} and
+ \code{rev} are similar as these functions for \code{dendrogram}
+ objects. However, \code{reorder} can use (and defaults to)
+ weighted mean. In weighted mean the node average is always the
+ mean of member leaves, whereas the \code{dendrogram} uses always
+ the unweighted means of joined branches.
\item \code{permustats} to extract and inspect permutation
results with support functions \code{summary}, \code{density},
- \code{densityplot}, \code{qqnorm} and \code{qqmath}.
+ \code{densityplot}, \code{qqnorm} and \code{qqmath}. The
+ \code{density} and \code{qqnorm} are standard \R{} tools that
+ only work with one statistic, and \code{densityplot} and
+ \code{qqmath} are \pkg{lattice} graphics that work with
+ univariate and multivariate statistics. The results of following
+ functions can be extracted: \code{anosim}, \code{adonis},
+ \code{mantel} (and \code{mantel.partial}), \code{mrpp},
+ \code{oecosimu}, \code{permustest.cca} (but not the
+ corresponding \code{anova} methods),
+ \code{permutest.betadisper}, and \code{protest}.
- \item \code{stressplot} functions.
+ \item \code{stressplot} functions display the ordination
+ distances at given number of dimensions against original
+ distances. These are a generalization of \code{stressplot} for
+ \code{metaMDS}, and always use the inherent distances of each
+ ordination method. The functions are available for the results
+ \code{capscale}, \code{cca}, \code{princomp}, \code{prcomp},
+ \code{rda}, and \code{wcmdscale}.
} % end itemize
} % end new functions
@@ -47,6 +135,9 @@
\subsection{BUG FIXES}{
\itemize{
+ \item \code{cascadeKM} of only one group will be \code{NA} instead
+ of a random value.
+
\item \code{ordiellipse} can handle points exactly on a line,
including only two points.
@@ -54,7 +145,8 @@
any of the communities had no species or had only one species.
\item \code{RsquareAdj} for \code{capscale} with negative
- eigenvalues will now report \code{NA}.
+ eigenvalues will now report \code{NA} instead of using biased
+ method of \code{rda} results.
\item \code{simper} failed when a group had only a single member.
@@ -64,26 +156,39 @@
\subsection{NEW FEATURES}{
\itemize{
- \item \code{anova.cca} functions re-written, and added an option
- of analysing a sequence of models against each other.
+ \item \code{anova.cca} functions were re-written to use the
+ \pkg{permute} package. Old results may not be exactly
+ reproduced, and models with missing data may fail in several
+ cases. There is a new option of analysing a sequence of models
+ against each other.
\item \code{simulate} functions for \code{cca} and \code{rda}
can return several simulations in a \code{nullmodel} compatible
object. The functions can produce simulations with correlated
- errors (also for \code{capscale}).
+ errors (also for \code{capscale}) in parametric simulation with
+ Gaussian error.
\item \code{bioenv} can use Manhattan, Gower and Mahalanobis
- distances in addition to Euclidean. New helper function
- \code{bioenvdist} can extract the dissimilarities applied in
- best model or any other model.
+ distances in addition to the default Euclidean. New helper
+ function \code{bioenvdist} can extract the dissimilarities
+ applied in best model or any other model.
- \item \code{cascadeKM} of only one group will be \code{NA} instead
- of a random value.
+ \item \code{metaMDS(..., trace = 2)} will show convergence
+ information with the default \code{monoMDS} engine.
- \item \code{MDSrotate} can rotate to multidimensional target.
+ \item Function \code{MDSrotate} can rotate a \eqn{k}-dimensional
+ ordination to \eqn{k-1} variables. When these variables are
+ correlated (like usually is the case), the vectors can also be
+ correlated to previously rotated dimensions, but will be
+ uncorrelated to all later ones.
- \item \code{nestednodf} gained new option for defining weighted
- nestedness statistic.
+ \item \pkg{vegan} 2.0-10 changed the weighted \code{nestednodf}
+ so that weighted analysis of binary data was equivalent to
+ binary analysis. However, this broke the equivalence to the
+ original method. Now the function has an argument \code{wbinary}
+ to select the method of analysis. The problem was reported and a
+ fix submitted by Vanderlei Debastiani (Universidade Federal do
+ Rio Grande do Sul, Brasil).
\item \code{ordiellipse}, \code{ordihull} and \code{ordiellipse}
can handle missing values in \code{groups}.
@@ -92,37 +197,44 @@
means.
\item \code{rankindex} can use Manhattan, Gower and Mahalanobis
- distance in addition to Euclidean.
+ distance in addition to the default Euclidean.
+ \item User can set colours and line types in unction
+ \code{rarecurve} for plotting rarefaction curves.
+
\item \code{spantree} gained a support function \code{as.hclust}
to change the minimum spannig tree into an \code{hclust} tree.
- \item \code{fitspecaccum} can do weighted analysis.
+ \item \code{fitspecaccum} can do weighted analysis. Gained
+ \code{lines} method.
\item \code{tabasco} uses now \code{reorder.hclust} for
- \code{hclust} for better ordering than previously when it cast
- trees to \code{dendrogram} objects.
+ \code{hclust} object for better ordering than previously when it
+ cast trees to \code{dendrogram} objects.
\item \code{treedive} and \code{treedist} default now to
- \code{match.force = TRUE} and can be silenced with
+ \code{match.force = TRUE} and can be silenced with
\code{verbose = FALSE}.
\item \code{vegdist} gained Mahalanobis distance.
- \item Nomenclature updated in plant community
- data. \code{varespec} and \code{dune} use 8-character names (4
+ \item Nomenclature updated in plant community data with the help
+ of \pkg{Taxonstand} and \pkg{taxize} packages. The taxonomy of
+ the \code{dune} data was adapted to the same sources and APG
+ III. \code{varespec} and \code{dune} use 8-character names (4
from genus + 4 from species epithet). New data set on
- phylogenetic distances for \code{dune}.
+ phylogenetic distances for \code{dune} was extracted from Zanne
+ et al. (\emph{Nature}, 2014).
\item User configurable plots for \code{rarecurve}.
} %end itemize
- } % end new features
+ } % end new featuresq
\subsection{DEPRECATED AND DEFUNCT}{
\itemize{
- \item \code{strata} deprecated in permutations. It is still
+ \item \code{strata} are deprecated in permutations. It is still
accepted but will be phased out in next releases. Use \code{how}
of \pkg{permute} package.
@@ -135,12 +247,9 @@
method))}.
\item \code{density} and \code{densityplot} for permutation
- results: use \code{density(permustats(
Author: jarioksa
Date: 2014-10-14 11:06:39 +0200 (Tue, 14 Oct 2014)
New Revision: 2900
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/permustats.R
pkg/vegan/R/permutest.betadisper.R
pkg/vegan/man/permustats.Rd
pkg/vegan/man/permutest.betadisper.Rd
pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
Squashed commit of the following:
commit 857c8e06410d0cbe1cec8fe92f08fc7714bb3323
Merge: e6e7d99 98731c7
Author: Jari Oksanen
Date: Tue Oct 14 11:37:41 2014 +0300
Merge pull request #56 from jarioksa/permustats-fixes
Permustats fixes
commit 98731c71d47d9c17fa713f43c1c54865a1a682ee
Author: Jari Oksanen
Date: Tue Oct 14 11:30:44 2014 +0300
summary of permustats failed with a vector of permutations
Function assumed that permutations are in a column matrix (one
column for each statistic). Now vectors of a single statistic are
coerced to a column matrix. The summary failed with the following
results: anosim, mantel (+ mantel.partial), mrpp and permutest.cca.
commit edfb8a7f98449f3539ced28e995ea67b51ffa1af
Author: Jari Oksanen
Date: Tue Oct 14 11:05:52 2014 +0300
export permutest.protest
commit e6e7d99abcf8a663d5e6156369f96589cd8e0cb6
Merge: 6b29357 6a45940
Author: Jari Oksanen
Date: Tue Oct 14 10:48:38 2014 +0300
Merge pull request #54 from gavinsimpson/improve-betadisper-ptest
Improve permutest.betadisper returned object
commit 6a45940e7482dba683a0a838a48ae7e0462c5507
Author: Gavin Simpson
Date: Mon Oct 13 20:37:38 2014 -0600
update author info
commit 74cd7296e5891de05f4caa82c6a2d1dba591f423
Author: Gavin Simpson
Date: Mon Oct 13 19:22:26 2014 -0600
Updated reference material
commit 1a90a2339e66754441353cef67ae32a1ab773493
Author: Gavin Simpson
Date: Mon Oct 13 16:39:43 2014 -0600
Need to replicate alternative if methods only supply a single alternative for multiple statistics, as per permustats.adonis and first example in ?permustats
commit 9647f58ea2c5f4c91cf5a48171137940e16c486c
Author: Gavin Simpson
Date: Mon Oct 13 16:15:56 2014 -0600
update the test material for examples
commit aaef90cf317fab5f7c2898abbfc1607df70f9e91
Author: Gavin Simpson
Date: Mon Oct 13 15:37:55 2014 -0600
Modification to the help to reflect removal of 'probs' and addition of 'interval'; other tweaks and minor changes
commit 8bac53666101084dd216b17147670dc6ddb7d908
Author: Gavin Simpson
Date: Mon Oct 13 15:34:53 2014 -0600
include an indication of the type of test statistic in the names of the statistic component of the returned object
commit 560696a5692738059c26999401d0debe636ef3e2
Author: Gavin Simpson
Date: Mon Oct 13 14:50:04 2014 -0600
don't transpose permutations; treat printed elements as test statistics 'tst.ind' in printCoefmat
commit 5c598511130d071272d84802ff6bb6a794486e74
Author: Gavin Simpson
Date: Mon Oct 13 11:03:34 2014 -0600
Update the reference materials for testing examples
commit 1f7b4ce38daed82facab430dc658901a9b6063cf
Author: Gavin Simpson
Date: Mon Oct 13 10:44:20 2014 -0600
really fix the printed interval statement; didn't set the separator
commit c95defa9e1eb79213f7f09d8c6cf18457e23de25
Author: Gavin Simpson
Date: Mon Oct 13 10:38:29 2014 -0600
update the Rd fiile for permustats to remove argument probs and add argument interval
commit f5b0ed8d66fecd1363ade3c51265d3b1563f7564
Author: Gavin Simpson
Date: Mon Oct 13 10:36:11 2014 -0600
update the example for permustats to illustrate use of interval
commit c75da6cd115b0f4155ff567e6c35b26c3b9b9b8f
Author: Gavin Simpson
Date: Mon Oct 13 10:35:00 2014 -0600
tweak interval statement in print method
commit 41f31de7c9a014af5b2547e24cb39bfae2bf282d
Author: Gavin Simpson
Date: Mon Oct 13 10:34:08 2014 -0600
implement Jari's suggestion of a single table with lower and upper defined for user-specified interval; for less and greater, upper and lower will be blank, respectively, under this scenario.
commit d11462a1bbb61eea5f70ae2b0172014cdc885a84
Author: Gavin Simpson
Date: Sun Oct 12 21:03:15 2014 -0600
* Add some tests of user-supplied 'probs'
* rbind together tests with same alternative
commit 8adf8fddd7d048c7523fe35d51dfb747a0105671
Author: Gavin Simpson
Date: Sun Oct 12 21:01:55 2014 -0600
add an example of specifying probs
commit 06ed3ccd2b354235b94345db3045c887cf1f9c9c
Author: Gavin Simpson
Date: Sun Oct 12 20:59:56 2014 -0600
set dimnames rather than colnames
commit ce59956d7de3c892e6f7766fd39f9a790934156d
Author: Gavin Simpson
Date: Sun Oct 12 17:28:42 2014 -0600
document that probs can be a list if a vector of alternatives is present.
commit 7a2d3c77dc3a09005240a4a4c9fc7ce229bca532
Author: Gavin Simpson
Date: Sun Oct 12 16:33:54 2014 -0600
Additional improvements following discussions with Jari:
* summary.permustats now handles multiple types of alternative hypotheses
* print.summary.permustats prints different types of alternatives in separate tables
* permustats.permutest.betadisper now correctly specifies the multiple alternative hypoetheses if pairwise tests were performed in permutest.betadisper
commit 9efe4b8de20c65b1e8f7ff16ff634e047088819e
Author: Gavin Simpson
Date: Sat Oct 11 12:30:28 2014 -0600
update reference materials
commit 1d423b3a9e009a0e0045ab5f495df7ed6bf501ab
Author: Gavin Simpson
Date: Sat Oct 11 12:12:59 2014 -0600
update example to use the new permustats method & draw some plots
commit fb7b12eff0588de8676fa29e451c81db6714fc0f
Author: Gavin Simpson
Date: Sat Oct 11 12:12:17 2014 -0600
add a permustats method for class 'permutest.betadisper'
commit 42b18892d752d74eff0cc40b43b22135979cb38a
Author: Gavin Simpson
Date: Sat Oct 11 11:19:33 2014 -0600
return vector of observed statistic(s) and matrix of permuted values of the statistic(s) under the null hypothesis
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/NAMESPACE 2014-10-14 09:06:39 UTC (rev 2900)
@@ -246,14 +246,15 @@
S3method(permustats, mantel)
S3method(permustats, mrpp)
S3method(permustats, oecosimu)
+S3method(permustats, permutest.betadisper)
S3method(permustats, permutest.cca)
+S3method(permustats, protest)
## these return an error: no permutation data
S3method(permustats, CCorA)
S3method(permustats, envfit)
S3method(permustats, factorfit)
S3method(permustats, vectorfit)
S3method(permustats, mso)
-S3method(permustats, permutest.betadisper)
S3method(print, permustats)
S3method(summary, permustats)
Modified: pkg/vegan/R/permustats.R
===================================================================
--- pkg/vegan/R/permustats.R 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/R/permustats.R 2014-10-14 09:06:39 UTC (rev 2900)
@@ -21,35 +21,47 @@
### modelled after print.oecosimu (should perhaps have oecosimu() args
### like 'alternative'
-`summary.permustats` <-
- function(object, probs, ...)
-{
- ## default cut levels for quantiles: these are two-sided
- if (missing(probs))
- probs <- switch(object$alternative,
- "two.sided" = c(0.025, 0.5, 0.975),
- "greater" = c(0.5, 0.95),
- "less" = c(0.05, 0.5))
- sim <- t(object$permutations)
- object$means <- rowMeans(sim)
- sd <- apply(sim, 1, sd)
+`summary.permustats` <- function(object, interval = 0.95, ...) {
+ nalt <- length(object$alternative)
+ nstat <- length(object$statistic)
+ ## Replicate alternative to length of statistic
+ if ((nalt < nstat) && identical(nalt, 1L)) {
+ object$alternative <- rep(object$alternative, length.out = nstat)
+ }
+ TAB <- c("two.sided", "greater", "less")
+ compint <- (1 - interval) / 2
+ PROBS <- list(two.sided = c(compint, 0.5, interval + compint),
+ greater = c(NA, 0.5, interval),
+ less = c(1 - interval, 0.5, NA))
+ alt <- match(object$alternative, TAB)
+ probs <- PROBS[alt]
+ ## take care that permutations are in a column matrix
+ permutations <- as.matrix(object$permutations)
+ object$means <- colMeans(permutations)
+ sd <- apply(permutations, 2, sd)
object$z <-
(object$statistic - object$means)/sd
- object$quantile <-
- apply(sim, 1, quantile, probs = probs, na.rm = TRUE)
+ qFun <- function(i, sim, probs) {
+ quantile(sim[, i], probs = probs[[i]], na.rm = TRUE)
+ }
+ object$quantile <- lapply(seq_along(probs), qFun, sim = permutations, probs = probs)
+ object$quantile <- do.call("rbind", object$quantile)
+ dimnames(object$quantile) <- list(NULL, c("lower", "median", "upper"))
+ object$interval <- interval
## not (yet) P-values...
class(object) <- "summary.permustats"
object
}
-`print.summary.permustats` <-
- function(x, ...)
-{
+`print.summary.permustats` <- function(x, ...) {
m <- cbind("statistic" = x$statistic,
"z" = x$z,
"mean" = x$means,
- t(x$quantile))
- printCoefmat(m, cs.ind = 3:ncol(m), ...)
+ x$quantile)
+ cat("\n")
+ printCoefmat(m, tst.ind = 1:ncol(m), na.print = "", ...)
+ writeLines(strwrap(paste0("(Interval (Upper - Lower) = ", x$interval, ")", sep = ""),
+ initial = "\n"))
invisible(x)
}
@@ -237,5 +249,14 @@
`permustats.permutest.betadisper` <-
function(x, ...)
{
- stop("no permutation data available")
+ ntypes <- NCOL(x$perm)
+ alt <- if (ntypes > 1) {
+ c("greater", rep("two.sided", ntypes - 1))
+ } else {
+ "greater"
+ }
+ structure(list("statistic" = x$statistic,
+ "permutations" = x$perm,
+ "alternative" = alt),
+ class ="permustats")
}
Modified: pkg/vegan/R/permutest.betadisper.R
===================================================================
--- pkg/vegan/R/permutest.betadisper.R 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/R/permutest.betadisper.R 2014-10-14 09:06:39 UTC (rev 2900)
@@ -104,7 +104,9 @@
## Process results
F0 <- summary(mod)$fstatistic[1]
Fstats <- round(Pstats[, 1], 12) # allow empty dim to be dropped
- F0 <- round(F0, 12)
+ statistic <- F0 <- round(F0, 12)
+ names(statistic) <- "Overall (F)"
+
## pairwise comparisons
if(pairwise) {
T0 <- apply(combn(levels(group), 2), 2, function(z) {
@@ -112,6 +114,7 @@
x$distances[group == z[2]])})
Tstats <- round(Pstats[, -1, drop = FALSE], 12)
T0 <- round(T0, 12)
+ statistic <- c(statistic, T0)
}
## compute permutation p-value
@@ -123,20 +126,28 @@
length(x$distance[group == z[2]]) - 2})
pairp <- (colSums(sweep(abs(Tstats), 2, abs(T0), '>=')) + 1) /
(NROW(Tstats) + 1)
- pairwise <- list(observed = 2 * pt(-abs(T0), df),
+ pairp <- list(observed = 2 * pt(-abs(T0), df),
permuted = pairp)
- names(pairwise$observed) <- names(pairwise$permuted) <-
- apply(combin, 2, paste, collapse = "-")
+ tnames <- apply(combin, 2, paste, collapse = "-")
+ names(pairp$observed) <- names(pairp$permuted) <- tnames
+ names(statistic)[-1] <- paste(tnames, "(t)")
} else {
- pairwise <- NULL
+ pairp <- NULL
}
retval <- cbind(mod.aov[, 1:4], c(nperm, NA), c(pval, NA))
dimnames(retval) <- list(c("Groups", "Residuals"),
c("Df", "Sum Sq", "Mean Sq", "F", "N.Perm",
"Pr(>F)"))
- retval <- list(tab = retval, pairwise = pairwise,
+ retval <- list(tab = retval,
+ pairwise = pairp,
groups = levels(group),
+ statistic = statistic,
+ perm = if (pairwise) {
+ structure(cbind(Fstats, Tstats), dimnames = list(NULL, names(statistic)))
+ } else {
+ structure(Fstats, names = names(statistic))
+ },
control = attr(permutations, "control"))
class(retval) <- "permutest.betadisper"
retval
Modified: pkg/vegan/man/permustats.Rd
===================================================================
--- pkg/vegan/man/permustats.Rd 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/man/permustats.Rd 2014-10-14 09:06:39 UTC (rev 2900)
@@ -31,7 +31,7 @@
\usage{
permustats(x, ...)
-\method{summary}{permustats}(object, probs, ...)
+\method{summary}{permustats}(object, interval = 0.95, ...)
\method{densityplot}{permustats}(x, data, xlab = "Permutations", ...)
\method{density}{permustats}(x, observed = TRUE, ...)
\method{qqnorm}{permustats}(y, observed = TRUE, ...)
@@ -40,11 +40,7 @@
\arguments{
\item{object, x, y}{The object to be handled.}
- \item{probs}{Numeric vector of probabilities in [0,1] used in
- \code{\link{quantile}} of permutations. If missing, default
- quantiles will cover 95\% of permutations, and the values are
- dependent on the test direction (either (0.025, 0.975), 0.05, or
- 0.95). In addition, default will give median (0.5). }
+ \item{interval}{numeric; the coverage interval reported.}
\item{xlab, ylab}{Arguments of
\code{\link[lattice]{densityplot}} and
\code{\link[lattice]{qqmath}} functions.}
@@ -57,25 +53,26 @@
\details{
The \code{permustats} function extracts permutation results and
- observed statistics from several \pkg{vegan} functions performing
+ observed statistics from several \pkg{vegan} functions that perform
permutations or simulations.
- The \code{summary} of \code{permustats} estimates the \eqn{z} values,
- also known as standardized effect sizes (SES) as the difference of
- obseved statistic and mean of permutations divided by the standard
- deviation of permutations. It also prints the the mean, median, and
- limits which contain 95\% of permutations. For two-sided test these
- are (2.5\%, 97.5\%) and for one-sided tests either 5\% or 95\%
+ The \code{summary} method of \code{permustats} estimates the \eqn{z}
+ values, also known as standardized effect sizes (SES) as the
+ difference of observed statistic and mean of permutations divided by
+ the standard deviation of permutations. It also prints the the mean,
+ median, and limits which contain \code{interval} percent of permuted
+ values. With the default (\code{interval = 0.95}), for two-sided test
+ these are (2.5\%, 97.5\%) and for one-sided tests either 5\% or 95\%
quantile depending on the test direction. The mean, quantiles and
- \eqn{z} values are evaluated from permutations without observed
+ \eqn{z} values are evaluated from permuted values without observed
statistic.
The \code{density} and \code{densityplot} methods display the
- density of permutations. When observed value of the statistic is put
- among the permutations, the \code{densityplot} method marks the
- observed statistic as a vertical line. However \code{density} method
- uses its standard \code{plot} method and cannot mark the obseved
- value.
+ kernel density estimates of permuted values. When observed value of
+ the statistic is included in the permuted values, the
+ \code{densityplot} method marks the observed statistic as a vertical
+ line. However the \code{density} method uses its standard \code{plot}
+ method and cannot mark the obseved value.
The \code{qqnorm} and \code{qqmath} display Q-Q plots of
permutations, optionally together with the observed value (default)
@@ -96,9 +93,10 @@
results of \code{\link{adonis}}, \code{\link{anosim}},
\code{\link{mantel}}, \code{\link{mantel.partial}},
\code{\link{mrpp}}, \code{\link{oecosimu}},
- \code{\link{permutest.cca}}, and \code{\link{protest}}. NB, there
- is no \code{permustats} method for \code{\link{anova.cca}}, but only
- for \code{\link{permutest.cca}}.
+ \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}}.
}
@@ -113,7 +111,10 @@
}
\author{
- Jari Oksanen
+ 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.
}
\seealso{
@@ -130,6 +131,12 @@
summary(perm)
densityplot(perm)
qqmath(perm)
+
+## example of multiple types of statistic
+mod <- with(dune.env, betadisper(vegdist(dune), Management))
+pmod <- permutest(mod, nperm = 99, pairwise = TRUE)
+perm <- permustats(pmod)
+summary(perm, interval = 0.90)
}
\keyword{ distribution }
Modified: pkg/vegan/man/permutest.betadisper.Rd
===================================================================
--- pkg/vegan/man/permutest.betadisper.Rd 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/man/permutest.betadisper.Rd 2014-10-14 09:06:39 UTC (rev 2900)
@@ -86,11 +86,16 @@
anova(mod)
## Permutation test for F
-permutest(mod, permutations = 99, pairwise = TRUE)
+pmod <- permutest(mod, permutations = 99, pairwise = TRUE)
## Tukey's Honest Significant Differences
(mod.HSD <- TukeyHSD(mod))
plot(mod.HSD)
+
+## Has permustats() method
+pstat <- permustats(pmod)
+densityplot(pstat)
+qqmath(pstat)
}
\keyword{methods}
\keyword{multivariate}
Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-13 08:58:59 UTC (rev 2899)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-10-14 09:06:39 UTC (rev 2900)
@@ -160,7 +160,7 @@
Formula:
y ~ poly(x1, 1) + poly(x2, 1)
-
+
Total model degrees of freedom 3
REML score: -3.185099
@@ -4882,7 +4882,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4899,7 +4899,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
6.45 total = 7.45
@@ -4930,7 +4930,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4945,7 +4945,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE)
-
+
Estimated degrees of freedom:
4.43 total = 5.43
@@ -4974,7 +4974,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE)
-
+
Estimated degrees of freedom:
5.63 total = 6.63
@@ -4990,7 +4990,7 @@
Formula:
y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE)
-
+
Estimated degrees of freedom:
3 total = 4
@@ -5007,7 +5007,7 @@
Formula:
y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE,
FALSE))
-
+
Estimated degrees of freedom:
2.99 total = 3.99
@@ -5026,7 +5026,7 @@
Formula:
y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE,
TRUE))
-
+
Estimated degrees of freedom:
11 total = 12
@@ -5167,7 +5167,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.71 total = 9.71
@@ -5180,7 +5180,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
7.18 total = 8.18
@@ -5193,7 +5193,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
8.32 total = 9.32
@@ -5454,14 +5454,34 @@
> ## use permustats
> perm <- permustats(mod)
> summary(perm)
- statistic z mean 50% 95%
-Management 3.0730 4.5815 1.04617 0.94704 1.8475
-A1 2.7676 2.6322 1.03640 0.88513 2.3280
+
+ statistic z mean lower median upper
+Management 3.0730 4.5815 1.0462 0.9470 1.8475
+A1 2.7676 2.6322 1.0364 0.8851 2.3280
+
+(Interval (Upper - Lower) = 0.95)
> densityplot(perm)
> qqmath(perm)
>
+> ## example of multiple types of statistic
+> mod <- with(dune.env, betadisper(vegdist(dune), Management))
+> pmod <- permutest(mod, nperm = 99, pairwise = TRUE)
+> perm <- permustats(pmod)
+> summary(perm, interval = 0.90)
+
+ statistic z mean lower median upper
+Overall (F) 1.9506 0.6046 1.2061 0.8375 2.7743
+BF-HF (t) -0.5634 -0.4179 -0.0584 -2.0011 -0.0974 1.8273
+BF-NM (t) -2.2387 -1.8228 -0.0941 -2.1192 -0.0944 1.7339
+BF-SF (t) -1.1675 -0.8886 -0.0928 -2.1442 -0.0866 1.8232
+HF-NM (t) -2.1017 -1.8899 -0.0158 -1.8740 0.0412 1.6319
+HF-SF (t) -0.8789 -0.7166 -0.0321 -1.8973 -0.0076 1.8362
+NM-SF (t) 0.9485 0.8309 -0.0036 -1.8411 -0.0531 1.9024
+
+(Interval (Upper - Lower) = 0.9)
>
>
+>
> cleanEx()
> nameEx("permutest.betadisper")
> ### * permutest.betadisper
@@ -5515,24 +5535,7 @@
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> ## Permutation test for F
-> permutest(mod, permutations = 99, pairwise = TRUE)
-
-Permutation test for homogeneity of multivariate dispersions
-Permutation: free
-Number of permutations: 99
-
-Response: Distances
- Df Sum Sq Mean Sq F N.Perm Pr(>F)
-Groups 1 0.07931 0.079306 4.6156 99 0.04 *
-Residuals 22 0.37801 0.017182
----
-Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
-
-Pairwise comparisons:
-(Observed p-value below diagonal, permuted p-value above diagonal)
- grazed ungrazed
-grazed 0.05
-ungrazed 0.04295
+> pmod <- permutest(mod, permutations = 99, pairwise = TRUE)
>
> ## Tukey's Honest Significant Differences
> (mod.HSD <- TukeyHSD(mod))
@@ -5547,8 +5550,13 @@
> plot(mod.HSD)
>
+> ## Has permustats() method
+> pstat <- permustats(pmod)
+> densityplot(pstat)
+> qqmath(pstat)
>
>
+>
> cleanEx()
> nameEx("plot.cca")
> ### * plot.cca
@@ -7824,7 +7832,7 @@
Formula:
y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
-
+
Estimated degrees of freedom:
1.28 total = 2.28
@@ -8380,7 +8388,7 @@
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 104.001 1.198 105.469 0 0
+Time elapsed: 116.267 1.384 118.094 0 0
> grDevices::dev.off()
null device
1
From noreply at r-forge.r-project.org Thu Oct 16 10:50:18 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Thu, 16 Oct 2014 10:50:18 +0200 (CEST)
Subject: [Vegan-commits] r2901 - pkg/vegan/man
Message-ID: <20141016085018.769CC18765A@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-16 10:50:18 +0200 (Thu, 16 Oct 2014)
New Revision: 2901
Modified:
pkg/vegan/man/tsallis.Rd
Log:
uh
Modified: pkg/vegan/man/tsallis.Rd
===================================================================
--- pkg/vegan/man/tsallis.Rd 2014-10-14 09:06:39 UTC (rev 2900)
+++ pkg/vegan/man/tsallis.Rd 2014-10-16 08:50:18 UTC (rev 2901)
@@ -1,134 +1,134 @@
-\encoding{UTF-8}
-\name{tsallis}
-\alias{tsallis}
-\alias{tsallisaccum}
-\alias{persp.tsallisaccum}
-\title{Tsallis Diversity and Corresponding Accumulation Curves}
-\description{
-Function \code{tsallis} find Tsallis diversities with any scale or the corresponding evenness measures. Function \code{tsallisaccum} finds these statistics with accumulating sites.
-}
-\usage{
-tsallis(x, scales = seq(0, 2, 0.2), norm = FALSE, hill = FALSE)
-tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100,
- raw = FALSE, subset, ...)
-\method{persp}{tsallisaccum}(x, theta = 220, phi = 15, col = heat.colors(100), zlim, ...)
-}
-
-\arguments{
- \item{x}{Community data matrix or plotting object. }
- \item{scales}{Scales of Tsallis diversity.}
-
- \item{norm}{Logical, if \code{TRUE} diversity values are normalized
- by their maximum (diversity value at equiprobability conditions).}
-
- \item{hill}{Calculate Hill numbers.}
-
- \item{permutations}{Number of random permutations in accumulating
- sites.}
-
- \item{raw}{If \code{FALSE} then return summary statistics of
- permutations, and if TRUE then returns the individual
- permutations.}
-
- \item{subset}{logical expression indicating sites (rows) to keep:
- missing values are taken as \code{FALSE}.}
-
- \item{theta, phi}{angles defining the viewing
- direction. \code{theta} gives the azimuthal direction and
- \code{phi} the colatitude.}
-
- \item{col}{Colours used for surface.} \item{zlim}{Limits of
- vertical axis.}
-
- \item{\dots}{Other arguments which are passed to \code{tsallis} and
- to graphical functions.}
-
-}
-
-\details{ The Tsallis diversity (also equivalent to Patil and Taillie
-diversity) is a one-parametric generalised entropy function, defined
-as:
-
-\deqn{H_q = \frac{1}{q-1} (1-\sum_{i=1}^S p_i^q)}{H.q = 1/(q-1)(1-sum(p^q))}
-
-where \eqn{q} is a scale parameter, \eqn{S} the number of species in
-the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave
-for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it
-gives the number of species minus one, as \eqn{q} tends to 1 this
-gives Shannon diversity, for \eqn{q=2} this gives the Simpson index
-(see function \code{\link{diversity}}).
-
-If \code{norm = TRUE}, \code{tsallis} gives values normalized by the
-maximum:
-
-\deqn{H_q(max) = \frac{S^{1-q}-1}{1-q}}{H.q(max) = (S^(1-q)-1)/(1-q)}
-
-where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum
-is defined as \eqn{ln(S)}.
-
-If \code{hill = TRUE}, \code{tsallis} gives Hill numbers (numbers
-equivalents, see Jost 2007):
-
-\deqn{D_q = (1-(q-1) H)^{1/(1-q)}}{D.q = (1-(q-1)*H)^(1/(1-q))}
-
-Details on plotting methods and accumulating values can be found on
-the help pages of the functions \code{\link{renyi}} and
-\code{\link{renyiaccum}}.
-}
-
-\value{
-Function \code{tsallis} returns a data frame of selected
-indices. Function \code{tsallisaccum} with argument \code{raw = FALSE}
-returns a three-dimensional array, where the first dimension are the
-accumulated sites, second dimension are the diversity scales, and
-third dimension are the summary statistics \code{mean}, \code{stdev},
-\code{min}, \code{max}, \code{Qnt 0.025} and \code{Qnt 0.975}. With
-argument \code{raw = TRUE} the statistics on the third dimension are
-replaced with individual permutation results. }
-
-\references{
-
-Tsallis, C. (1988) Possible generalization of Boltzmann-Gibbs
- statistics. \emph{J. Stat. Phis.} 52, 479--487.
-
-Tothmeresz, B. (1995) Comparison of different methods for diversity
- ordering. \emph{Journal of Vegetation Science} \bold{6}, 283--290.
-
-Patil, G. P. and Taillie, C. (1982) Diversity as a concept and its
- measurement. \emph{J. Am. Stat. Ass.} \bold{77}, 548--567.
-
-Keylock, C. J. (2005) Simpson diversity and the Shannon-Wiener index
- as special cases of a generalized entropy. \emph{Oikos} \bold{109},
- 203--207.
-
-Jost, L (2007) Partitioning diversity into independent alpha and beta
- components. \emph{Ecology} \bold{88}, 2427--2439.
-}
-
-\author{\enc{P?ter S?lymos}{Peter Solymos},
-\email{solymos at ualberta.ca}, based on the code of Roeland Kindt and
-Jari Oksanen written for \code{renyi}}
-
-\seealso{ Plotting methods and accumulation routines are based on
-functions \code{\link{renyi}} and \code{\link{renyiaccum}}. An object
-of class 'tsallisaccum' can be used with function
-\code{\link[vegan3d]{rgl.renyiaccum}} as well. See also settings for
-\code{\link{persp}}. }
-
-\examples{
-data(BCI)
-i <- sample(nrow(BCI), 12)
-x1 <- tsallis(BCI[i,])
-x1
-diversity(BCI[i,],"simpson") == x1[["2"]]
-plot(x1)
-x2 <- tsallis(BCI[i,],norm=TRUE)
-x2
-plot(x2)
-mod1 <- tsallisaccum(BCI[i,])
-plot(mod1, as.table=TRUE, col = c(1, 2, 2))
-persp(mod1)
-mod2 <- tsallisaccum(BCI[i,], norm=TRUE)
-persp(mod2,theta=100,phi=30)
-}
-\keyword{multivariate}
+\encoding{UTF-8}
+\name{tsallis}
+\alias{tsallis}
+\alias{tsallisaccum}
+\alias{persp.tsallisaccum}
+\title{Tsallis Diversity and Corresponding Accumulation Curves}
+\description{
+Function \code{tsallis} find Tsallis diversities with any scale or the corresponding evenness measures. Function \code{tsallisaccum} finds these statistics with accumulating sites.
+}
+\usage{
+tsallis(x, scales = seq(0, 2, 0.2), norm = FALSE, hill = FALSE)
+tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100,
+ raw = FALSE, subset, ...)
+\method{persp}{tsallisaccum}(x, theta = 220, phi = 15, col = heat.colors(100), zlim, ...)
+}
+
+\arguments{
+ \item{x}{Community data matrix or plotting object. }
+ \item{scales}{Scales of Tsallis diversity.}
+
+ \item{norm}{Logical, if \code{TRUE} diversity values are normalized
+ by their maximum (diversity value at equiprobability conditions).}
+
+ \item{hill}{Calculate Hill numbers.}
+
+ \item{permutations}{Number of random permutations in accumulating
+ sites.}
+
+ \item{raw}{If \code{FALSE} then return summary statistics of
+ permutations, and if TRUE then returns the individual
+ permutations.}
+
+ \item{subset}{logical expression indicating sites (rows) to keep:
+ missing values are taken as \code{FALSE}.}
+
+ \item{theta, phi}{angles defining the viewing
+ direction. \code{theta} gives the azimuthal direction and
+ \code{phi} the colatitude.}
+
+ \item{col}{Colours used for surface.} \item{zlim}{Limits of
+ vertical axis.}
+
+ \item{\dots}{Other arguments which are passed to \code{tsallis} and
+ to graphical functions.}
+
+}
+
+\details{ The Tsallis diversity (also equivalent to Patil and Taillie
+diversity) is a one-parametric generalised entropy function, defined
+as:
+
+\deqn{H_q = \frac{1}{q-1} (1-\sum_{i=1}^S p_i^q)}{H.q = 1/(q-1)(1-sum(p^q))}
+
+where \eqn{q} is a scale parameter, \eqn{S} the number of species in
+the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave
+for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it
+gives the number of species minus one, as \eqn{q} tends to 1 this
+gives Shannon diversity, for \eqn{q=2} this gives the Simpson index
+(see function \code{\link{diversity}}).
+
+If \code{norm = TRUE}, \code{tsallis} gives values normalized by the
+maximum:
+
+\deqn{H_q(max) = \frac{S^{1-q}-1}{1-q}}{H.q(max) = (S^(1-q)-1)/(1-q)}
+
+where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum
+is defined as \eqn{ln(S)}.
+
+If \code{hill = TRUE}, \code{tsallis} gives Hill numbers (numbers
+equivalents, see Jost 2007):
+
+\deqn{D_q = (1-(q-1) H)^{1/(1-q)}}{D.q = (1-(q-1)*H)^(1/(1-q))}
+
+Details on plotting methods and accumulating values can be found on
+the help pages of the functions \code{\link{renyi}} and
+\code{\link{renyiaccum}}.
+}
+
+\value{
+Function \code{tsallis} returns a data frame of selected
+indices. Function \code{tsallisaccum} with argument \code{raw = FALSE}
+returns a three-dimensional array, where the first dimension are the
+accumulated sites, second dimension are the diversity scales, and
+third dimension are the summary statistics \code{mean}, \code{stdev},
+\code{min}, \code{max}, \code{Qnt 0.025} and \code{Qnt 0.975}. With
+argument \code{raw = TRUE} the statistics on the third dimension are
+replaced with individual permutation results. }
+
+\references{
+
+Tsallis, C. (1988) Possible generalization of Boltzmann-Gibbs
+ statistics. \emph{J. Stat. Phis.} 52, 479--487.
+
+Tothmeresz, B. (1995) Comparison of different methods for diversity
+ ordering. \emph{Journal of Vegetation Science} \bold{6}, 283--290.
+
+Patil, G. P. and Taillie, C. (1982) Diversity as a concept and its
+ measurement. \emph{J. Am. Stat. Ass.} \bold{77}, 548--567.
+
+Keylock, C. J. (2005) Simpson diversity and the Shannon-Wiener index
+ as special cases of a generalized entropy. \emph{Oikos} \bold{109},
+ 203--207.
+
+Jost, L (2007) Partitioning diversity into independent alpha and beta
+ components. \emph{Ecology} \bold{88}, 2427--2439.
+}
+
+\author{\enc{P?ter S?lymos}{Peter Solymos},
+\email{solymos at ualberta.ca}, based on the code of Roeland Kindt and
+Jari Oksanen written for \code{renyi}}
+
+\seealso{ Plotting methods and accumulation routines are based on
+functions \code{\link{renyi}} and \code{\link{renyiaccum}}. An object
+of class 'tsallisaccum' can be used with function
+\code{\link[vegan3d]{rgl.renyiaccum}} as well. See also settings for
+\code{\link{persp}}. }
+
+\examples{
+data(BCI)
+i <- sample(nrow(BCI), 12)
+x1 <- tsallis(BCI[i,])
+x1
+diversity(BCI[i,],"simpson") == x1[["2"]]
+plot(x1)
+x2 <- tsallis(BCI[i,],norm=TRUE)
+x2
+plot(x2)
+mod1 <- tsallisaccum(BCI[i,])
+plot(mod1, as.table=TRUE, col = c(1, 2, 2))
+persp(mod1)
+mod2 <- tsallisaccum(BCI[i,], norm=TRUE)
+persp(mod2,theta=100,phi=30)
+}
+\keyword{multivariate}
From noreply at r-forge.r-project.org Thu Oct 16 10:50:21 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Thu, 16 Oct 2014 10:50:21 +0200 (CEST)
Subject: [Vegan-commits] r2902 - in pkg/vegan: R man
Message-ID: <20141016085021.88E9C18765A@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-16 10:50:21 +0200 (Thu, 16 Oct 2014)
New Revision: 2902
Modified:
pkg/vegan/R/clamtest.R
pkg/vegan/R/commsim.R
pkg/vegan/R/contribdiv.R
pkg/vegan/R/eventstar.R
pkg/vegan/R/indpower.R
pkg/vegan/R/make.commsim.R
pkg/vegan/R/nullmodel.R
pkg/vegan/R/permutest.betadisper.R
pkg/vegan/R/persp.tsallisaccum.R
pkg/vegan/R/plot.clamtest.R
pkg/vegan/R/plot.contribdiv.R
pkg/vegan/R/print.commsim.R
pkg/vegan/R/print.mantel.correlog.R
pkg/vegan/R/print.nullmodel.R
pkg/vegan/R/print.simmat.R
pkg/vegan/R/print.summary.clamtest.R
pkg/vegan/R/simulate.nullmodel.R
pkg/vegan/R/summary.clamtest.R
pkg/vegan/R/tsallis.R
pkg/vegan/R/tsallisaccum.R
pkg/vegan/R/update.nullmodel.R
pkg/vegan/man/clamtest.Rd
pkg/vegan/man/commsim.Rd
pkg/vegan/man/eventstar.Rd
pkg/vegan/man/mantel.correlog.Rd
pkg/vegan/man/nullmodel.Rd
pkg/vegan/man/pcnm.Rd
pkg/vegan/man/permatfull.Rd
Log:
Merge branch 'master' into r-forge-svn-local
Modified: pkg/vegan/R/clamtest.R
===================================================================
--- pkg/vegan/R/clamtest.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/clamtest.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,127 +1,127 @@
-## CLAM, reproduction of software described in Chazdon et al. 2011
-## Ecology, 92, 1332--1343
-clamtest <-
-function(comm, groups, coverage.limit = 10,
-specialization = 2/3, npoints = 20, alpha = 0.05/20)
-{
- ## inital checks
- comm <- as.matrix(comm)
- if (NROW(comm) < 2)
- stop("'comm' must have at least 2 rows")
- if (nrow(comm) > 2 && missing(groups))
- stop("'groups' is missing")
- if (nrow(comm) == 2 && missing(groups))
- groups <- if (is.null(rownames(comm)))
- c("Group.1", "Group.2") else rownames(comm)
- if (length(groups) != nrow(comm))
- stop("length of 'groups' must equal 'nrow(comm)'")
- if (length(unique(groups)) != 2)
- stop("number of groups must be 2")
- glabel <- as.character(unique(groups))
- if (is.null(colnames(comm)))
- colnames(comm) <- paste("Species", 1:ncol(comm), sep=".")
- if (any(colSums(comm) <= 0))
- stop("'comm' contains zero sum columns")
- spp <- colnames(comm)
- ## reproduced from Chazdon et al. 2011, Ecology 92, 1332--1343
- S <- ncol(comm)
- if (nrow(comm) == 2) {
- Y <- comm[glabel[1],]
- X <- comm[glabel[2],]
- } else {
- Y <- colSums(comm[which(groups==glabel[1]),])
- X <- colSums(comm[which(groups==glabel[2]),])
- }
- names(X) <- names(Y) <- NULL
- #all(ct$Total_SG == Y)
- #all(ct$Total_OG == X)
- m <- sum(Y)
- n <- sum(X)
- if (sum(Y) <= 0 || sum(X) <= 0)
- stop("zero group totals not allowed")
- ## check if comm contains integer, especially for singletons
- if (any(X[X>0] < 1) || any(Y[Y>0] < 1))
- warning("<1 non integer values detected: analysis might not be meaningful")
- if (abs(sum(X,Y) - sum(as.integer(X), as.integer(Y))) > 10^-6)
- warning("non integer values detected")
- C1 <- 1 - sum(X==1)/n
- C2 <- 1 - sum(Y==1)/m
- ## this stands for other than 2/3 cases
- uu <- specialization/(1-specialization)
- ## critical level
- Zp <- qnorm(alpha, lower.tail=FALSE)
- #p_i=a
- #pi_i=b
- ## function to calculate test statistic from Appendix D
- ## (Ecological Archives E092-112-A4)
- ## coverage limit is count, not freq !!!
- testfun <- function(p_i, pi_i, C1, C2, n, m) {
- C1 <- ifelse(p_i*n < coverage.limit, C1, 1)
- C2 <- ifelse(pi_i*m < coverage.limit, C2, 1)
- Var <- C1^2*(p_i*(1-p_i)/n) + uu^2*C2^2*(pi_i*(1-pi_i)/m)
- C1*p_i - C2*pi_i*uu - Zp*sqrt(Var)
- }
- ## root finding for iso-lines (instead of itarative search)
- rootfun <- function(pi_i, C1, C2, n, m, upper) {
- f <- function(p_i) testfun(p_i/n, pi_i/m, C1, C2, n, m)
- if (length(unique(sign(c(f(1), f(upper))))) > 1)
- ceiling(uniroot(f, lower=1, upper=upper)$root) else NA
- }
- ## sequences for finding Xmin and Ymin values
- Xseq <- as.integer(trunc(seq(1, max(X), len=npoints)))
- Yseq <- as.integer(trunc(seq(1, max(Y), len=npoints)))
- ## finding Xmin and Ymin values for Xseq and Yseq
- Xmins <- sapply(Yseq, function(z) rootfun(z, C1, C2, n, m, upper=max(X)))
- Ymins <- sapply(Xseq, function(z) rootfun(z, C2, C1, m, n, upper=max(Y)))
-
- ## needed to tweak original set of rules (extreme case reported
- ## by Richard Telford failed here)
- if (all(is.na(Xmins)))
- Xmins[1] <- 1
- if (all(is.na(Ymins)))
- Ymins[1] <- 1
-
- minval <- list(data.frame(x=Xseq[!is.na(Ymins)], y=Ymins[!is.na(Ymins)]),
- data.frame(x=Xmins[!is.na(Xmins)], y=Yseq[!is.na(Xmins)]))
-
- ## shared but too rare
- Ymin <- Ymins[1]
- Xmin <- Xmins[1]
- sr <- X < Xmin & Y < Ymin
-
- ## consequence of manually setting Xmin/Ymin resolved here
- tmp1 <- if (Xmin==1)
- list(x=1, y=Xmin) else approx(c(Xmin, 1), c(1, Ymin), xout=1:Xmin)
- tmp2 <- if (Ymin==1)
- list(x=1, y=Ymin) else approx(c(1, Ymin), c(Xmin, 1), xout=1:Ymin)
-
- for (i in 1:S) {
- if (X[i] %in% tmp1$x)
- sr[i] <- Y[i] < tmp1$y[which(X[i]==tmp1$x)]
- if (Y[i] %in% tmp2$x)
- sr[i] <- X[i] < tmp2$y[which(Y[i]==tmp2$x)]
- }
- ## classification
- a <- ifelse(X==0, 1, X)/n # \hat{p_i}
- b <- ifelse(Y==0, 1, Y)/m # \hat{\pi_i}
- specX <- !sr & testfun(a, b, C1, C2, n, m) > 0
- specY <- !sr & testfun(b, a, C2, C1, m, n) > 0
- gen <- !sr & !specX & !specY
- ## crosstable
- tmp <- ifelse(cbind(gen, specY, specX, sr), 1, 0)
- types <- c("Generalist", paste("Specialist", glabel[1], sep="_"),
- paste("Specialist", glabel[2], sep="_"), "Too_rare")
- classes <- factor((1:4)[rowSums(tmp*col(tmp))], levels=1:4)
- levels(classes) <- c("Generalist", paste("Specialist", glabel[1], sep="_"),
- paste("Specialist", glabel[2], sep="_"), "Too_rare")
- tab <- data.frame(Species=spp, y=Y, x=X, Classes=classes)
- colnames(tab)[2:3] <- paste("Total", glabel, sep="_")
- rownames(tab) <- NULL
- class(tab) <- c("clamtest","data.frame")
- attr(tab, "settings") <- list(labels = glabel,
- coverage.limit = coverage.limit, specialization = specialization,
- npoints = npoints, alpha = alpha)
- attr(tab, "minv") <- minval
- attr(tab, "coverage") <- structure(c(C2, C1), .Names=glabel)
- tab
-}
+## CLAM, reproduction of software described in Chazdon et al. 2011
+## Ecology, 92, 1332--1343
+clamtest <-
+function(comm, groups, coverage.limit = 10,
+specialization = 2/3, npoints = 20, alpha = 0.05/20)
+{
+ ## inital checks
+ comm <- as.matrix(comm)
+ if (NROW(comm) < 2)
+ stop("'comm' must have at least 2 rows")
+ if (nrow(comm) > 2 && missing(groups))
+ stop("'groups' is missing")
+ if (nrow(comm) == 2 && missing(groups))
+ groups <- if (is.null(rownames(comm)))
+ c("Group.1", "Group.2") else rownames(comm)
+ if (length(groups) != nrow(comm))
+ stop("length of 'groups' must equal 'nrow(comm)'")
+ if (length(unique(groups)) != 2)
+ stop("number of groups must be 2")
+ glabel <- as.character(unique(groups))
+ if (is.null(colnames(comm)))
+ colnames(comm) <- paste("Species", 1:ncol(comm), sep=".")
+ if (any(colSums(comm) <= 0))
+ stop("'comm' contains zero sum columns")
+ spp <- colnames(comm)
+ ## reproduced from Chazdon et al. 2011, Ecology 92, 1332--1343
+ S <- ncol(comm)
+ if (nrow(comm) == 2) {
+ Y <- comm[glabel[1],]
+ X <- comm[glabel[2],]
+ } else {
+ Y <- colSums(comm[which(groups==glabel[1]),])
+ X <- colSums(comm[which(groups==glabel[2]),])
+ }
+ names(X) <- names(Y) <- NULL
+ #all(ct$Total_SG == Y)
+ #all(ct$Total_OG == X)
+ m <- sum(Y)
+ n <- sum(X)
+ if (sum(Y) <= 0 || sum(X) <= 0)
+ stop("zero group totals not allowed")
+ ## check if comm contains integer, especially for singletons
+ if (any(X[X>0] < 1) || any(Y[Y>0] < 1))
+ warning("<1 non integer values detected: analysis might not be meaningful")
+ if (abs(sum(X,Y) - sum(as.integer(X), as.integer(Y))) > 10^-6)
+ warning("non integer values detected")
+ C1 <- 1 - sum(X==1)/n
+ C2 <- 1 - sum(Y==1)/m
+ ## this stands for other than 2/3 cases
+ uu <- specialization/(1-specialization)
+ ## critical level
+ Zp <- qnorm(alpha, lower.tail=FALSE)
+ #p_i=a
+ #pi_i=b
+ ## function to calculate test statistic from Appendix D
+ ## (Ecological Archives E092-112-A4)
+ ## coverage limit is count, not freq !!!
+ testfun <- function(p_i, pi_i, C1, C2, n, m) {
+ C1 <- ifelse(p_i*n < coverage.limit, C1, 1)
+ C2 <- ifelse(pi_i*m < coverage.limit, C2, 1)
+ Var <- C1^2*(p_i*(1-p_i)/n) + uu^2*C2^2*(pi_i*(1-pi_i)/m)
+ C1*p_i - C2*pi_i*uu - Zp*sqrt(Var)
+ }
+ ## root finding for iso-lines (instead of itarative search)
+ rootfun <- function(pi_i, C1, C2, n, m, upper) {
+ f <- function(p_i) testfun(p_i/n, pi_i/m, C1, C2, n, m)
+ if (length(unique(sign(c(f(1), f(upper))))) > 1)
+ ceiling(uniroot(f, lower=1, upper=upper)$root) else NA
+ }
+ ## sequences for finding Xmin and Ymin values
+ Xseq <- as.integer(trunc(seq(1, max(X), len=npoints)))
+ Yseq <- as.integer(trunc(seq(1, max(Y), len=npoints)))
+ ## finding Xmin and Ymin values for Xseq and Yseq
+ Xmins <- sapply(Yseq, function(z) rootfun(z, C1, C2, n, m, upper=max(X)))
+ Ymins <- sapply(Xseq, function(z) rootfun(z, C2, C1, m, n, upper=max(Y)))
+
+ ## needed to tweak original set of rules (extreme case reported
+ ## by Richard Telford failed here)
+ if (all(is.na(Xmins)))
+ Xmins[1] <- 1
+ if (all(is.na(Ymins)))
+ Ymins[1] <- 1
+
+ minval <- list(data.frame(x=Xseq[!is.na(Ymins)], y=Ymins[!is.na(Ymins)]),
+ data.frame(x=Xmins[!is.na(Xmins)], y=Yseq[!is.na(Xmins)]))
+
+ ## shared but too rare
+ Ymin <- Ymins[1]
+ Xmin <- Xmins[1]
+ sr <- X < Xmin & Y < Ymin
+
+ ## consequence of manually setting Xmin/Ymin resolved here
+ tmp1 <- if (Xmin==1)
+ list(x=1, y=Xmin) else approx(c(Xmin, 1), c(1, Ymin), xout=1:Xmin)
+ tmp2 <- if (Ymin==1)
+ list(x=1, y=Ymin) else approx(c(1, Ymin), c(Xmin, 1), xout=1:Ymin)
+
+ for (i in 1:S) {
+ if (X[i] %in% tmp1$x)
+ sr[i] <- Y[i] < tmp1$y[which(X[i]==tmp1$x)]
+ if (Y[i] %in% tmp2$x)
+ sr[i] <- X[i] < tmp2$y[which(Y[i]==tmp2$x)]
+ }
+ ## classification
+ a <- ifelse(X==0, 1, X)/n # \hat{p_i}
+ b <- ifelse(Y==0, 1, Y)/m # \hat{\pi_i}
+ specX <- !sr & testfun(a, b, C1, C2, n, m) > 0
+ specY <- !sr & testfun(b, a, C2, C1, m, n) > 0
+ gen <- !sr & !specX & !specY
+ ## crosstable
+ tmp <- ifelse(cbind(gen, specY, specX, sr), 1, 0)
+ types <- c("Generalist", paste("Specialist", glabel[1], sep="_"),
+ paste("Specialist", glabel[2], sep="_"), "Too_rare")
+ classes <- factor((1:4)[rowSums(tmp*col(tmp))], levels=1:4)
+ levels(classes) <- c("Generalist", paste("Specialist", glabel[1], sep="_"),
+ paste("Specialist", glabel[2], sep="_"), "Too_rare")
+ tab <- data.frame(Species=spp, y=Y, x=X, Classes=classes)
+ colnames(tab)[2:3] <- paste("Total", glabel, sep="_")
+ rownames(tab) <- NULL
+ class(tab) <- c("clamtest","data.frame")
+ attr(tab, "settings") <- list(labels = glabel,
+ coverage.limit = coverage.limit, specialization = specialization,
+ npoints = npoints, alpha = alpha)
+ attr(tab, "minv") <- minval
+ attr(tab, "coverage") <- structure(c(C2, C1), .Names=glabel)
+ tab
+}
Modified: pkg/vegan/R/commsim.R
===================================================================
--- pkg/vegan/R/commsim.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/commsim.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,24 +1,24 @@
-## this is function to create a commsim object, does some checks
-## there is a finite number of useful arguments here
-## but I added ... to allow for unforeseen algorithms,
-## or being able to reference to external objects
-commsim <-
-function(method, fun, binary, isSeq, mode)
-{
- fun <- if (!missing(fun))
- match.fun(fun) else stop("'fun' missing")
- if (any(!(names(formals(fun)) %in%
- c("x", "n", "nr", "nc", "rs", "cs", "rf", "cf", "s", "fill", "thin", "..."))))
- stop("unexpected arguments in 'fun'")
- out <- structure(list(method = if (!missing(method))
- as.character(method)[1L] else stop("'method' missing"),
- binary = if (!missing(binary))
- as.logical(binary)[1L] else stop("'binary' missing"),
- isSeq = if (!missing(isSeq))
- as.logical(isSeq)[1L] else stop("'isSeq' missing"),
- mode = if (!missing(mode))
- match.arg(as.character(mode)[1L],
- c("integer", "double")) else stop("'mode' missing"),
- fun = fun), class = "commsim")
- out
-}
+## this is function to create a commsim object, does some checks
+## there is a finite number of useful arguments here
+## but I added ... to allow for unforeseen algorithms,
+## or being able to reference to external objects
+commsim <-
+function(method, fun, binary, isSeq, mode)
+{
+ fun <- if (!missing(fun))
+ match.fun(fun) else stop("'fun' missing")
+ if (any(!(names(formals(fun)) %in%
+ c("x", "n", "nr", "nc", "rs", "cs", "rf", "cf", "s", "fill", "thin", "..."))))
+ stop("unexpected arguments in 'fun'")
+ out <- structure(list(method = if (!missing(method))
+ as.character(method)[1L] else stop("'method' missing"),
+ binary = if (!missing(binary))
+ as.logical(binary)[1L] else stop("'binary' missing"),
+ isSeq = if (!missing(isSeq))
+ as.logical(isSeq)[1L] else stop("'isSeq' missing"),
+ mode = if (!missing(mode))
+ match.arg(as.character(mode)[1L],
+ c("integer", "double")) else stop("'mode' missing"),
+ fun = fun), class = "commsim")
+ out
+}
Modified: pkg/vegan/R/contribdiv.R
===================================================================
--- pkg/vegan/R/contribdiv.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/contribdiv.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,52 +1,52 @@
-## Contribution diversity
-## Lu, H.P., H.H. Wagner and X.Y. Chen (2007).
-## A contribution diversity approach to evaluate species diversity.
-## Basic and Applied Ecology 8: 1 -12.
-`contribdiv` <-
- function(comm, index = c("richness", "simpson"), relative = FALSE,
- scaled = TRUE, drop.zero = FALSE)
-{
-
- index <- match.arg(index)
-
- x <- comm[rowSums(comm) > 0, colSums(comm) > 0]
- n <- nrow(x)
- S <- ncol(x)
-
- if (index == "richness") {
- n.i <- colSums(x > 0)
- S.k <- rowSums(x > 0)
- alpha <- S.k / n
- beta <- apply(x, 1, function(z) sum((n - n.i[z > 0]) / (n * n.i[z > 0])))
- denom <- 1
- } else {
- P.ik <- decostand(x, "total")
- P.i <- apply(P.ik, 2, function(z) sum(z) / n)
- P.i2 <- matrix(P.i, n, S, byrow=TRUE)
- alpha <- diversity(x, "simpson")
- beta <- rowSums(P.ik * (P.ik - P.i2))
- denom <- n
- }
- gamma <- alpha + beta
- D <- sum(beta) / sum(gamma)
- if (relative) {
- denom <- if (scaled)
- {denom * sum(gamma)} else 1
- alpha <- (alpha - mean(alpha)) / denom
- beta <- (beta - mean(beta)) / denom
- gamma <- (gamma - mean(gamma)) / denom
- }
- rval <- data.frame(alpha = alpha, beta = beta, gamma = gamma)
- if (!drop.zero && nrow(comm) != n) {
- nas <- rep(NA, nrow(comm))
- rval2 <- data.frame(alpha = nas, beta = nas, gamma = nas)
- rval2[rowSums(comm) > 0, ] <- rval
- rval <- rval2
- }
- attr(rval, "diff.coef") <- D
- attr(rval, "index") <- index
- attr(rval, "relative") <- relative
- attr(rval, "scaled") <- scaled
- class(rval) <- c("contribdiv", "data.frame")
- rval
-}
+## Contribution diversity
+## Lu, H.P., H.H. Wagner and X.Y. Chen (2007).
+## A contribution diversity approach to evaluate species diversity.
+## Basic and Applied Ecology 8: 1 -12.
+`contribdiv` <-
+ function(comm, index = c("richness", "simpson"), relative = FALSE,
+ scaled = TRUE, drop.zero = FALSE)
+{
+
+ index <- match.arg(index)
+
+ x <- comm[rowSums(comm) > 0, colSums(comm) > 0]
+ n <- nrow(x)
+ S <- ncol(x)
+
+ if (index == "richness") {
+ n.i <- colSums(x > 0)
+ S.k <- rowSums(x > 0)
+ alpha <- S.k / n
+ beta <- apply(x, 1, function(z) sum((n - n.i[z > 0]) / (n * n.i[z > 0])))
+ denom <- 1
+ } else {
+ P.ik <- decostand(x, "total")
+ P.i <- apply(P.ik, 2, function(z) sum(z) / n)
+ P.i2 <- matrix(P.i, n, S, byrow=TRUE)
+ alpha <- diversity(x, "simpson")
+ beta <- rowSums(P.ik * (P.ik - P.i2))
+ denom <- n
+ }
+ gamma <- alpha + beta
+ D <- sum(beta) / sum(gamma)
+ if (relative) {
+ denom <- if (scaled)
+ {denom * sum(gamma)} else 1
+ alpha <- (alpha - mean(alpha)) / denom
+ beta <- (beta - mean(beta)) / denom
+ gamma <- (gamma - mean(gamma)) / denom
+ }
+ rval <- data.frame(alpha = alpha, beta = beta, gamma = gamma)
+ if (!drop.zero && nrow(comm) != n) {
+ nas <- rep(NA, nrow(comm))
+ rval2 <- data.frame(alpha = nas, beta = nas, gamma = nas)
+ rval2[rowSums(comm) > 0, ] <- rval
+ rval <- rval2
+ }
+ attr(rval, "diff.coef") <- D
+ attr(rval, "index") <- index
+ attr(rval, "relative") <- relative
+ attr(rval, "scaled") <- scaled
+ class(rval) <- c("contribdiv", "data.frame")
+ rval
+}
Modified: pkg/vegan/R/eventstar.R
===================================================================
--- pkg/vegan/R/eventstar.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/eventstar.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,18 +1,18 @@
-eventstar <- function(x, qmax=5) {
- if (is.null(dim(x)))
- x <- matrix(x, 1, length(x))
- lossfun <- function(q, x)
- tsallis(x, scales=q, norm=TRUE)
- qstarfun <- function(x) {
- optimize(lossfun, interval=c(0, qmax), x=x)$minimum
- }
- qs <- apply(x, 1, qstarfun)
- Hs <- sapply(1:nrow(x), function(i) tsallis(x[i,],
- scales=qs[i], hill=FALSE))
- S <- rowSums(x)
- Es <- ifelse(qs==1, log(S), Hs/((S^(1-qs)-1)/(1-qs)))
- Ds <- (1-(qs-1)*Hs)^(1/(1-qs))
- out <- data.frame(qstar=qs, Estar=Es, Hstar=Hs, Dstar=Ds)
- rownames(out) <- rownames(x)
- out
-}
+eventstar <- function(x, qmax=5) {
+ if (is.null(dim(x)))
+ x <- matrix(x, 1, length(x))
+ lossfun <- function(q, x)
+ tsallis(x, scales=q, norm=TRUE)
+ qstarfun <- function(x) {
+ optimize(lossfun, interval=c(0, qmax), x=x)$minimum
+ }
+ qs <- apply(x, 1, qstarfun)
+ Hs <- sapply(1:nrow(x), function(i) tsallis(x[i,],
+ scales=qs[i], hill=FALSE))
+ S <- rowSums(x)
+ Es <- ifelse(qs==1, log(S), Hs/((S^(1-qs)-1)/(1-qs)))
+ Ds <- (1-(qs-1)*Hs)^(1/(1-qs))
+ out <- data.frame(qstar=qs, Estar=Es, Hstar=Hs, Dstar=Ds)
+ rownames(out) <- rownames(x)
+ out
+}
Modified: pkg/vegan/R/indpower.R
===================================================================
--- pkg/vegan/R/indpower.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/indpower.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,25 +1,25 @@
-indpower <-
-function(x, type=0)
-{
- x <- as.matrix(x)
- x <- ifelse(x > 0, 1, 0)
- if (NCOL(x) < 2)
- stop("provide at least 2 columns for 'x'")
- if (!(type %in% 0:2))
- stop("'type' must be in c(0, 1, 2)")
- n <- nrow(x)
- j <- crossprod(x) ## faster t(x) %*% x
- ip1 <- sweep(j, 1, diag(j), "/")
- ip2 <- 1 - sweep(-sweep(j, 2, diag(j), "-"), 1, n - diag(j), "/")
- out <- switch(as.character(type),
- "0" = sqrt(ip1 * ip2),
- "1" = ip1,
- "2" = ip2)
- cn <- if (is.null(colnames(out)))
- 1:ncol(out) else colnames(out)
- rn <- if (is.null(rownames(out)))
- 1:ncol(out) else rownames(out)
- colnames(out) <- paste("t", cn, sep=".")
- rownames(out) <- paste("i", rn, sep=".")
- out
-}
+indpower <-
+function(x, type=0)
+{
+ x <- as.matrix(x)
+ x <- ifelse(x > 0, 1, 0)
+ if (NCOL(x) < 2)
+ stop("provide at least 2 columns for 'x'")
+ if (!(type %in% 0:2))
+ stop("'type' must be in c(0, 1, 2)")
+ n <- nrow(x)
+ j <- crossprod(x) ## faster t(x) %*% x
+ ip1 <- sweep(j, 1, diag(j), "/")
+ ip2 <- 1 - sweep(-sweep(j, 2, diag(j), "-"), 1, n - diag(j), "/")
+ out <- switch(as.character(type),
+ "0" = sqrt(ip1 * ip2),
+ "1" = ip1,
+ "2" = ip2)
+ cn <- if (is.null(colnames(out)))
+ 1:ncol(out) else colnames(out)
+ rn <- if (is.null(rownames(out)))
+ 1:ncol(out) else rownames(out)
+ colnames(out) <- paste("t", cn, sep=".")
+ rownames(out) <- paste("i", rn, sep=".")
+ out
+}
Modified: pkg/vegan/R/make.commsim.R
===================================================================
--- pkg/vegan/R/make.commsim.R 2014-10-16 08:50:18 UTC (rev 2901)
+++ pkg/vegan/R/make.commsim.R 2014-10-16 08:50:21 UTC (rev 2902)
@@ -1,436 +1,436 @@
-## this lists all known algos in vegan and more
-## if method is commsim object, it is returned
-## if it is character, switch returns the right one, else stop with error
-## so it can be used instead of match.arg(method) in other functions
-## NOTE: very very long -- but it can be a central repository of algos
-## NOTE 2: storage mode coercions are avoided here
-## (with no apparent effect on speed), it should be
-## handled by nullmodel and commsim characteristics
-make.commsim <-
-function(method)
-{
- algos <- list(
- "r00" = commsim(method="r00", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- matrix(0L, nr * nc, n)
- for (k in seq_len(n))
- out[sample.int(nr * nc, s), k] <- 1L
- dim(out) <- c(nr, nc, n)
- out
- }),
- "c0" = commsim(method="c0", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- J <- seq_len(nc)
- for (k in seq_len(n))
- for (j in J)
- out[sample.int(nr, cs[j]), j, k] <- 1L
- out
- }),
- "r0" = commsim(method="r0", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- I <- seq_len(nr)
- for (k in seq_len(n))
- for (i in I)
- out[i, sample.int(nc, rs[i]), k] <- 1L
- out
- }),
- "r0_old" = commsim(method="r0_old", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- I <- seq_len(nr)
- p <- rep(1, nc)
- for (k in seq_len(n))
- for (i in I)
- out[i, sample.int(nc, rs[i], prob = p), k] <- 1L
- out
- }),
- "r1" = commsim(method="r1", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- I <- seq_len(nr)
- storage.mode(cs) <- "double"
- for (k in seq_len(n))
- for (i in I)
- out[i, sample.int(nc, rs[i], prob=cs), k] <- 1L
- out
- }),
- "r2" = commsim(method="r2", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- p <- cs * cs
- I <- seq_len(nr)
- for (k in seq_len(n))
- for (i in I)
- out[i, sample.int(nc, rs[i], prob=p), k] <- 1L
- out
- }),
- "quasiswap" = commsim(method="quasiswap", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(unlist(r2dtable(n, rs, cs)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n))
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- out
- }),
- "swap" = commsim(method="swap", binary=TRUE, isSeq=TRUE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- out[,,1] <- .C("swap",
- m = x, nr, nc, thin, PACKAGE = "vegan")$m
- for (k in seq_len(n-1))
- out[,,k+1] <- .C("swap",
- m = out[,,k], nr, nc, thin,
- PACKAGE = "vegan")$m
- out
- }),
- "tswap" = commsim(method="tswap", binary=TRUE, isSeq=TRUE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- out[,,1] <- .C("trialswap",
- m = x, nr, nc, thin, PACKAGE = "vegan")$m
- for (k in seq_len(n-1))
- out[,,k+1] <- .C("trialswap",
- m = out[,,k], nr, nc, thin, PACKAGE = "vegan")$m
- out
- }),
- "backtrack" = commsim(method="backtrack", binary=TRUE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
- btrfun <- function() {
- all <- matrix(as.integer(1:(nr * nc)), nrow = nr, ncol = nc)
- out <- matrix(0L, nrow = nr, ncol = nc)
- free <- matrix(as.integer(1:(nr * nc)), nrow = nr)
- icount <- integer(length(rs))
- jcount <- integer(length(cs))
- prob <- outer(rs, cs, "*")
- ij <- sample(free, prob = prob)
- i <- (ij - 1)%%nr + 1
- j <- (ij - 1)%/%nr + 1
- for (k in 1:length(ij)) {
- if (icount[i[k]] < rs[i[k]] && jcount[j[k]] < cs[j[k]]) {
- out[ij[k]] <- 1L
- icount[i[k]] <- icount[i[k]] + 1L
- jcount[j[k]] <- jcount[j[k]] + 1L
- }
- }
- ndrop <- 1
- for (i in 1:10000) {
- oldout <- out
- oldn <- sum(out)
- drop <- sample(all[out == 1L], ndrop)
- out[drop] <- 0L
- candi <- outer(rowSums(out) < rs, colSums(out) < cs, "&") & out == 0L
- while (sum(candi) > 0) {
- if (sum(candi) > 1)
- ij <- sample(all[candi], 1)
- else ij <- all[candi]
- out[ij] <- 1L
- candi <- outer(rowSums(out) < rs, colSums(out) < cs, "&") & out == 0
- }
- if (sum(out) >= fill)
- break
- if (oldn >= sum(out))
- ndrop <- min(ndrop + 1, 4)
- else ndrop <- 1
- if (oldn > sum(out))
- out <- oldout
- }
- out
- }
- out <- array(0L, c(nr, nc, n))
- for (k in seq_len(n))
- out[, , k] <- btrfun()
- out
- }),
- "r2dtable" = commsim(method="r2dtable", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(unlist(r2dtable(n, rs, cs)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- out
- }),
- "swap_count" = commsim(method="swap_count", binary=FALSE, isSeq=TRUE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(0L, c(nr, nc, n))
- out[,,1] <- .C("swapcount",
- m = x, nr, nc, thin, PACKAGE = "vegan")$m
- for (k in seq_len(n-1))
- out[,,k+1] <- .C("swapcount",
- m = out[,,k], nr, nc, thin, PACKAGE = "vegan")$m
- out
- }),
- "quasiswap_count" = commsim(method="quasiswap_count", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(unlist(r2dtable(n, rs, cs)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n))
- out[,,k] <- .C("rswapcount",
- m = out[,,k], nr, nc, fill, PACKAGE = "vegan")$m
- out
- }),
- "swsh_samp" = commsim(method="swsh_samp", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- nz <- as.integer(x[x > 0])
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- out[,,k][out[,,k] > 0] <- sample(nz) # we assume that length(nz)>1
- }
- out
- }),
- "swsh_both" = commsim(method="swsh_both", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- indshuffle <- function(x) {
- drop(rmultinom(1, sum(x), rep(1, length(x))))
- }
- nz <- as.integer(x[x > 0])
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- out[,,k][out[,,k] > 0] <- indshuffle(nz - 1L) + 1L # we assume that length(nz)>1
- }
- out
- }),
- "swsh_samp_r" = commsim(method="swsh_samp_r", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- I <- seq_len(nr)
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- for (i in I) {
- nz <- as.integer(x[i,][x[i,] > 0])
- if (length(nz) == 1)
- out[i,,k][out[i,,k] > 0] <- nz
- if (length(nz) > 1)
- out[i,,k][out[i,,k] > 0] <- sample(nz)
- }
- }
- out
- }),
- "swsh_samp_c" = commsim(method="swsh_samp_c", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- J <- seq_len(nc)
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- for (j in J) {
- nz <- as.integer(x[,j][x[,j] > 0])
- if (length(nz) == 1)
- out[,j,k][out[,j,k] > 0] <- nz
- if (length(nz) > 1)
- out[,j,k][out[,j,k] > 0] <- sample(nz)
- }
- }
- out
- }),
- "swsh_both_r" = commsim(method="swsh_both_r", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- indshuffle <- function(x) {
- drop(rmultinom(1, sum(x), rep(1, length(x))))
- }
- I <- seq_len(nr)
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- for (i in I) {
- nz <- as.integer(x[i,][x[i,] > 0])
- if (length(nz) == 1)
- out[i,,k][out[i,,k] > 0] <- nz
- if (length(nz) > 1)
- out[i,,k][out[i,,k] > 0] <- indshuffle(nz - 1L) + 1L
- }
- }
- out
- }),
- "swsh_both_c" = commsim(method="swsh_both_c", binary=FALSE, isSeq=FALSE,
- mode="integer",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- indshuffle <- function(x) {
- drop(rmultinom(1, sum(x), rep(1, length(x))))
- }
- J <- seq_len(nc)
- out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
- for (k in seq_len(n)) {
- out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
- for (j in J) {
- nz <- as.integer(x[,j][x[,j] > 0])
- if (length(nz) == 1)
- out[,j,k][out[,j,k] > 0] <- nz
- if (length(nz) > 1)
- out[,j,k][out[,j,k] > 0] <- indshuffle(nz - 1L) + 1L
- }
- }
- out
- }),
- "abuswap_r" = commsim(method="abuswap_r", binary=FALSE, isSeq=TRUE,
- mode="double",
- fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- out <- array(0, c(nr, nc, n))
- out[,,1] <- .C("abuswap",
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/vegan -r 2902
From noreply at r-forge.r-project.org Wed Oct 22 10:26:23 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 22 Oct 2014 10:26:23 +0200 (CEST)
Subject: [Vegan-commits] r2903 - in pkg/vegan: R man
Message-ID: <20141022082623.391DF18740E@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-22 10:26:22 +0200 (Wed, 22 Oct 2014)
New Revision: 2903
Modified:
pkg/vegan/R/anova.cca.R
pkg/vegan/man/permutations.Rd
Log:
Squashed commit of the following:
commit 05ced8cfb03aa540abc415be0e91baa59e486856
Merge: 2b4aa54 efd575f
Author: Jari Oksanen
Date: Wed Oct 22 10:27:16 2014 +0300
Merge pull request #60 from gavinsimpson/fix-argument-passing-in-anova
pass relevant named arguments from anova.cca to permutest.cca
commit efd575f1f654348dad12245e19ca2f276ea7c7dc
Author: Gavin Simpson
Date: Mon Oct 20 16:19:59 2014 -0600
pass relevant named arguments from anova.cca to permutest.cca
commit 2b4aa54974f330357b8c5323987866e96a895cf0
Author: Gavin Simpson
Date: Thu Oct 16 22:00:50 2014 -0600
some minor tweaks, fixes for typos, and a clarification
commit 31d2e8f9317d1562a558e095d1ef59b093d985b8
Merge: eada1ca 845060a
Author: Gavin Simpson
Date: Thu Oct 16 20:59:41 2014 -0600
Merge pull request #57 from gavinsimpson/improve-permutations-rd
Improve permutations.Rd
commit 845060a209d9512c935b346af125abe390694431
Author: Gavin Simpson
Date: Thu Oct 16 20:36:16 2014 -0600
sampleSet -> shuffleSet typo
commit cf642a5834743ad07c7f475a08a6a36aa15988a6
Author: Gavin Simpson
Date: Thu Oct 16 20:30:05 2014 -0600
add davison and hinkley reference
commit 3a64ee41e734cab1074e89c9a4b2b342dc9c9627
Author: Gavin Simpson
Date: Wed Oct 15 21:38:03 2014 -0600
final round of edits for draft of revised intro to permutations for vegan users
commit c7fee52e21ccf1db3f6ab19330a0b22c591eb450
Author: Gavin Simpson
Date: Wed Oct 15 20:24:38 2014 -0600
first stab at updates to the permutations Rd file
Modified: pkg/vegan/R/anova.cca.R
===================================================================
--- pkg/vegan/R/anova.cca.R 2014-10-16 08:50:21 UTC (rev 2902)
+++ pkg/vegan/R/anova.cca.R 2014-10-22 08:26:22 UTC (rev 2903)
@@ -2,7 +2,7 @@
function(object, ..., permutations = how(nperm=999), by = NULL,
model = c("reduced", "direct", "full"),
parallel = getOption("mc.cores"), strata = NULL,
- cutoff = 1, scope = NULL)
+ cutoff = 1, scope = NULL)
{
model <- match.arg(model)
## permutation matrix
@@ -21,7 +21,7 @@
dotargs <- dotargs[isCCA]
object <- c(list(object), dotargs)
sol <-
- anova.ccalist(object,
+ anova.ccalist(object,
permutations = permutations,
model = model,
parallel = parallel)
@@ -54,15 +54,17 @@
return(sol)
}
## basic overall test
- tst <- permutest.cca(object, permutations = permutations, ...)
+ tst <- permutest.cca(object, permutations = permutations,
+ model = model, parallel = parallel,
+ strata = strata, ...)
Fval <- c(tst$F.0, NA)
Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1)
Pval <- c(Pval, NA)
table <- data.frame(tst$df, tst$chi, Fval, Pval)
is.rda <- inherits(object, "rda")
- colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"),
+ colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"),
"F", "Pr(>F)")
- head <- paste0("Permutation test for ", tst$method, " under ",
+ head <- paste0("Permutation test for ", tst$method, " under ",
tst$model, " model\n", howHead(control))
mod <- paste("Model:", c(object$call))
structure(table, heading = c(head, mod), Random.seed = seed,
Modified: pkg/vegan/man/permutations.Rd
===================================================================
--- pkg/vegan/man/permutations.Rd 2014-10-16 08:50:21 UTC (rev 2902)
+++ pkg/vegan/man/permutations.Rd 2014-10-22 08:26:22 UTC (rev 2903)
@@ -3,35 +3,58 @@
\title{Permutation tests in Vegan}
\description{
- Unless stated otherwise, vegan currently provides for two types of
- permutation test:
+ From version 2.2-0, \pkg{vegan} has significantly improved access to
+ restricted permutations which brings it into line with those offered
+ by Canoco. The permutation designs are modelled after the permutation
+ schemes of Canoco 3.1 (ter Braak, 1990).
+
+ \pkg{vegan} currently provides for the following features within
+ permutation tests:
\enumerate{
- \item{Free permutation of \emph{DATA}, also known as randomisation,
+ \item{Free permutation of \emph{DATA}, also known as randomisation,}
+ \item{Free permutation of \emph{DATA} within the levels of a
+ grouping variable,}
+ \item{Restricted permutations for line transects or time series,}
+ \item{Permutation of groups of samples whilst retaining the
+ within-group ordering,}
+ \item{Restricted permutations for spatial grids,}
+ \item{Blocking, samples are never permuted \emph{between} blocks,
and}
- \item{Free permutation of \emph{DATA} within the levels of a factor
- variable.}
+ \item{Split-plot designs, with permutation of whole plots, split
+ plots, or both.}
}
- We use \emph{DATA} to mean either the observed data themselves or some
- function of the data, for example the residuals of an ordination model
- in the presence of covariables.
+ Above, we use \emph{DATA} to mean either the observed data themselves
+ or some function of the data, for example the residuals of an
+ ordination model in the presence of covariables.
- The second type of permutation test above is available if the function
- providing the test accepts an argument \code{strata} or passes
- additional arguments (via \code{\dots}) to
- \code{permuted.index}.
+ These capabilities are provided by functions from the \pkg{permute}
+ package. The user can request a particular type of permutation by
+ supplying the \code{permutations} argument of a function with an
+ object returned by \code{\link{how}}, which defines how samples should
+ be permuted. Alternatively, the user can simply specify the required
+ number of permutations and a simple randomisation procedure will be
+ performed. Finally, the user can supply a matrix of permutations (with
+ number of rows equal to the number of permutations and number of
+ columns equal to the number of observations in the data) and
+ \pkg{vegan} will use these permutations instead of generating new
+ permutations.
+
+ The majority of functions in \pkg{vegan} allow for the full range of
+ possibilities outlined above. Exceptions include
+ \code{\link{kendall.post}} and \code{\link{kendall.global}}.
- The Null hypothesis for these two types of permutation test assumes
- free exchangeability of \emph{DATA} (within the levels of
- \code{strata} if specified). Dependence between observations, such as
- that which arises due to spatial or temporal autocorrelation, or
- more-complicated experimental designs, such as split-plot designs,
- violates this fundamental assumption of the test and requires restricted
- permutation test designs. The next major version of Vegan will include
- infrastructure to handle these more complicated permutation designs.
+ The Null hypothesis for the first two types of permutation test listed
+ above assumes free exchangeability of \emph{DATA} (within the levels
+ of the grouping variable, if specified). Dependence between
+ observations, such as that which arises due to spatial or temporal
+ autocorrelation, or more-complicated experimental designs, such as
+ split-plot designs, violates this fundamental assumption of the test
+ and requires more complex restricted permutation test designs. It is
+ these designs that are available via the \pkg{permute} package and to
+ which \pkg{vegan} provides access from version 2.2-0 onwards.
- Again, unless otherwise stated in the help pages for specific
- functions, permutation tests in Vegan all follow the same
- format/structure:
+ Unless otherwise stated in the help pages for specific functions,
+ permutation tests in \pkg{vegan} all follow the same format/structure:
\enumerate{
\item{An appropriate test statistic is chosen. Which statistic is
chosen should be described on the help pages for individual
@@ -40,63 +63,109 @@
data and analysis/model and recorded. Denote this value
\eqn{x_0}{x[0]}.}
\item{The \emph{DATA} are randomly permuted according to one of the
- above two schemes, and the value of the test statistic for this
+ above schemes, and the value of the test statistic for this
permutation is evaluated and recorded.}
\item{Step 3 is repeated a total of \eqn{n} times, where \eqn{n} is
the number of permutations requested. Denote these values as
\eqn{x_i}{x[i]}, where \eqn{i = 1, ..., n}{{i = 1, \ldots, n}.}}
- \item{The values of the test statistic for the \eqn{n} permutations
- of the \emph{DATA} are added to the value of the test statistic
- for the observed data. These \emph{n + 1} values represent the
- \emph{Null} or \emph{randomisation} distribution of the test
- statistic. The observed value for the test statistic is included
- in the Null distribution because under the Null hypothesis being
- tested, the observed value is just a typical value of the test
- statistic, inherently no different from the values obtained via
- permutation of \emph{DATA}.}
- \item{The number of times that a value of the test statistic in the
- Null distribution is equal to or greater than the value of the
- test statistic for the observed data is recorded. Note the point
- mentioned in step 5 above; the Null distribution includes the
- \strong{observed} value of the test statistic. Denote this count
- as \eqn{N}.}
+ \item{Count the number of values of the test statistic,
+ \eqn{x_i}{x[i]}, in the Null distribution that are as extreme as
+ test statistic for the observed data \eqn{x_0}{x[0]}. Denote this
+ count as \eqn{N}.
+
+ We use the phrase \emph{as extreme} to include cases where a
+ two-sided test is performed and large negative values of the test
+ statistic should be considered.}
\item{The permutation p-value is computed as
- \deqn{p = \frac{N}{n + 1}}{N / (n + 1)}}
+ \deqn{p = \frac{N + 1}{n + 1}}{(N + 1) / (n + 1)}}
}
+
The above description illustrates why the default number of
- permutations specified in Vegan functions takes values of 199 or 999
- for example. Once the observed value of the test statistic is added to
- this number of random permutations of \emph{DATA}, pretty p-values are
- achievable because \eqn{n + 1} becomes 200 or 1000, for example.
+ permutations specified in \pkg{vegan} functions takes values of 199 or
+ 999 for example. Pretty \emph{p} values are achieved because the
+ \eqn{+ 1} in the denominator results in division by 200 or 1000, for
+ the 199 or 999 random permutations used in the test.
- The minimum achievable p-value is
- \deqn{p_{\mathrm{min}} = \frac{1}{n +1}}{p[min] = 1 / (n + 1)}
+ The simple intuition behind the presence of \eqn{+ 1} in the numerator
+ and denominator is that these represent the inclusion of the observed
+ value of the statistic in the Null distribution (e.g. Manly 2006).
+ Phipson & Smyth (2010) present a more compelling explanation for the
+ inclusion of \eqn{+ 1} in the numerator and denominator of the
+ \emph{p} value calculation.
+
+ Fisher (1935) had in mind that a permutation test would involve
+ enumeration of all possible permutations of the data yielding an exact
+ test. However, doing this complete enumeration may not be feasible in
+ practice owing to the potentially vast number of arrangements of the
+ data, even in modestly-sized data sets with free permutation of
+ samples. As a result we evaluate the \emph{p} value as the tail
+ probability of the Null distribution of the test statistic directly
+ from the random sample of possible permutations. Phipson & Smyth
+ (2010) show that the naive calculation of the permutation \emph{p}
+ value is
+
+ \deqn{p = \frac{N}{n}}{p = (N / n)}
+
+ which leads to an invalid test with incorrect type I error rate. They
+ go on to show that by replacing the unknown tail probability (the
+ \emph{p} value) of the Null distribution with the biased estimator
+
+ \deqn{p = \frac{N + 1}{n + 1}}{p = (N + 1 / n + 1)}
- A more common definition, in ecological circles, for \eqn{N} would be
- the number of \eqn{x_i}{x[i]} greater than or equal to
- \eqn{x_0}{x[0]}. The permutation p-value would then be defined as
- \deqn{p = \frac{N + 1}{n + 1}}{(N + 1) / (n + 1)}
- The + 1 in the numerator of the above equation represents the observed
- statistic \eqn{x_0}{x[0]}. The minimum p-value would then be defined as
- \deqn{p_{\mathrm{min}} = \frac{0 + 1}{n +1}}{p[min] = 0 + 1 / (n + 1)}
- However this definition discriminates between the observed
- statistic and the other \eqn{x_i}{x[i]}. Under the Null hypothesis
- there is no such distinction, hence we prefer the definintion used in
- the numbered steps above.
+ that the positive bias induced is of just the right size to
+ account for the uncertainty in the estimation of the tail probability
+ from the set of randomly sampled permutations to yield a test with the
+ correct type I error rate.
- One cannot simply increase the number of permutations
- (\eqn{n}) to achieve a potentially lower p-value unless the number of
- observations available permits such a number of permutations. This is
- unlikely to be a problem for all but the smallest data sets when
- free permutation (randomisation) is valid, but in designs where
- \code{strata} is specified and there are a low number of observations
- within each level of \code{strata}, there may not be as many actual
- permutations of the data as you might want.
+ The estimator described above is correct for the situation where
+ permutations of the data are samples randomly \emph{without}
+ replacement. This is not strictly what happens in \pkg{vegan} because
+ permutations are drawn pseudo-randomly independent of one
+ another. Note that the actual chance of this happening is practice is
+ small but the functions in \pkg{permute} do not guarantee to generate
+ a unique set of permutations unless complete enumeration of
+ permutations is requested. This is not feasible for all but the
+ smallest of data sets or restrictive of permutation designs, but in
+ such cases the chance of drawing a set of permutations with repeats is
+ lessened as the sample size, and thence the size of set of all
+ possible permutations, increases.
+
+ Under the situation of sampling permutations with replacement then,
+ the tail probability \eqn{p} calculated from the biased estimator
+ described above is somewhat \strong{conservative}, being too large by
+ an amount that depends on the number of possible values that the test
+ statistic can take under permutation of the data (Phipson & Smyth,
+ 2010). This represents a slight loss of statistical power for the
+ conservative \emph{p} value calculation used here. However, unless
+ smaples sizes are small and the the permutation design such that the
+ set of values that the test statistic can take is also small, this
+ loss of power is unlikely to be critical.
+
+ The minimum achievable p-value is
+
+ \deqn{p_{\mathrm{min}} = \frac{1}{n + 1}}{p[min] = 1 / (n + 1)}
+
+ and hence depends on the number of permutations evaluated. However,
+ one cannot simply increase the number of permutations (\eqn{n}) to
+ achieve a potentially lower p-value unless the number of observations
+ available permits such a number of permutations. This is unlikely to
+ be a problem for all but the smallest data sets when free permutation
+ (randomisation) is valid, but in restricted permutation designs with a
+ low number of observations, there may not be as many unique
+ permutations of the data as you might desire to reach the required
+ level of significance.
It is currently the responsibility of the user to determine the total
- number of possible permutations for their \emph{DATA}. No checks are
- made within Vegan functions to ensure a sensible number of
- permutations is chosen.
+ number of possible permutations for their \emph{DATA}. The number of
+ possible permutations allowed under the specified design can be
+ calculated using \code{\link[permute]{numPerms}} from the
+ \pkg{permute} package. Heuristics employed within the
+ \code{\link[permute]{shuffleSet}} function used by \pkg{vegan} can be
+ triggered to generate the entire set of permutations instead of a
+ random set. The settings controlling the triggering of the complete
+ enumeration step are contained within a permutation design created
+ using \code{link[permute]{how}} and can be set by the user. See
+ \code{\link[permute]{how}} for details.
Limits on the total number of permutations of \emph{DATA} are more
severe in temporally or spatially ordered data or experimental designs
@@ -106,17 +175,43 @@
In situations where only a low number of permutations is possible due
to the nature of \emph{DATA} or the experimental design, enumeration
- of all permutations becomes important and achievable
- computationally. Currently, Vegan does not include functions to
- perform complete enumeration of the set of possible
- permutations. The next major release of Vegan will include such
- functionality, however.
+ of all permutations becomes important and achievable computationally.
+
+ Above, we have provided only a brief overview of the capbilities of
+ \pkg{vegan} and \pkg{permute}. To get the best out of the new
+ functionality and for details on how to set up permutation designs
+ using \code{\link[permute]{how}}, consult the vignette
+ \emph{Restricted permutations; using the permute package} supplied
+ with \pkg{permute} and accessible via \code{vignette("permutations",
+ package = "permute").}
}
\seealso{
- \code{\link{permutest}}
+ \code{\link{permutest}} for the main interface in \pkg{vegan}. See
+ also \code{\link[permute]{how}} for details on permutation design
+ specification, \code{\link[permute]{shuffleSet}} for the code used to
+ generate a set of permutations, \code{\link[permute]{numPerms}} for
+ a function to return the size of the set of possible permutations
+ under the current design.
}
-%\references{
-%}
-\author{ Gavin Simpson }
+
+\references{
+
+ Manly, B. F. J. (2006). \emph{Randomization, Bootstrap and Monte Carlo
+ Methods in Biology}, Third Edition. Chapman and Hall/CRC.
+
+ Phipson, B., & Smyth, G. K. (2010). Permutation P-values should never
+ be zero: calculating exact P-values when permutations are randomly
+ drawn. \emph{Statistical Applications in Genetics and Molecular
+ Biology}, \strong{9}, Article 39. DOI: 10.2202/1544-6115.1585
+
+ ter Braak, C. J. F. (1990). \emph{Update notes: CANOCO version
+ 3.1}. Wageningen: Agricultural Mathematics Group. (UR).
+
+ See also:
+
+ Davison, A. C., & Hinkley, D. V. (1997). \emph{Bootstrap Methods and
+ their Application}. Cambridge University Press.
+}
+\author{ Gavin L. Simpson }
\keyword{multivariate}
From noreply at r-forge.r-project.org Thu Oct 23 11:18:30 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Thu, 23 Oct 2014 11:18:30 +0200 (CEST)
Subject: [Vegan-commits] r2904 - pkg/vegan/R
Message-ID: <20141023091830.D51EB1876A6@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-23 11:18:30 +0200 (Thu, 23 Oct 2014)
New Revision: 2904
Modified:
pkg/vegan/R/plot.cca.R
Log:
Squashed commit of the following:
commit 40fef9d21093a5f2a2ce65b2ca5f9f6eda7c3792
Merge: 05ced8c f445e14
Author: Jari Oksanen
Date: Thu Oct 23 12:15:00 2014 +0300
Merge pull request #62 from gavinsimpson/fix-plot-limits-issue
extract all scores when setting x and y limits for plot
Modified: pkg/vegan/R/plot.cca.R
===================================================================
--- pkg/vegan/R/plot.cca.R 2014-10-22 08:26:22 UTC (rev 2903)
+++ pkg/vegan/R/plot.cca.R 2014-10-23 09:18:30 UTC (rev 2904)
@@ -1,12 +1,12 @@
`plot.cca` <-
- function (x, choices = c(1, 2), display = c("sp", "wa", "cn"),
- scaling = 2, type, xlim, ylim, const, ...)
+ function (x, choices = c(1, 2), display = c("sp", "wa", "cn"),
+ scaling = 2, type, xlim, ylim, const, ...)
{
TYPES <- c("text", "points", "none")
g <- scores(x, choices, display, scaling, const)
if (length(g) == 0 || all(is.na(g)))
stop("nothing to plot: requested scores do not exist")
- if (!is.list(g))
+ if (!is.list(g))
g <- list(default = g)
## Take care that there are names
for (i in seq_len(length(g))) {
@@ -15,20 +15,20 @@
prefix = substr(names(g)[i], 1, 3))
}
if (!is.null(g$centroids)) {
- if (is.null(g$biplot))
+ if (is.null(g$biplot))
g$biplot <- scores(x, choices, "bp", scaling)
if (!is.na(g$centroids)[1]) {
bipnam <- rownames(g$biplot)
cntnam <- rownames(g$centroids)
g$biplot <- g$biplot[!(bipnam %in% cntnam), , drop = FALSE]
- if (nrow(g$biplot) == 0)
+ if (nrow(g$biplot) == 0)
g$biplot <- NULL
}
}
if (missing(type)) {
nitlimit <- 80
nit <- max(nrow(g$spe), nrow(g$sit), nrow(g$con), nrow(g$def))
- if (nit > nitlimit)
+ if (nit > nitlimit)
type <- "points"
else type <- "text"
}
@@ -53,36 +53,44 @@
}
return(invisible(pl))
}
- if (missing(xlim))
- xlim <- range(g$spe[, 1], g$sit[, 1], g$con[, 1], g$default[,1],
+ if (missing(xlim)) {
+ xlim <- range(g$species[, 1], g$sites[, 1], g$constraints[, 1],
+ g$biplot[, 1],
+ if (length(g$centroids) > 0 && is.na(g$centroids)) NA else g$centroids[, 1],
+ g$default[, 1],
na.rm = TRUE)
+ }
if (!any(is.finite(xlim)))
stop("no finite scores to plot")
- if (missing(ylim))
- ylim <- range(g$spe[, 2], g$sit[, 2], g$con[, 2], g$default[,2],
+ if (missing(ylim)) {
+ ylim <- range(g$species[, 2], g$sites[, 2], g$constraints[, 2],
+ g$biplot[, 2],
+ if (length(g$centroids) > 0 && is.na(g$centroids)) NA else g$centroids[, 2],
+ g$default[, 2],
na.rm = TRUE)
- plot(g[[1]], xlim = xlim, ylim = ylim, type = "n", asp = 1,
+ }
+ plot(g[[1]], xlim = xlim, ylim = ylim, type = "n", asp = 1,
...)
abline(h = 0, lty = 3)
abline(v = 0, lty = 3)
if (!is.null(g$species)) {
- if (type == "text")
- text(g$species, rownames(g$species), col = "red",
+ if (type == "text")
+ text(g$species, rownames(g$species), col = "red",
cex = 0.7)
- else if (type == "points")
+ else if (type == "points")
points(g$species, pch = "+", col = "red", cex = 0.7)
}
if (!is.null(g$sites)) {
- if (type == "text")
+ if (type == "text")
text(g$sites, rownames(g$sites), cex = 0.7)
- else if (type == "points")
+ else if (type == "points")
points(g$sites, pch = 1, cex = 0.7)
}
if (!is.null(g$constraints)) {
- if (type == "text")
- text(g$constraints, rownames(g$constraints), cex = 0.7,
+ if (type == "text")
+ text(g$constraints, rownames(g$constraints), cex = 0.7,
col = "darkgreen")
- else if (type == "points")
+ else if (type == "points")
points(g$constraints, pch = 2, cex = 0.7, col = "darkgreen")
}
if (!is.null(g$biplot) && nrow(g$biplot) > 0 && type != "none") {
@@ -91,24 +99,24 @@
}
else mul <- 1
attr(g$biplot, "arrow.mul") <- mul
- arrows(0, 0, mul * g$biplot[, 1], mul * g$biplot[, 2],
+ arrows(0, 0, mul * g$biplot[, 1], mul * g$biplot[, 2],
length = 0.05, col = "blue")
biplabs <- ordiArrowTextXY(mul * g$biplot, rownames(g$biplot))
text(biplabs, rownames(g$biplot), col = "blue")
axis(3, at = c(-mul, 0, mul), labels = rep("", 3), col = "blue")
axis(4, at = c(-mul, 0, mul), labels = c(-1, 0, 1), col = "blue")
}
- if (!is.null(g$centroids) && !is.na(g$centroids) && type !=
+ if (!is.null(g$centroids) && !is.na(g$centroids) && type !=
"none") {
- if (type == "text")
+ if (type == "text")
text(g$centroids, rownames(g$centroids), col = "blue")
- else if (type == "points")
+ else if (type == "points")
points(g$centroids, pch = "x", col = "blue")
}
if (!is.null(g$default) && type != "none") {
- if (type == "text")
+ if (type == "text")
text(g$default, rownames(g$default), cex = 0.7)
- else if (type == "points")
+ else if (type == "points")
points(g$default, pch = 1, cex = 0.7)
}
class(g) <- "ordiplot"
From noreply at r-forge.r-project.org Wed Oct 29 09:36:32 2014
From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org)
Date: Wed, 29 Oct 2014 09:36:32 +0100 (CET)
Subject: [Vegan-commits] r2905 - in pkg/vegan: R man
Message-ID: <20141029083633.10E321877A2@r-forge.r-project.org>
Author: jarioksa
Date: 2014-10-29 09:36:32 +0100 (Wed, 29 Oct 2014)
New Revision: 2905
Modified:
pkg/vegan/R/make.commsim.R
pkg/vegan/man/adipart.Rd
pkg/vegan/man/adonis.Rd
pkg/vegan/man/anosim.Rd
pkg/vegan/man/bioenv.Rd
pkg/vegan/man/clamtest.Rd
pkg/vegan/man/commsim.Rd
pkg/vegan/man/mantel.Rd
pkg/vegan/man/metaMDS.Rd
pkg/vegan/man/mrpp.Rd
pkg/vegan/man/multipart.Rd
pkg/vegan/man/oecosimu.Rd
pkg/vegan/man/ordisurf.Rd
pkg/vegan/man/permatfull.Rd
pkg/vegan/man/simper.Rd
Log:
Squashed commit of the following:
commit 6819b9dc3d8be4a57dc90a353a116dcaf730b9bb
Merge: a15feb5 4855881
Author: Jari Oksanen
Date: Wed Oct 29 10:04:10 2014 +0200
Merge pull request #65 from jarioksa/dollar-and-data-usage
Dollar and data usage
commit a15feb54164ea48042d6a7f8582701979376d56f
Merge: bb4b8bd 5af6b9d
Author: Jari Oksanen
Date: Wed Oct 29 10:03:21 2014 +0200
Merge pull request #63 from jarioksa/swsh-samp-works-with-double
swsh_samp null models can be used with non-integer quantities
commit 5af6b9d26fd220d1ec314a8de40336fd32939478
Author: Jari Oksanen
Date: Tue Oct 28 18:21:04 2014 +0200
Further clarification of swsh methods, like suggested by Peter Solymos
commit 485588172ea06f402b84f0e0b705845e49aeb082
Author: Jari Oksanen
Date: Tue Oct 28 16:07:33 2014 +0200
clean up edits
commit 1027a101b7f77c3dfaac8fe55910019b2400b8f5
Author: Jari Oksanen
Date: Tue Oct 28 15:56:04 2014 +0200
ordisurf has formula & data=, it does not need with()
commit f4543bed4c83603fc6fe6e608c4ec1cd44485ac9
Author: Jari Oksanen
Date: Tue Oct 28 15:44:43 2014 +0200
Use residuals(x) instead of x$residuals in permatfull examples
commit 5d51dc282c4d7932374c9b144ff104ef184f0b87
Author: Jari Oksanen
Date: Tue Oct 28 15:42:02 2014 +0200
Remove dollars from mrpp and multipart examples
commit def279b08ed4aa1233674d6ec68a0b6db2dd8a9c
Author: Jari Oksanen
Date: Tue Oct 28 15:35:06 2014 +0200
Remove $ from clamtest example
commit 4ba8c7e6116daec96ba7efa826bf8c67dcba6e76
Author: Jari Oksanen
Date: Tue Oct 28 15:29:44 2014 +0200
Avoid some $ signs in adonis examples
commit a1eaa183e10ea54f2644484d934855e43a2d7581
Author: Jari Oksanen
Date: Tue Oct 28 15:25:41 2014 +0200
Avoid $ with data frame, and force asp=1 in plotting maps of points
commit 78bf998d0d9e1033e791dc2efb0382761005b3b5
Author: Jari Oksanen
Date: Tue Oct 28 14:35:16 2014 +0200
swsh_samp null models can be used with non-integer quantities
swsh_samp, swsh_samp_c and swsh_samp_r null models shuffle original
cell values and can also be used with non-integer data. They were
unnecessarily restricted to integers. The swsh_both models
redistribute individuals among non-zero cells and can only be used
with integer values.
commit bb4b8bd0df28072e3aeb39be4521f717e06468ee
Author: Jari Oksanen
Date: Mon Oct 27 11:05:54 2014 +0200
remove refs to R 2.14.0 in man/: we depend on later version of R
Modified: pkg/vegan/R/make.commsim.R
===================================================================
--- pkg/vegan/R/make.commsim.R 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/R/make.commsim.R 2014-10-29 08:36:32 UTC (rev 2905)
@@ -183,14 +183,14 @@
out
}),
"swsh_samp" = commsim(method="swsh_samp", binary=FALSE, isSeq=FALSE,
- mode="integer",
+ mode="double",
fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
- nz <- as.integer(x[x > 0])
+ nz <- x[x > 0]
out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
+ storage.mode(out) <- "double"
for (k in seq_len(n)) {
out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
+ m = as.integer(out[,,k]), nr, nc, PACKAGE = "vegan")$m
out[,,k][out[,,k] > 0] <- sample(nz) # we assume that length(nz)>1
}
out
@@ -212,16 +212,16 @@
out
}),
"swsh_samp_r" = commsim(method="swsh_samp_r", binary=FALSE, isSeq=FALSE,
- mode="integer",
+ mode="double",
fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
+ storage.mode(out) <- "double"
I <- seq_len(nr)
for (k in seq_len(n)) {
out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
+ m = as.integer(out[,,k]), nr, nc, PACKAGE = "vegan")$m
for (i in I) {
- nz <- as.integer(x[i,][x[i,] > 0])
+ nz <- x[i,][x[i,] > 0]
if (length(nz) == 1)
out[i,,k][out[i,,k] > 0] <- nz
if (length(nz) > 1)
@@ -231,16 +231,16 @@
out
}),
"swsh_samp_c" = commsim(method="swsh_samp_c", binary=FALSE, isSeq=FALSE,
- mode="integer",
+ mode="double",
fun=function(x, n, nr, nc, cs, rs, rf, cf, s, fill, thin) {
out <- array(unlist(r2dtable(fill, rf, cf)), c(nr, nc, n))
- storage.mode(out) <- "integer"
+ storage.mode(out) <- "double"
J <- seq_len(nc)
for (k in seq_len(n)) {
out[,,k] <- .C("quasiswap",
- m = out[,,k], nr, nc, PACKAGE = "vegan")$m
+ m = as.integer(out[,,k]), nr, nc, PACKAGE = "vegan")$m
for (j in J) {
- nz <- as.integer(x[,j][x[,j] > 0])
+ nz <- x[,j][x[,j] > 0]
if (length(nz) == 1)
out[,j,k][out[,j,k] > 0] <- nz
if (length(nz) > 1)
Modified: pkg/vegan/man/adipart.Rd
===================================================================
--- pkg/vegan/man/adipart.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/adipart.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -162,16 +162,16 @@
out[which(x > cut[i] & x <= cut[(i + 1)])] <- i
return(out)}
## The hierarchy of sample aggregation
-levsm <- data.frame(
+levsm <- with(mite.xy, data.frame(
l1=1:nrow(mite),
- l2=cutter(mite.xy$y, cut = seq(0, 10, by = 2.5)),
- l3=cutter(mite.xy$y, cut = seq(0, 10, by = 5)),
- l4=cutter(mite.xy$y, cut = seq(0, 10, by = 10)))
+ l2=cutter(y, cut = seq(0, 10, by = 2.5)),
+ l3=cutter(y, cut = seq(0, 10, by = 5)),
+ l4=cutter(y, cut = seq(0, 10, by = 10))))
## Let's see in a map
par(mfrow=c(1,3))
-plot(mite.xy, main="l1", col=as.numeric(levsm$l1)+1)
-plot(mite.xy, main="l2", col=as.numeric(levsm$l2)+1)
-plot(mite.xy, main="l3", col=as.numeric(levsm$l3)+1)
+plot(mite.xy, main="l1", col=as.numeric(levsm$l1)+1, asp = 1)
+plot(mite.xy, main="l2", col=as.numeric(levsm$l2)+1, asp = 1)
+plot(mite.xy, main="l3", col=as.numeric(levsm$l3)+1, asp = 1)
par(mfrow=c(1,1))
## Additive diversity partitioning
adipart(mite, index="richness", nsimul=19)
Modified: pkg/vegan/man/adonis.Rd
===================================================================
--- pkg/vegan/man/adonis.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/adonis.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -38,7 +38,7 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
\item{\dots}{Other arguments passed to \code{vegdist}.}
}
@@ -211,10 +211,10 @@
mod <- metaMDS(Y)
plot(mod)
### Hulls show treatment
-ordihull(mod, group=dat$NO3, show="0")
-ordihull(mod, group=dat$NO3, show="10", col=3)
+with(dat, ordihull(mod, group=NO3, show="0"))
+with(dat, ordihull(mod, group=NO3, show="10", col=3))
### Spider shows fields
-ordispider(mod, group=dat$field, lty=3, col="red")
+with(dat, ordispider(mod, group=field, lty=3, col="red"))
### Correct hypothesis test (with strata)
adonis(Y ~ NO3, data=dat, strata=dat$field, perm=999)
Modified: pkg/vegan/man/anosim.Rd
===================================================================
--- pkg/vegan/man/anosim.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/anosim.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -33,7 +33,7 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
}
\details{
Analysis of similarities (ANOSIM) provides a way to test statistically
Modified: pkg/vegan/man/bioenv.Rd
===================================================================
--- pkg/vegan/man/bioenv.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/bioenv.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -38,7 +38,7 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
\item{x}{\code{bioenv} result object.}
\item{which}{The number of the model for which the environmental
distances are evaluated, or the \code{"best"} model.}
Modified: pkg/vegan/man/clamtest.Rd
===================================================================
--- pkg/vegan/man/clamtest.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/clamtest.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -143,7 +143,7 @@
\examples{
data(mite)
data(mite.env)
-sol <- clamtest(mite, mite.env$Shrub=="None", alpha=0.005)
+sol <- with(mite.env, clamtest(mite, Shrub=="None", alpha=0.005))
summary(sol)
head(sol)
plot(sol)
Modified: pkg/vegan/man/commsim.Rd
===================================================================
--- pkg/vegan/man/commsim.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/commsim.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -224,29 +224,34 @@
\section{Quantitative Swap and Shuffle Models}{
- Quantitative Swap and Shuffle methods (\code{swhs} methods) preserve
+ Quantitative Swap and Shuffle methods (\code{swsh} methods) preserve
fill and column and row frequencies, and also either row or column
sums. The methods first perform a binary \code{quasiswap} and then
- shuffle original count data to non-zero cells. The \code{samp} methods
- shuffle original non-zero cell values, and \code{both} methods
- redistribute individuals randomly among non-zero cells. The shuffling
- is either free over the whole matrix, or within rows (\code{r} methods)
- or within columns (\code{c} methods). Shuffling within a row preserves
- row sums, and shuffling within a column preserves column sums.
+ shuffle original quantitative data to non-zero cells. The
+ \code{samp} methods shuffle original non-zero cell values and can be
+ used also with non-integer data. The \code{both} methods
+ redistribute individuals randomly among non-zero cells and can only
+ be used with integer data. The shuffling is either free over the
+ whole matrix, or within rows (\code{r} methods) or within columns
+ (\code{c} methods). Shuffling within a row preserves row sums, and
+ shuffling within a column preserves column sums.
-\itemize{
- \item{\code{"swsh_samp"}: }{non-sequential algorithm for count matrices.
+\itemize{
+
+ \item{\code{"swsh_samp"}: }{non-sequential algorithm for
+ quantitative data (either integer counts or non-integer values).
Original non-zero values values are shuffled.}
- \item{\code{"swsh_both"}: }{non-sequential algorithm for count matrices.
+ \item{\code{"swsh_both"}: }{non-sequential algorithm for count data.
Individuals are shuffled freely over non-zero cells.}
- \item{\code{"swsh_samp_r"}: }{non-sequential algorithm for count matrices.
- Non-zero values (samples) are shuffled separately for each row.}
+ \item{\code{"swsh_samp_r"}: }{non-sequential algorithm for
+ quantitative data. Non-zero values (samples) are shuffled
+ separately for each row.}
- \item{\code{"swsh_samp_c"}: }{non-sequential algorithm for count
- matrices. Non-zero values (samples) are shuffled separately for
- each column.}
+ \item{\code{"swsh_samp_c"}: }{non-sequential algorithm for
+ quantitative data. Non-zero values (samples) are shuffled
+ separately for each column.}
\item{\code{"swsh_both_r"}: }{non-sequential algorithm for count matrices.
Individuals are shuffled freely for non-zero values within each row.}
Modified: pkg/vegan/man/mantel.Rd
===================================================================
--- pkg/vegan/man/mantel.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/mantel.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -37,7 +37,7 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
}
\details{
Modified: pkg/vegan/man/metaMDS.Rd
===================================================================
--- pkg/vegan/man/metaMDS.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/metaMDS.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -131,7 +131,7 @@
library(vegan))} to make available internal \pkg{vegan}
functions. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
\item{dist}{Dissimilarity matrix used in multidimensional scaling. }
\item{pc}{Rotate to principal components. }
Modified: pkg/vegan/man/mrpp.Rd
===================================================================
--- pkg/vegan/man/mrpp.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/mrpp.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -41,7 +41,7 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later.}
+ package.}
\item{dist}{A \code{\link{dist}} object of dissimilarities, such as
produced by functions \code{\link{dist}}, \code{\link{vegdist}} or
\code{\link{designdist}}.}.
@@ -190,7 +190,7 @@
\examples{
data(dune)
data(dune.env)
-dune.mrpp <- mrpp(dune, dune.env$Management)
+dune.mrpp <- with(dune.env, mrpp(dune, Management))
dune.mrpp
# Save and change plotting parameters
@@ -198,7 +198,7 @@
layout(matrix(1:2,nr=1))
plot(dune.ord <- metaMDS(dune), type="text", display="sites" )
-ordihull(dune.ord, dune.env$Management)
+with(dune.env, ordihull(dune.ord, Management))
with(dune.mrpp, {
fig.dist <- hist(boot.deltas, xlim=range(c(delta,boot.deltas)),
Modified: pkg/vegan/man/multipart.Rd
===================================================================
--- pkg/vegan/man/multipart.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/multipart.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -105,11 +105,11 @@
out[which(x > cut[i] & x <= cut[(i + 1)])] <- i
return(out)}
## The hierarchy of sample aggregation
-levsm <- data.frame(
+levsm <- with(mite.xy, data.frame(
l1=1:nrow(mite),
- l2=cutter(mite.xy$y, cut = seq(0, 10, by = 2.5)),
- l3=cutter(mite.xy$y, cut = seq(0, 10, by = 5)),
- l4=cutter(mite.xy$y, cut = seq(0, 10, by = 10)))
+ l2=cutter(y, cut = seq(0, 10, by = 2.5)),
+ l3=cutter(y, cut = seq(0, 10, by = 5)),
+ l4=cutter(y, cut = seq(0, 10, by = 10))))
## Multiplicative diversity partitioning
multipart(mite, levsm, index="renyi", scales=1, nsimul=19)
multipart(mite ~ ., levsm, index="renyi", scales=1, nsimul=19)
Modified: pkg/vegan/man/oecosimu.Rd
===================================================================
--- pkg/vegan/man/oecosimu.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/oecosimu.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -78,10 +78,9 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later. If you
- define a \code{nestfun} in Windows that needs other \R packages
- than \pkg{vegan} or \pkg{permute}, you must set up a socket
- cluster before the call. See \code{\link{vegandocs}}
+ package. If you define a \code{nestfun} in Windows that needs other
+ \R packages than \pkg{vegan} or \pkg{permute}, you must set up a
+ socket cluster before the call. See \code{\link{vegandocs}}
\code{decision-vegan} for details. }
\item{x}{An \code{oecosimu} result object.}
Modified: pkg/vegan/man/ordisurf.Rd
===================================================================
--- pkg/vegan/man/ordisurf.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/ordisurf.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -269,15 +269,15 @@
data(varechem)
vare.dist <- vegdist(varespec)
vare.mds <- monoMDS(vare.dist)
-with(varechem, ordisurf(vare.mds, Baresoil, bubble = 5))
+ordisurf(vare.mds ~ Baresoil, varechem, bubble = 5)
## as above but without the extra penalties on smooth terms,
## and using GCV smoothness selection (old behaviour of `ordisurf()`):
-with(varechem, ordisurf(vare.mds, Baresoil,col = "blue", add = TRUE,
- select = FALSE, method = "GCV.Cp"))
+ordisurf(vare.mds ~ Baresoil, varechem, col = "blue", add = TRUE,
+ select = FALSE, method = "GCV.Cp")
## Cover of Cladina arbuscula
-fit <- with(varespec, ordisurf(vare.mds, Cladarbu, family=quasipoisson))
+fit <- ordisurf(vare.mds ~ Cladarbu, varespec, family=quasipoisson)
## Get fitted values
calibrate(fit)
@@ -286,11 +286,9 @@
## of the model not just to a linear surface. There are 2
## options available:
## - option 1: `select = TRUE` --- the *default*
-with(varechem,
- ordisurf(vare.mds, Baresoil, method = "REML", select = TRUE))
+ordisurf(vare.mds ~ Baresoil, varechem, method = "REML", select = TRUE)
## - option 2: use a basis with shrinkage
-with(varechem,
- ordisurf(vare.mds, Baresoil, method = "REML", bs = "ts"))
+ordisurf(vare.mds ~ Baresoil, varechem, method = "REML", bs = "ts")
## or bs = "cs" with `isotropic = FALSE`
## Plot method
@@ -305,22 +303,21 @@
### controlling the basis functions used
## Use Duchon splines
-with(varechem, ordisurf(vare.mds, Baresoil, bs = "ds"))
+ordisurf(vare.mds ~ Baresoil, varechem, bs = "ds")
## A fixed degrees of freedom smooth, must use 'select = FALSE'
-with(varechem, ordisurf(vare.mds, Baresoil, knots = 4,
- fx = TRUE, select = FALSE))
+ordisurf(vare.mds ~ Baresoil, varechem, knots = 4,
+ fx = TRUE, select = FALSE)
## An anisotropic smoother with cubic regression spline bases
-with(varechem, ordisurf(vare.mds, Baresoil, isotropic = FALSE,
- bs = "cr", knots = 4))
+ordisurf(vare.mds ~ Baresoil, varechem, isotropic = FALSE,
+ bs = "cr", knots = 4)
## An anisotropic smoother with cubic regression spline with
## shrinkage bases & different degrees of freedom in each dimension
-with(varechem, ordisurf(vare.mds, Baresoil, isotropic = FALSE,
+ordisurf(vare.mds ~ Baresoil, varechem, isotropic = FALSE,
bs = "cs", knots = c(3,4), fx = TRUE,
- select = FALSE))
-
+ select = FALSE)
}
\keyword{ multivariate }
\keyword{ aplot }
Modified: pkg/vegan/man/permatfull.Rd
===================================================================
--- pkg/vegan/man/permatfull.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/permatfull.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -283,7 +283,7 @@
mar <- arima(bc, c(1,0,0))
mar
## Ljung-Box test of residuals
-Box.test(mar$residuals)
+Box.test(residuals(mar))
## Graphical diagnostics
tsdiag(mar)
}
Modified: pkg/vegan/man/simper.Rd
===================================================================
--- pkg/vegan/man/simper.Rd 2014-10-23 09:18:30 UTC (rev 2904)
+++ pkg/vegan/man/simper.Rd 2014-10-29 08:36:32 UTC (rev 2905)
@@ -32,8 +32,8 @@
\item{parallel}{Number of parallel processes or a predefined socket
cluster. With \code{parallel = 1} uses ordinary, non-parallel
processing. The parallel processing is done with \pkg{parallel}
- package which is available only for \R 2.14.0 and later. See
- \code{\link{vegandocs}} \code{decision-vegan} for details.}
+ package. See \code{\link{vegandocs}} \code{decision-vegan} for
+ details.}
\item{...}{Parameters passed to other functions. In \code{simper} the
extra parameters are passed to \code{\link[permute]{shuffleSet}} if
permutations are used.}