[Vegan-commits] r913 - in pkg/vegan: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 11 10:35:58 CEST 2009
Author: jarioksa
Date: 2009-08-11 10:35:56 +0200 (Tue, 11 Aug 2009)
New Revision: 913
Added:
pkg/vegan/R/poolaccum.R
pkg/vegan/R/print.poolaccum.R
Modified:
pkg/vegan/DESCRIPTION
pkg/vegan/inst/ChangeLog
pkg/vegan/man/specaccum.Rd
pkg/vegan/man/specpool.Rd
Log:
poolaccum: new function for extrapolated richness in random accumulation of sites
Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION 2009-08-09 06:19:10 UTC (rev 912)
+++ pkg/vegan/DESCRIPTION 2009-08-11 08:35:56 UTC (rev 913)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 1.16-22
-Date: July 4, 2009
+Version: 1.16-23
+Date: August 11, 2009
Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson,
Peter Solymos, M. Henry H. Stevens, Helene Wagner
Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>
Added: pkg/vegan/R/poolaccum.R
===================================================================
--- pkg/vegan/R/poolaccum.R (rev 0)
+++ pkg/vegan/R/poolaccum.R 2009-08-11 08:35:56 UTC (rev 913)
@@ -0,0 +1,37 @@
+`poolaccum` <-
+ function(x, permutations = 100, minsize = 3)
+{
+ x <- as.matrix(x)
+ n <- nrow(x)
+ m <- ncol(x)
+ N <- seq_len(n)
+ S <- chao <- boot <- jack1 <- jack2 <-
+ matrix(0, nrow=n, ncol=permutations)
+ ## specpool() is slow, but the vectorized versions below are
+ ## pretty fast
+ for (i in 1:permutations) {
+ take <- sample(n)
+ tmp <- apply(x[take,] > 0, 2, cumsum)
+ S[,i] <- rowSums(tmp > 0)
+ ## All-zero species are taken as *known* to be missing in
+ ## subsamples, and in the following we subtract them (as
+ ## 2*S-m) from the bootstrap samples to give a more unbiased
+ ## estimate.
+ boot[,i] <- 2*S[,i] - m + rowSums(exp(sweep(log1p(-sweep(tmp, 1, N, "/")), 1, N, "*") ))
+ a1 <- rowSums(tmp == 1)
+ a2 <- rowSums(tmp == 2)
+ chao[, i] <- S[,i] + a1*a1/2/a2
+ jack1[,i] <- S[,i] + a1 * (N-1)/N
+ jack2[,i] <- S[,i] + a1*(2*N-3)/N - a2*(N-2)^2/N/(N-1)
+ }
+ means <- cbind(`N` = N, `S` = rowMeans(S), `Chao` = rowMeans(chao),
+ `Jackknife 1` = rowMeans(jack1),
+ `Jackknife 2` = rowMeans(jack2),
+ `Bootstrap` = rowMeans(boot))
+ take <- N >= minsize
+ out <- list(S = S[take,], chao = chao[take,], jack1 = jack1[take,],
+ jack2 = jack2[take,], boot = boot[take,], N = N[take],
+ means = means[take,])
+ class(out) <- "poolaccum"
+ out
+}
Added: pkg/vegan/R/print.poolaccum.R
===================================================================
--- pkg/vegan/R/print.poolaccum.R (rev 0)
+++ pkg/vegan/R/print.poolaccum.R 2009-08-11 08:35:56 UTC (rev 913)
@@ -0,0 +1,6 @@
+`print.poolaccum` <-
+ function(x, ...)
+{
+ print(x$means, ...)
+ invisible(x)
+}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-08-09 06:19:10 UTC (rev 912)
+++ pkg/vegan/inst/ChangeLog 2009-08-11 08:35:56 UTC (rev 913)
@@ -2,8 +2,13 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 1.16-22 (opened July 15, 2009)
+Version 1.16-23 (opened August 11, 2009)
+ * poolaccum: new function to find the extrapolated richness
+ values (or specpool() estimates) for random accumulation of sites.
+
+Version 1.16-22 (closed August 11, 2009)
+
* metaMDS: accepts now user supplied dissimilarities either as a
"dist" structure or as symmetric square matrix (Susan Letcher's
wish). As a side effect, dissimilarity matrices are now correctly
Modified: pkg/vegan/man/specaccum.Rd
===================================================================
--- pkg/vegan/man/specaccum.Rd 2009-08-09 06:19:10 UTC (rev 912)
+++ pkg/vegan/man/specaccum.Rd 2009-08-11 08:35:56 UTC (rev 913)
@@ -136,10 +136,14 @@
without replacement. Further, its standard deviation does not take
into account species correlations, and is generally too low. }
-\seealso{\code{\link{rarefy}} and \code{\link{renyiaccum}}.
- Underlying graphical functions are
- \code{\link{boxplot}}, \code{\link{matlines}}, \code{\link{segments}}
- and \code{\link{polygon}}. }
+\seealso{\code{\link{rarefy}} and \code{\link{rrarefy}} are related
+ individual based models. Other accumulation models are
+ \code{\link{poolaccum}} for extrapoltated richenss, and
+ \code{\link{renyiaccum}} and \code{\link{tsallisaccum}} for
+ diversity indices. Underlying graphical functions are
+ \code{\link{boxplot}}, \code{\link{matlines}},
+ \code{\link{segments}} and \code{\link{polygon}}.
+}
\examples{
data(BCI)
sp1 <- specaccum(BCI)
Modified: pkg/vegan/man/specpool.Rd
===================================================================
--- pkg/vegan/man/specpool.Rd 2009-08-09 06:19:10 UTC (rev 912)
+++ pkg/vegan/man/specpool.Rd 2009-08-11 08:35:56 UTC (rev 913)
@@ -1,6 +1,8 @@
\name{specpool}
\alias{specpool}
\alias{specpool2vect}
+\alias{poolaccum}
+\alias{print.poolaccum}
\alias{estimateR}
\alias{estimateR.default}
\alias{estimateR.matrix}
@@ -16,6 +18,7 @@
\usage{
specpool(x, pool)
specpool2vect(X, index = c("Jack.1","Jack.2", "Chao", "Boot","Species"))
+poolaccum(x, permutations = 100, minsize = 3)
estimateR(x, ...)
}
@@ -25,6 +28,8 @@
the species data. If missing, all sites are pooled together.}
\item{X}{A \code{specpool} result object.}
\item{index}{The selected index of extrapolated richness.}
+ \item{permutations}{Number of permutations of sampling order of sites.}
+ \item{minsize}{Smallest number of sampling units reported.}
\item{...}{Other parameters (not used).}
}
\details{
@@ -58,6 +63,10 @@
(1-p_i)^N}
}
+ Function \code{poolaccum} is similar to \code{\link{specaccum}}, but
+ it estimates all extrapolated richness values of \code{specpool} in
+ addition to number of species for random ordering of sampling units.
+
The abundance-based estimates in \code{estimateR} use counts (frequencies) of
species in a single site. If called for a matrix or data frame, the
function will give separate estimates for each site. The two
@@ -105,13 +114,17 @@
}
\value{
+
Function \code{specpool} returns a data frame with entries for
- observed richness
- and each of the indices for each class in \code{pool} vector. The
- utility function \code{specpool2vect} maps the pooled values into
- a vector giving the value of selected \code{index} for each original
- site. Function \code{estimateR} returns the estimates and their
- standard errors for each site.
+ observed richness and each of the indices for each class in
+ \code{pool} vector. The utility function \code{specpool2vect} maps
+ the pooled values into a vector giving the value of selected
+ \code{index} for each original site. Function \code{poolaccum}
+ returns matrices of permutation results for each richness estimator,
+ the vector of sample sizes and a table of \code{means} of
+ permutations for each estimator. Function \code{estimateR} returns
+ the estimates and their standard errors for each site.
+
}
\references{
Chao, A. (1987). Estimating the population size for capture-recapture
@@ -137,7 +150,8 @@
See \url{http://viceroy.eeb.uconn.edu/EstimateS} for a more complete
(and positive) discussion and alternative software for some platforms.
}
-\seealso{\code{\link{veiledspec}}, \code{\link{diversity}}, \code{\link{beals}}. }
+\seealso{\code{\link{veiledspec}}, \code{\link{diversity}}, \code{\link{beals}},
+ \code{\link{specaccum}}. }
\examples{
data(dune)
data(dune.env)
More information about the Vegan-commits
mailing list