From noreply at r-forge.r-project.org Wed Aug 26 09:03:51 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 26 Aug 2015 09:03:51 +0200 (CEST) Subject: [Vegan-commits] r2955 - in pkg/vegan: R man Message-ID: <20150826070351.DE2511844B3@r-forge.r-project.org> Author: jarioksa Date: 2015-08-26 09:03:51 +0200 (Wed, 26 Aug 2015) New Revision: 2955 Added: pkg/vegan/man/rarefy.Rd Modified: pkg/vegan/R/anova.cca.R pkg/vegan/R/anova.ccabyterm.R pkg/vegan/R/anova.ccalist.R pkg/vegan/R/anova.ccanull.R pkg/vegan/R/print.cca.R pkg/vegan/man/adipart.Rd pkg/vegan/man/cca.Rd pkg/vegan/man/diversity.Rd pkg/vegan/man/specaccum.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/anova.cca.R =================================================================== --- pkg/vegan/R/anova.cca.R 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/R/anova.cca.R 2015-08-26 07:03:51 UTC (rev 2955) @@ -61,9 +61,14 @@ 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"), - "F", "Pr(>F)") + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" + colnames(table) <- c("Df", varname, "F", "Pr(>F)") head <- paste0("Permutation test for ", tst$method, " under ", tst$model, " model\n", howHead(control)) mod <- paste("Model:", c(object$call)) Modified: pkg/vegan/R/anova.ccabyterm.R =================================================================== --- pkg/vegan/R/anova.ccabyterm.R 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/R/anova.ccabyterm.R 2015-08-26 07:03:51 UTC (rev 2955) @@ -27,13 +27,18 @@ sol <- anova.ccalist(mods, permutations = permutations, model = model, parallel = parallel) ## Reformat - out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]), - c(sol[-1,4], sol[ntrm+1,2]), - c(sol[-1,5], NA), - c(sol[-1,6], NA)) - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") + out <- data.frame(c(sol[-1, 3], sol[ntrm+1, 1]), + c(sol[-1, 4], sol[ntrm+1, 2]), + c(sol[-1, 5], NA), + c(sol[-1, 6], NA)) + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" + colnames(out) <- c("Df", varname, "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", @@ -94,9 +99,14 @@ ## Collect results to anova data.frame out <- data.frame(c(Df, dfbig), c(Chisq, chibig), c(Fstat, NA), c(Pval, NA)) - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" + colnames(out) <- c("Df", varname, "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", mods[[1]]$model, " model\n", @@ -157,9 +167,14 @@ out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), c(Fstat, NA), c(Pvals,NA)) rownames(out) <- c(names(eig), "Residual") - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" + colnames(out) <- c("Df", varname, "F", "Pr(>F)") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", "Marginal tests for axes\n", Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/R/anova.ccalist.R 2015-08-26 07:03:51 UTC (rev 2955) @@ -72,13 +72,16 @@ ## collect table table <- data.frame(resdf, resdev, c(NA, df), c(NA,changedev), c(NA,fval), c(NA,pval)) - isRDA <- method != "cca" + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" dimnames(table) <- list(1L:nmodels, - c("Res.Df", - ifelse(isRDA,"Res.Variance", "Res.ChiSquare"), - "Df", - ifelse(isRDA,"Variance","ChiSquare"), - "F", "Pr(>F)")) + c("ResDf", paste0("Res", varname), "Df", + varname, "F", "Pr(>F)")) ## Collect header information formulae <- sapply(object, function(z) deparse(formula(z))) head <- paste0("Permutation tests for ", method, " under ", Modified: pkg/vegan/R/anova.ccanull.R =================================================================== --- pkg/vegan/R/anova.ccanull.R 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/R/anova.ccanull.R 2015-08-26 07:03:51 UTC (rev 2955) @@ -4,19 +4,24 @@ `anova.ccanull` <- function(object, ...) { - table <- matrix(0, nrow = 2, ncol = 5) + table <- matrix(0, nrow = 2, ncol = 4) if (object$CA$rank == 0) { - table[1,] <- c(object$CCA$qrank, object$CCA$tot.chi, NA, 0, NA) - table[2,] <- c(0,0,NA,NA,NA) + table[1,] <- c(object$CCA$qrank, object$CCA$tot.chi, NA, NA) + table[2,] <- c(0,0,NA,NA) } else { - table[1,] <- c(0,0,0,0,NA) - table[2,] <- c(nrow(object$CA$u) - 1, object$CA$tot.chi, NA, NA, NA) + table[1,] <- c(0,0,0,NA) + table[2,] <- c(nrow(object$CA$u) - 1, object$CA$tot.chi, NA, NA) } rownames(table) <- c("Model", "Residual") - colnames(table) <- c("Df", - if (inherits(object, "rda")) "Var" else "Chisq", - "F", "N.Perm", "Pr(>F)") + if (inherits(object, "capscale") && + (object$adjust != 1 || is.null(object$adjust))) + varname <- "SumOfSqs" + else if (inherits(object, "rda")) + varname <- "Variance" + else + varname <- "ChiSquare" + colnames(table) <- c("Df", varname, "F", "Pr(>F)") table <- as.data.frame(table) if (object$CA$rank == 0) head <- "No residual component\n" Modified: pkg/vegan/R/print.cca.R =================================================================== --- pkg/vegan/R/print.cca.R 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/R/print.cca.R 2015-08-26 07:03:51 UTC (rev 2955) @@ -27,7 +27,7 @@ ## Remove "Proportion" if only one component if (is.null(x$CCA) && is.null(x$pCCA)) tbl <- tbl[,-2] - printCoefmat(tbl, digits = digits, na.print = "", zap.ind = 1:2) + printCoefmat(tbl, digits = digits, na.print = "") cat("Inertia is", x$inertia, "\n") if (!is.null(x$CCA$alias)) cat("Some constraints were aliased because they were collinear (redundant)\n") Modified: pkg/vegan/man/adipart.Rd =================================================================== --- pkg/vegan/man/adipart.Rd 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/man/adipart.Rd 2015-08-26 07:03:51 UTC (rev 2955) @@ -145,9 +145,11 @@ \author{ \enc{P?ter S?lymos}{Peter Solymos}, \email{solymos at ualberta.ca}} - \seealso{See \code{\link{oecosimu}} for permutation settings and - calculating \eqn{p}-values. } +\seealso{See \code{\link{oecosimu}} for permutation settings and + calculating \eqn{p}-values. \code{\link{multipart}} for multiplicative + diversity partitioning.} + \examples{ ## NOTE: 'nsimul' argument usually needs to be >= 99 ## here much lower value is used for demonstration Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/man/cca.Rd 2015-08-26 07:03:51 UTC (rev 2955) @@ -131,7 +131,7 @@ constraints. However, the curve artefact can be avoided only with a low number of constraints that do not have a curvilinear relation with each other. The curve can reappear even with two badly chosen - constraints or a single factor. Although the formula interface makes + constraints or a single factor. Although the formula interface makes it easy to include polynomial or interaction terms, such terms often produce curved artefacts (that are difficult to interpret), these should probably be avoided. @@ -171,7 +171,7 @@ vignette with this package. } \references{ The original method was by ter Braak, but the current - implementations follows Legendre and Legendre. + implementation follows Legendre and Legendre. Legendre, P. and Legendre, L. (2012) \emph{Numerical Ecology}. 3rd English ed. Elsevier. Modified: pkg/vegan/man/diversity.Rd =================================================================== --- pkg/vegan/man/diversity.Rd 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/man/diversity.Rd 2015-08-26 07:03:51 UTC (rev 2955) @@ -1,27 +1,16 @@ \encoding{UTF-8} \name{diversity} \alias{diversity} -\alias{rarefy} -\alias{rrarefy} -\alias{drarefy} -\alias{rarecurve} -\alias{rareslope} \alias{fisher.alpha} \alias{specnumber} -\title{ Ecological Diversity Indices and Rarefaction Species Richness } +\title{Ecological Diversity Indices} -\description{ Shannon, Simpson, and Fisher diversity indices -and rarefied species richness for community ecologists. } +\description{ Shannon, Simpson, and Fisher diversity indices and species + richness. } \usage{ diversity(x, index = "shannon", MARGIN = 1, base = exp(1)) -rarefy(x, sample, se = FALSE, MARGIN = 1) -rrarefy(x, sample) -drarefy(x, sample) -rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species", - label = TRUE, col, lty, ...) -rareslope(x, sample) fisher.alpha(x, MARGIN = 1, ...) specnumber(x, groups, MARGIN = 1) } @@ -32,20 +21,9 @@ \code{"simpson"} or \code{"invsimpson"}.} \item{MARGIN}{Margin for which the index is computed. } \item{base}{ The logarithm \code{base} used in \code{shannon}.} - \item{sample}{Subsample size for rarefying community, either a single - value or a vector.} - \item{se}{Estimate standard errors.} - \item{step}{Step size for sample sizes in rarefaction curves.} - \item{xlab, ylab}{Axis labels in plots of rarefaction curves.} - \item{label}{Label rarefaction curves by rownames of \code{x} - (logical).} - \item{col, lty}{plotting colour and line type, see - \code{\link{par}}. Can be a vector of length \code{nrow(x)}, one per - sample, and will be extended to such a length internally.} \item{groups}{A grouping factor: if given, finds the total number of species in each group.} - \item{...}{Parameters passed to \code{\link{nlm}}, or to \code{\link{plot}}, - \code{\link{lines}} and \code{\link{ordilabel}} in \code{rarecurve}.} + \item{...}{Parameters passed to the function.} } \details{ Shannon or Shannon--Weaver (or Shannon--Wiener) index is defined as @@ -59,40 +37,6 @@ sum p_i^2}. Choice \code{simpson} returns \eqn{1-D} and \code{invsimpson} returns \eqn{1/D}. - Function \code{rarefy} gives the expected species richness in random - subsamples of size \code{sample} from the community. The size of - \code{sample} should be smaller than total community size, but the - function will work for larger \code{sample} as well (with a warning) - and return non-rarefied species richness (and standard error = - 0). If \code{sample} is a vector, rarefaction of all observations is - performed for each sample size separately. Rarefaction can be - performed only with genuine counts of individuals. The function - \code{rarefy} is based on Hurlbert's (1971) formulation, and the - standard errors on Heck et al. (1975). - - Function \code{rrarefy} generates one randomly rarefied community data - frame or vector of given \code{sample} size. The \code{sample} can be - a vector giving the sample sizes for each row, and its values must be - less or equal to observed number of individuals. The random - rarefaction is made without replacement so that the variance of - rarefied communities is rather related to rarefaction proportion than - to to the size of the \code{sample}. - - Function \code{drarefy} returns probabilities that species occur in a - rarefied community of size \code{sample}. The \code{sample} can be a - vector giving the sample sizes for each row. - - Function \code{rarecurve} draws a rarefaction curve for each row of - the input data. The rarefaction curves are evaluated using the - interval of \code{step} sample sizes, always including 1 and total - sample size. If \code{sample} is specified, a vertical line is - drawn at \code{sample} with horizontal lines for the rarefied - species richnesses. - - Function \code{rareslope} calculates the slope of \code{rarecurve} - (derivative of \code{rarefy}) at given \code{sample} size; the - \code{sample} need not be an integer. - \code{fisher.alpha} estimates the \eqn{\alpha} parameter of Fisher's logarithmic series (see \code{\link{fisherfit}}). The estimation is possible only for genuine @@ -114,26 +58,11 @@ inverse Simpson is asymptotically equal to rarefied species richness in sample of two individuals, and Fisher's \eqn{\alpha} is very similar to inverse Simpson. + } \value{ - A vector of diversity indices or rarefied species richness values. With - a single \code{sample} and \code{se = TRUE}, function \code{rarefy} - returns a 2-row matrix - with rarefied richness (\code{S}) and its standard error - (\code{se}). If \code{sample} is a vector in \code{rarefy}, the - function returns a matrix with a column for each \code{sample} size, - and if \code{se = TRUE}, rarefied richness and its standard error are - on consecutive lines. - - Function \code{rarecurve} returns \code{\link{invisible}} list of - \code{rarefy} results corresponding each drawn curve. - - With option \code{se = TRUE}, function \code{fisher.alpha} returns a - data frame with items for \eqn{\alpha} (\code{alpha}), its approximate - standard errors (\code{se}), residual degrees of freedom - (\code{df.residual}), and the \code{code} returned by - \code{\link{nlm}} on the success of estimation. + A vector of diversity indices or numbers of species. } \references{ @@ -141,19 +70,21 @@ between the number of species and the number of individuals in a random sample of animal population. \emph{Journal of Animal Ecology} \strong{12}, 42--58. - - Heck, K.L., van Belle, G. & Simberloff, D. (1975). Explicit - calculation of the rarefaction diversity measurement and the - determination of sufficient sample size. \emph{Ecology} \strong{56}, - 1459--1461. Hurlbert, S.H. (1971). The nonconcept of species diversity: a critique and alternative parameters. \emph{Ecology} \strong{52}, 577--586. } -\seealso{Function \code{renyi} for generalized \enc{R?nyi}{Renyi} - diversity and Hill numbers.} +\seealso{These functions calculate only some basic indices, but many + others can be derived with them (see Examples). Facilities related to + diversity are discussed in a \pkg{vegan} vignette that can be read + with command \code{vegandocs("diversity")}. Functions + \code{\link{renyi}} and \code{\link{tsallis}} estimate a series of + generalized diversity indices. Function \code{\link{rarefy}} finds + estimated number of species for given sample size. Beta diversity can + be estimated with \code{\link{betadiver}}. Diversities can be + partitioned with \code{\link{adipart}} and \code{\link{multipart}}. } \author{ Jari Oksanen and Bob O'Hara (\code{fisher.alpha}).} @@ -162,7 +93,7 @@ H <- diversity(BCI) simp <- diversity(BCI, "simpson") invsimp <- diversity(BCI, "inv") -## Unbiased Simpson of Hurlbert 1971 (eq. 5): +## Unbiased Simpson (Hurlbert 1971, eq. 5) with rarefy: unbias.simp <- rarefy(BCI, 2) - 1 ## Fisher alpha alpha <- fisher.alpha(BCI) @@ -177,12 +108,6 @@ alpha <- with(dune.env, tapply(specnumber(dune), Management, mean)) gamma <- with(dune.env, specnumber(dune, Management)) gamma/alpha - 1 -## Rarefaction -(raremax <- min(rowSums(BCI))) -Srare <- rarefy(BCI, raremax) -plot(S, Srare, xlab = "Observed No. of Species", ylab = "Rarefied No. of Species") -abline(0, 1) -rarecurve(BCI, step = 20, sample = raremax, col = "blue", cex = 0.6) } \keyword{ univar } Copied: pkg/vegan/man/rarefy.Rd (from rev 2954, pkg/vegan/man/diversity.Rd) =================================================================== --- pkg/vegan/man/rarefy.Rd (rev 0) +++ pkg/vegan/man/rarefy.Rd 2015-08-26 07:03:51 UTC (rev 2955) @@ -0,0 +1,116 @@ +\name{rarefy} +\alias{rarefy} +\alias{rrarefy} +\alias{drarefy} +\alias{rarecurve} +\alias{rareslope} + +\title{Rarefaction Species Richness} + +\description{ Rarefied species richness for community ecologists. } + +\usage{ +rarefy(x, sample, se = FALSE, MARGIN = 1) +rrarefy(x, sample) +drarefy(x, sample) +rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species", + label = TRUE, col, lty, ...) +rareslope(x, sample) +} + +\arguments{ + \item{x}{Community data, a matrix-like object or a vector.} + \item{MARGIN}{Margin for which the index is computed. } + \item{sample}{Subsample size for rarefying community, either a single + value or a vector.} + \item{se}{Estimate standard errors.} + \item{step}{Step size for sample sizes in rarefaction curves.} + \item{xlab, ylab}{Axis labels in plots of rarefaction curves.} + \item{label}{Label rarefaction curves by rownames of \code{x} + (logical).} + \item{col, lty}{plotting colour and line type, see + \code{\link{par}}. Can be a vector of length \code{nrow(x)}, one per + sample, and will be extended to such a length internally.} + \item{...}{Parameters passed to \code{\link{nlm}}, or to \code{\link{plot}}, + \code{\link{lines}} and \code{\link{ordilabel}} in \code{rarecurve}.} +} +\details{ + + Function \code{rarefy} gives the expected species richness in random + subsamples of size \code{sample} from the community. The size of + \code{sample} should be smaller than total community size, but the + function will work for larger \code{sample} as well (with a warning) + and return non-rarefied species richness (and standard error = + 0). If \code{sample} is a vector, rarefaction of all observations is + performed for each sample size separately. Rarefaction can be + performed only with genuine counts of individuals. The function + \code{rarefy} is based on Hurlbert's (1971) formulation, and the + standard errors on Heck et al. (1975). + + Function \code{rrarefy} generates one randomly rarefied community data + frame or vector of given \code{sample} size. The \code{sample} can be + a vector giving the sample sizes for each row, and its values must be + less or equal to observed number of individuals. The random + rarefaction is made without replacement so that the variance of + rarefied communities is rather related to rarefaction proportion than + to to the size of the \code{sample}. + + Function \code{drarefy} returns probabilities that species occur in a + rarefied community of size \code{sample}. The \code{sample} can be a + vector giving the sample sizes for each row. + + Function \code{rarecurve} draws a rarefaction curve for each row of + the input data. The rarefaction curves are evaluated using the + interval of \code{step} sample sizes, always including 1 and total + sample size. If \code{sample} is specified, a vertical line is + drawn at \code{sample} with horizontal lines for the rarefied + species richnesses. + + Function \code{rareslope} calculates the slope of \code{rarecurve} + (derivative of \code{rarefy}) at given \code{sample} size; the + \code{sample} need not be an integer. + +} + +\value{ + A vector of rarefied species richness values. With a single + \code{sample} and \code{se = TRUE}, function \code{rarefy} returns a + 2-row matrix with rarefied richness (\code{S}) and its standard error + (\code{se}). If \code{sample} is a vector in \code{rarefy}, the + function returns a matrix with a column for each \code{sample} size, + and if \code{se = TRUE}, rarefied richness and its standard error are + on consecutive lines. + + Function \code{rarecurve} returns \code{\link{invisible}} list of + \code{rarefy} results corresponding each drawn curve. +} + +\references{ + Heck, K.L., van Belle, G. & Simberloff, D. (1975). Explicit + calculation of the rarefaction diversity measurement and the + determination of sufficient sample size. \emph{Ecology} \strong{56}, + 1459--1461. + + Hurlbert, S.H. (1971). The nonconcept of species diversity: a critique + and alternative parameters. \emph{Ecology} \strong{52}, 577--586. + +} + +\seealso{Use \code{\link{specaccum}} for species accumulation curves + where sites are sampled instead of individuals. \code{\link{specpool}} + extrapolates richness to an unknown sample size.} + +\author{Jari Oksanen} + +\examples{ +data(BCI) +S <- specnumber(BCI) # observed number of species +(raremax <- min(rowSums(BCI))) +Srare <- rarefy(BCI, raremax) +plot(S, Srare, xlab = "Observed No. of Species", ylab = "Rarefied No. of Species") +abline(0, 1) +rarecurve(BCI, step = 20, sample = raremax, col = "blue", cex = 0.6) +} +\keyword{ univar } + + Modified: pkg/vegan/man/specaccum.Rd =================================================================== --- pkg/vegan/man/specaccum.Rd 2015-07-15 08:28:34 UTC (rev 2954) +++ pkg/vegan/man/specaccum.Rd 2015-08-26 07:03:51 UTC (rev 2955) @@ -14,7 +14,7 @@ \alias{deviance.fitspecaccum} \alias{specslope} -\title{Species Accumulation Curves } +\title{Species Accumulation Curves} \description{ Function \code{specaccum} finds species accumulation curves or the number of species for a certain number of sampled sites or @@ -96,31 +96,31 @@ \item{...}{Other parameters to functions.} } \details{ - Species accumulation curves (SAC) are used to compare diversity properties - of community data sets using different accumulator functions. The - classic method is \code{"random"} which finds the mean SAC and its - standard deviation from random permutations of the data, or - subsampling without replacement (Gotelli & Colwell 2001). - The \code{"exact"} method finds the - expected SAC using the method that was independently developed by - Ugland et al. (2003), Colwell et al. (2004) and Kindt et al. (2006). - The unconditional standard deviation for the exact SAC represents a - moment-based estimation that is not conditioned on the empirical data - set (sd for all samples > 0), unlike the conditional standard deviation - that was developed by Jari Oksanen (not published, sd=0 for all - samples). The unconditional standard deviation is based on an estimation - of the total extrapolated number of species in the survey area - (a.k.a. gamma diversity), as estimated by - function \code{\link{specpool}}. - Method \code{"coleman"} finds the expected SAC and its standard - deviation following Coleman et al. (1982). All these methods are - based on sampling sites without replacement. In contrast, the - \code{method = "rarefaction"} finds the expected species richness and - its standard deviation by sampling individuals instead of sites. - It achieves this by applying function \code{\link{rarefy}} with - number of individuals corresponding to average number of individuals - per site. + Species accumulation curves (SAC) are used to compare diversity + properties of community data sets using different accumulator + functions. The classic method is \code{"random"} which finds the mean + SAC and its standard deviation from random permutations of the data, + or subsampling without replacement (Gotelli & Colwell 2001). The + \code{"exact"} method finds the expected SAC using sample-based + rarefaction method that has been independently developed numerous + times (Chiarucci et al. 2008) and it is often known as Mao Tau + estimate (Colwell et al. 2012). The unconditional standard deviation + for the exact SAC represents a moment-based estimation that is not + conditioned on the empirical data set (sd for all samples > 0). The + unconditional standard deviation is based on an estimation of the + extrapolated number of species in the survey area (a.k.a. gamma + diversity), as estimated by function \code{\link{specpool}}. The + conditional standard deviation that was developed by Jari Oksanen (not + published, sd=0 for all samples). Method \code{"coleman"} finds the + expected SAC and its standard deviation following Coleman et + al. (1982). All these methods are based on sampling sites without + replacement. In contrast, the \code{method = "rarefaction"} finds the + expected species richness and its standard deviation by sampling + individuals instead of sites. It achieves this by applying function + \code{\link{rarefy}} with number of individuals corresponding to + average number of individuals per site. + Methods \code{"random"} and \code{"collector"} can take weights (\code{w}) that give the sampling effort for each site. The weights \code{w} do not influence the order the sites are accumulated, but @@ -232,34 +232,27 @@ } \references{ + Chiarucci, A., Bacaro, G., Rocchini, D. & Fattorini, + L. (2008). Discovering and rediscovering the sample-based rarefaction + formula in the ecological literature. \emph{Commun. Ecol.} 9: + 121--123. + Coleman, B.D, Mares, M.A., Willis, M.R. & Hsieh, Y. (1982). Randomness, area and species richness. \emph{Ecology} 63: 1121--1133. - Colwell, R.K., Mao, C.X. & Chang, J. (2004). Interpolating, - extrapolating, and comparing incidence-based species accumulation - curves. \emph{Ecology} 85: 2717--2727. + Colwell, R.K., Chao, A., Gotelli, N.J., Lin, S.Y., Mao, C.X., Chazdon, + R.L. & Longino, J.T. (2012). Models and estimators linking + individual-based and sample-based rarefaction, extrapolation and + comparison of assemblages. \emph{J. Plant Ecol.} 5: 3--21. Dengler, J. (2009). Which function describes the species-area relationship best? A review and empirical evaluation. \emph{Journal of Biogeography} 36, 728--744. - Gotellli, N.J. & Colwell, R.K. (2001). Quantifying biodiversity: + Gotelli, N.J. & Colwell, R.K. (2001). Quantifying biodiversity: procedures and pitfalls in measurement and comparison of species richness. \emph{Ecol. Lett.} 4, 379--391. - - Kindt, R. (2003). Exact species richness for sample-based accumulation - curves. \emph{Manuscript.} - - Kindt R., Van Damme, P. & Simons, A.J. (2006) Patterns of species - richness at varying scales in western Kenya: planning for - agroecosystem diversification. \emph{Biodiversity and Conservation}, - 10: 3235--3249. - - Ugland, K.I., Gray, J.S. & Ellingsen, K.E. (2003). The - species-accumulation curve and estimation of species richness. \emph{Journal - of Animal Ecology} 72: 888--897. - } \author{Roeland Kindt \email{r.kindt at cgiar.org} and Jari Oksanen.} \note{ From noreply at r-forge.r-project.org Fri Aug 28 09:40:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 28 Aug 2015 09:40:29 +0200 (CEST) Subject: [Vegan-commits] r2956 - in pkg/vegan: R inst Message-ID: <20150828074030.056B4184B7C@r-forge.r-project.org> Author: jarioksa Date: 2015-08-28 09:40:29 +0200 (Fri, 28 Aug 2015) New Revision: 2956 Modified: pkg/vegan/R/metaMDS.R pkg/vegan/R/metaMDSdist.R pkg/vegan/inst/NEWS.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/metaMDS.R =================================================================== --- pkg/vegan/R/metaMDS.R 2015-08-26 07:03:51 UTC (rev 2955) +++ pkg/vegan/R/metaMDS.R 2015-08-28 07:40:29 UTC (rev 2956) @@ -6,7 +6,13 @@ plot = FALSE, previous.best, ...) { engine <- match.arg(engine) - commname <- deparse(substitute(comm)) + ## This could be a character vector of length > 1L + commname <- deparse(substitute(comm), width.cutoff = 500L) + if (length(commname) > 1L) { + paste(commname, collapse = "", sep = "") + ## deparse can add more white space, so cull 2 or more spaces to a single space + commname <- gsub("[ ]{2,}", " ", commname) + } ## metaMDS was written for community data which should be all ## positive. Check this here, and set arguments so that they are ## suitable for non-negative data. @@ -45,13 +51,14 @@ points <- postMDS(out$points, dis, plot = max(0, plot - 1), ...) if (is.null(rownames(points))) rownames(points) <- rownames(comm) - if (wascores) { + wa <- if (wascores) { ## transformed data - comm <- eval.parent(parse(text=attr(dis, "commname"))) - wa <- wascores(points, comm, expand = expand) + ##comm <- eval.parent(parse(text=attr(dis, "commname"))) + comm <- attr(dis, "comm") + wascores(points, comm, expand = expand) + } else { + NA } - else - wa <- NA out$points <- points out$species <- wa out$call <- match.call() Modified: pkg/vegan/R/metaMDSdist.R =================================================================== --- pkg/vegan/R/metaMDSdist.R 2015-08-26 07:03:51 UTC (rev 2955) +++ pkg/vegan/R/metaMDSdist.R 2015-08-28 07:40:29 UTC (rev 2956) @@ -64,6 +64,7 @@ } attr(dis, "maxdis") <- maxdis attr(dis, "commname") <- commname + attr(dis, "comm") <- comm attr(dis, "function") <- distname dis } Modified: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2015-08-26 07:03:51 UTC (rev 2955) +++ pkg/vegan/inst/NEWS.Rd 2015-08-28 07:40:29 UTC (rev 2956) @@ -2,6 +2,45 @@ \title{vegan News} \encoding{UTF-8} +\section{Changes in version 2.3-1}{ + + \subsection{BUG FIXES}{ + \itemize{ + + \item Automated model building in constrained ordination + (\code{cca}, \code{rda}, \code{capscale}) with \code{step}, + \code{ordistep} and \code{ordiR2step} could fail if there were + aliased candidate variables, or constraints that were completely + explained by other variables already in the model. This was a + regression introduced in \pkg{vegan} 2.2-0. + + \item Constrained ordination methods \code{cca}, \code{rda} and + \code{capscale} treat character variables as factors in analysis, + but did not return their centroids for plotting. + + \item Recovery of original data in \code{metaMDS} when computing + WA scores for species would fail if the expression supplied to + argument \code{comm} was long & got deparsed to multiple + strings. \code{metaMDSdist} now returns the (possibly modified) + data frame of community data \code{comm} as attribute + \code{"comm"} of the returned \code{dist} object. \code{metaMDS} + now uses this to compute the WA species scores for the NMDS. In + addition, the deparsed expression for \code{comm} is now robust to + long expressions. Reported by Richard Telford. + + \item Function \code{rarecurve} did not check its input and this + could cause confusing error messages. Now function checks that + input data are integers that can be interpreted as counts on + individuals and all sampling units have some species. Unchecked + bad inputs were the reason for problems reported in + \href{http://stackoverflow.com/questions/30856909/error-while-using-rarecurve-in-r}{Stackoverflow (Error while using rarecurve)}. + + } + + } + +} + \section{Changes in version 2.3-0}{ \subsection{BUG FIXES}{ From noreply at r-forge.r-project.org Fri Aug 28 10:22:19 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 28 Aug 2015 10:22:19 +0200 (CEST) Subject: [Vegan-commits] r2957 - in pkg/vegan: R inst Message-ID: <20150828082219.DE292186CCA@r-forge.r-project.org> Author: jarioksa Date: 2015-08-28 10:22:19 +0200 (Fri, 28 Aug 2015) New Revision: 2957 Modified: pkg/vegan/R/adonis.R pkg/vegan/R/anosim.R pkg/vegan/R/anova.cca.R pkg/vegan/R/anova.ccabyterm.R pkg/vegan/R/anova.ccalist.R pkg/vegan/R/factorfit.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R pkg/vegan/R/mrpp.R pkg/vegan/R/mso.R pkg/vegan/R/oecosimu.R pkg/vegan/R/ordiareatest.R pkg/vegan/R/permutest.betadisper.R pkg/vegan/R/permutest.cca.R pkg/vegan/R/print.permutest.cca.R pkg/vegan/R/protest.R pkg/vegan/R/simper.R pkg/vegan/R/vectorfit.R pkg/vegan/inst/NEWS.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/adonis.R =================================================================== --- pkg/vegan/R/adonis.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/adonis.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -3,6 +3,7 @@ contr.unordered="contr.sum", contr.ordered="contr.poly", parallel = getOption("mc.cores"), ...) { + EPS <- sqrt(.Machine$double.eps) ## use with >= in permutation P-values ## formula is model formula such as Y ~ A + B*C where Y is a data ## frame or a matrix, and A, B, and C may be factors or continuous ## variables. data is the data frame from which A, B, and C would @@ -132,10 +133,7 @@ ## Close socket cluster if created here if (isParal && !isMulticore && !hasClus) stopCluster(parallel) - ## Round to avoid arbitrary P-values with tied data - f.perms <- round(f.perms, 12) - F.Mod <- round(F.Mod, 12) - P <- (rowSums(t(f.perms) >= F.Mod)+1)/(permutations+1) + P <- (rowSums(t(f.perms) >= F.Mod - EPS)+1)/(permutations+1) } else { # no permutations f.perms <- P <- rep(NA, nterms) } Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/anosim.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function (dat, grouping, permutations = 999, distance = "bray", strata = NULL, parallel = getOption("mc.cores")) { + EPS <- sqrt(.Machine$double.eps) if (inherits(dat, "dist")) x <- dat else if (is.matrix(dat) && nrow(dat) == ncol(dat) && all(dat[lower.tri(dat)] == @@ -65,7 +66,7 @@ } else { perm <- sapply(1:permutations, function(i) ptest(permat[i,])) } - p.val <- (1 + sum(perm >= statistic))/(1 + permutations) + p.val <- (1 + sum(perm >= statistic - EPS))/(1 + permutations) } else { # no permutations p.val <- perm <- NA } Modified: pkg/vegan/R/anova.cca.R =================================================================== --- pkg/vegan/R/anova.cca.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/anova.cca.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -4,6 +4,7 @@ parallel = getOption("mc.cores"), strata = NULL, cutoff = 1, scope = NULL) { + EPS <- sqrt(.Machine$double.eps) # for permutation P-values model <- match.arg(model) ## permutation matrix N <- nrow(object$CA$u) @@ -58,7 +59,7 @@ tst <- permutest.cca(object, permutations = permutations, model = model, parallel = parallel, ...) Fval <- c(tst$F.0, NA) - Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) + Pval <- (sum(tst$F.perm >= tst$F.0 - EPS) + 1)/(tst$nperm + 1) Pval <- c(Pval, NA) table <- data.frame(tst$df, tst$chi, Fval, Pval) if (inherits(object, "capscale") && Modified: pkg/vegan/R/anova.ccabyterm.R =================================================================== --- pkg/vegan/R/anova.ccabyterm.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/anova.ccabyterm.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -56,6 +56,7 @@ `anova.ccabymargin` <- function(object, permutations, scope, ...) { + EPS <- sqrt(.Machine$double.eps) nperm <- nrow(permutations) ## Refuse to handle models with missing data if (!is.null(object$na.action)) @@ -95,7 +96,7 @@ Fval <- sweep(Fval, 2, Df, "/") Fval <- sweep(Fval, 1, scale, "/") ## Simulated P-values - Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1) + Pval <- (colSums(sweep(Fval, 2, Fstat - EPS, ">=")) + 1)/(nperm + 1) ## Collect results to anova data.frame out <- data.frame(c(Df, dfbig), c(Chisq, chibig), c(Fstat, NA), c(Pval, NA)) @@ -123,6 +124,7 @@ `anova.ccabyaxis` <- function(object, permutations, model, parallel, cutoff = 1) { + EPS <- sqrt(.Machine$double.eps) nperm <- nrow(permutations) ## Observed F-values and Df eig <- object$CCA$eig Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/anova.ccalist.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -1,6 +1,7 @@ `anova.ccalist` <- function(object, permutations, model, parallel) { + EPS <- sqrt(.Machine$double.eps) ## 'object' *must* be a list of cca objects, and 'permutations' ## *must* be a permutation matrix -- we assume that calling ## function takes care of this, and this function is not directly @@ -67,8 +68,8 @@ pfvals <- matrix(pfvals, nrow=1, ncol=nperm) pfvals <- sweep(pfvals, 1, df, "/") pfvals <- sweep(pfvals, 2, pscale, "/") - pval <- rowSums(sweep(pfvals, 1, fval, ">=")) - pval <- (pval + 1)/(nperm+1) + pval <- rowSums(sweep(pfvals, 1, fval - EPS, ">=")) + pval <- (pval + 1)/(nperm + 1) ## collect table table <- data.frame(resdf, resdev, c(NA, df), c(NA,changedev), c(NA,fval), c(NA,pval)) Modified: pkg/vegan/R/factorfit.R =================================================================== --- pkg/vegan/R/factorfit.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/factorfit.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -1,6 +1,7 @@ `factorfit` <- function (X, P, permutations = 0, strata = NULL, w, ...) { + EPS <- sqrt(.Machine$double.eps) P <- as.data.frame(P) ## Check that all variables are factors, and coerce if necessary if(any(!sapply(P, is.factor))) @@ -50,7 +51,7 @@ } tmp <- sapply(seq_len(permutations), function(indx,...) ptest(permat[indx,], ...)) - pval.this <- (sum(tmp >= r.this) + 1)/(permutations + 1) + pval.this <- (sum(tmp >= r.this - EPS) + 1)/(permutations + 1) pval <- c(pval, pval.this) } } Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/mantel.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function (xdis, ydis, method = "pearson", permutations = 999, strata = NULL, na.rm = FALSE, parallel = getOption("mc.cores")) { + EPS <- sqrt(.Machine$double.eps) xdis <- as.dist(xdis) ydis <- as.vector(as.dist(ydis)) ## Handle missing values @@ -54,7 +55,7 @@ } else { perm <- sapply(1:permutations, function(i, ...) ptest(permat[i,], ...)) } - signif <- (sum(perm >= statistic) + 1)/(permutations + 1) + signif <- (sum(perm >= statistic - EPS) + 1)/(permutations + 1) } else { signif <- NA Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/mantel.partial.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function (xdis, ydis, zdis, method = "pearson", permutations = 999, strata = NULL, na.rm = FALSE, parallel = getOption("mc.cores")) { + EPS <- sqrt(.Machine$double.eps) part.cor <- function(rxy, rxz, ryz) { (rxy - rxz * ryz)/sqrt(1-rxz*rxz)/sqrt(1-ryz*ryz) } @@ -62,7 +63,7 @@ } else { perm <- sapply(1:permutations, function(i, ...) ptest(permat[i,], ...)) } - signif <- (sum(perm >= statistic)+1)/(permutations + 1) + signif <- (sum(perm >= statistic - EPS)+1)/(permutations + 1) } else { signif <- NA Modified: pkg/vegan/R/mrpp.R =================================================================== --- pkg/vegan/R/mrpp.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/mrpp.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -3,6 +3,7 @@ weight.type = 1, strata = NULL, parallel = getOption("mc.cores")) { + EPS <- sqrt(.Machine$double.eps) classmean <- function(ind, dmat, indls) { sapply(indls, function(x) mean(c(dmat[ind == x, ind == x]), @@ -69,7 +70,7 @@ } else { m.ds <- apply(perms, 2, function(x) mrpp.perms(x, dmat, indls, w)) } - p <- (1 + sum(del >= m.ds))/(permutations + 1) + p <- (1 + sum(del + EPS >= m.ds))/(permutations + 1) r2 <- 1 - del/E.del } else { # no permutations m.ds <- p <- r2 <- NA Modified: pkg/vegan/R/mso.R =================================================================== --- pkg/vegan/R/mso.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/mso.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function (object.cca, object.xy, grain = 1, round.up = FALSE, permutations = 0) { + EPS <- sqrt(.Machine$double.eps) if (inherits(object.cca, "mso")) { rm <- which(class(object.cca) == "mso") class(object.cca) <- class(object.cca)[-rm] @@ -76,7 +77,8 @@ } perm <- sapply(1:nperm, function(take) permfunc(permat[take,])) object$vario$CA.signif <- - (rowSums(sweep(perm, 1, statistic, ">=")) + 1)/(nperm + 1) + (rowSums(sweep(perm, 1, statistic - EPS, ">=")) + 1)/ + (nperm + 1) attr(object$vario, "control") <- attr(permat, "control") } object$call <- match.call() Modified: pkg/vegan/R/oecosimu.R =================================================================== --- pkg/vegan/R/oecosimu.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/oecosimu.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -143,8 +143,15 @@ z <- (indstat - means)/sd if (any(sd < sqrt(.Machine$double.eps))) z[sd < sqrt(.Machine$double.eps)] <- 0 - pless <- rowSums(indstat >= simind, na.rm = TRUE) - pmore <- rowSums(indstat <= simind, na.rm = TRUE) + ## results can be integers or real: comparisons differ + if (is.integer(indstat) && is.integer(simind)) { + pless <- rowSums(indstat >= simind, na.rm = TRUE) + pmore <- rowSums(indstat <= simind, na.rm = TRUE) + } else { + EPS <- sqrt(.Machine$double.eps) + pless <- rowSums(indstat + EPS >= simind, na.rm = TRUE) + pmore <- rowSums(indstat - EPS <= simind, na.rm = TRUE) + } if (any(is.na(simind))) { warning("some simulated values were NA and were removed") nsimul <- nsimul - rowSums(is.na(simind)) Modified: pkg/vegan/R/ordiareatest.R =================================================================== --- pkg/vegan/R/ordiareatest.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/ordiareatest.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -16,6 +16,7 @@ function(ord, groups, area = c("hull", "ellipse"), permutations = 999, parallel = getOption("mc.cores"), ...) { + EPS <- sqrt(.Machine$double.eps) ## Function to find area area <- match.arg(area) areafun <- if (area == "hull") ordihull else ordiellipse @@ -47,7 +48,7 @@ } else { areas <- sapply(1:permutations, function(i, ...) pfun(perm[i,], ...)) } - signif <- (rowSums(areas <= obs) + 1)/(nperm + 1) + signif <- (rowSums(areas <= obs + EPS) + 1)/(nperm + 1) out <- list("areas" = obs, "pvalues" = signif, "permutations" = areas, nperm = nperm, control = attr(perm, "control"), "kind" = area) class(out) <- "ordiareatest" Modified: pkg/vegan/R/permutest.betadisper.R =================================================================== --- pkg/vegan/R/permutest.betadisper.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/permutest.betadisper.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ permutations = 999, parallel = getOption("mc.cores"), ...) { + EPS <- sqrt(.Machine$double.eps) # for P-value comparisons t.statistic <- function(x, y) { m <- length(x) n <- length(y) @@ -104,8 +105,8 @@ ## Process results F0 <- summary(mod)$fstatistic[1] - Fstats <- round(Pstats[, 1], 12) # allow empty dim to be dropped - statistic <- F0 <- round(F0, 12) + Fstats <- Pstats[, 1] # allow empty dim to be dropped + statistic <- F0 names(statistic) <- "Overall (F)" ## pairwise comparisons @@ -113,13 +114,12 @@ T0 <- apply(combn(levels(group), 2), 2, function(z) { t.statistic(x$distances[group == z[1]], x$distances[group == z[2]])}) - Tstats <- round(Pstats[, -1, drop = FALSE], 12) - T0 <- round(T0, 12) + Tstats <- Pstats[, -1, drop = FALSE] statistic <- c(statistic, T0) } ## compute permutation p-value - pval <- (sum(Fstats >= F0) + 1) / (length(Fstats) + 1) + pval <- (sum(Fstats >= F0 - EPS) + 1) / (length(Fstats) + 1) if(pairwise) { df <- apply(combin, 2, function(z) { Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/permutest.cca.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -139,10 +139,6 @@ num <- tmp[,1] den <- tmp[,2] F.perm <- tmp[,3] - ## Round to avoid arbitrary ordering of statistics due to - ## numerical inaccuracy - F.0 <- round(F.0, 12) - F.perm <- round(F.perm, 12) Call <- match.call() Call[[1]] <- as.name("permutest") sol <- list(call = Call, testcall = x$call, model = model, Modified: pkg/vegan/R/print.permutest.cca.R =================================================================== --- pkg/vegan/R/print.permutest.cca.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/print.permutest.cca.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -1,10 +1,11 @@ `print.permutest.cca` <- function (x, ...) { + EPS <- sqrt(.Machine$double.eps) cat("\nPermutation test for", x$method, "\n\n") cat(howHead(x$control), "\n") writeLines(strwrap(pasteCall(x$testcall))) - Pval <- (sum(x$F.perm >= x$F.0) + 1)/(x$nperm + 1) + Pval <- (sum(x$F.perm >= x$F.0 - EPS) + 1)/(x$nperm + 1) cat("Permutation test for ") if (x$first) cat("first constrained eigenvalue\n") Modified: pkg/vegan/R/protest.R =================================================================== --- pkg/vegan/R/protest.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/protest.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function (X, Y, scores = "sites", permutations = how(nperm = 999), ...) { + EPS <- sqrt(.Machine$double.eps) X <- scores(X, display = scores, ...) Y <- scores(Y, display = scores, ...) ## Centre and normalize X & Y here so that the permutations will @@ -34,7 +35,7 @@ perm <- sapply(seq_len(np), function(i, ...) procr(X, Y[permutations[i,],])) - Pval <- (sum(perm >= sol$t0) + 1)/(np + 1) + Pval <- (sum(perm >= sol$t0 - EPS) + 1)/(np + 1) sol$t <- perm sol$signif <- Pval Modified: pkg/vegan/R/simper.R =================================================================== --- pkg/vegan/R/simper.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/simper.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -2,6 +2,7 @@ function(comm, group, permutations = 0, trace = FALSE, parallel = getOption("mc.cores"), ...) { + EPS <- sqrt(.Machine$double.eps) if (any(rowSums(comm, na.rm = TRUE) == 0)) warning("you have empty rows: results may be meaningless") pfun <- function(x, comm, comp, i, contrp) { @@ -78,7 +79,7 @@ perm.contr <- sapply(1:nperm, function(d) pfun(d, comm, comp, i, contrp)) } - p <- (rowSums(apply(perm.contr, 2, function(x) x >= average)) + 1) / (nperm + 1) + p <- (rowSums(apply(perm.contr, 2, function(x) x >= average - EPS)) + 1) / (nperm + 1) } else { p <- NULL Modified: pkg/vegan/R/vectorfit.R =================================================================== --- pkg/vegan/R/vectorfit.R 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/R/vectorfit.R 2015-08-28 08:22:19 UTC (rev 2957) @@ -1,6 +1,7 @@ "vectorfit" <- function (X, P, permutations = 0, strata = NULL, w, ...) { + EPS <- sqrt(.Machine$double.eps) if (missing(w) || is.null(w)) w <- 1 if (length(w) == 1) @@ -47,7 +48,7 @@ ## permutations are the matrix columns and variables are rows if (!is.matrix(permstore)) permstore <- matrix(permstore, ncol=permutations) - permstore <- sweep(permstore, 1, r, ">=") + permstore <- sweep(permstore, 1, r - EPS, ">=") validn <- rowSums(is.finite(permstore)) pvals <- (rowSums(permstore, na.rm = TRUE) + 1)/(validn + 1) } Modified: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2015-08-28 07:40:29 UTC (rev 2956) +++ pkg/vegan/inst/NEWS.Rd 2015-08-28 08:22:19 UTC (rev 2957) @@ -7,6 +7,20 @@ \subsection{BUG FIXES}{ \itemize{ + \item Permutation tests did not always correctly recognize ties + with the observed statistic and this could result in too low + \eqn{P}-values. This would happen in particular when all predictor + variables were factors (classes). The changes concern functions + \code{adonis}, \code{anosim}, \code{anova} and \code{permutest} + functions for \code{cca}, \code{rda} and \code{capscale}, + \code{permutest} for \code{betadisper}, \code{envfit}, + \code{mantel} and \code{mantel.partial}, \code{mrpp}, \code{mso}, + \code{oecosimu}, \code{ordiareatest}, \code{protest} and + \code{simper}. This also fixes issues + \href{https://github.com/vegandevs/vegan/issues/120}{#120} and + \href{https://github.com/vegandevs/vegan/issues/132}{#132} in + GitHub. + \item Automated model building in constrained ordination (\code{cca}, \code{rda}, \code{capscale}) with \code{step}, \code{ordistep} and \code{ordiR2step} could fail if there were From noreply at r-forge.r-project.org Fri Aug 28 10:24:02 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 28 Aug 2015 10:24:02 +0200 (CEST) Subject: [Vegan-commits] r2958 - www Message-ID: <20150828082402.93ABE1876B4@r-forge.r-project.org> Author: jarioksa Date: 2015-08-28 10:24:02 +0200 (Fri, 28 Aug 2015) New Revision: 2958 Modified: www/NEWS.html Log: NEWS of 2.3-1 Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2015-08-28 08:22:19 UTC (rev 2957) +++ www/NEWS.html 2015-08-28 08:24:02 UTC (rev 2958) @@ -7,6 +7,65 @@

vegan News

+

Changes in version 2.3-1

+ + + +

BUG FIXES

+ + + + + + +

Changes in version 2.3-0