From noreply at r-forge.r-project.org Sat Feb 2 08:31:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 08:31:04 +0100 (CET) Subject: [Vegan-commits] r2400 - in pkg/vegan: . R inst man Message-ID: <20130202073104.17ED9183D8C@r-forge.r-project.org> Author: jarioksa Date: 2013-02-02 08:31:03 +0100 (Sat, 02 Feb 2013) New Revision: 2400 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/oecosimu.R pkg/vegan/R/print.oecosimu.R pkg/vegan/inst/ChangeLog pkg/vegan/man/oecosimu.Rd Log: oecosimu: better fix than r2394 -- changes the structure of the result object Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-01-31 13:48:28 UTC (rev 2399) +++ pkg/vegan/DESCRIPTION 2013-02-02 07:31:03 UTC (rev 2400) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-24 -Date: January 25, 2013 +Version: 2.1-25 +Date: February 2, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: pkg/vegan/R/oecosimu.R =================================================================== --- pkg/vegan/R/oecosimu.R 2013-01-31 13:48:28 UTC (rev 2399) +++ pkg/vegan/R/oecosimu.R 2013-02-02 07:31:03 UTC (rev 2400) @@ -123,17 +123,12 @@ if (is.null(names(indstat)) && length(indstat) == 1) names(indstat) <- statistic - ## $oecosimu cannot be added to a data frame, but this gives - ## either an error or a mess - if (is.data.frame(ind)) - ind <- as.list(ind) - if (!is.list(ind)) - ind <- list(statistic = ind) - ind$oecosimu <- list(z = z, means = means, pval = p, simulated=simind, - method=method, statistic = indstat, - alternative = alternative, isSeq = attr(x, "isSeq")) - attr(ind, "call") <- match.call() - class(ind) <- c("oecosimu", class(ind)) - ind + oecosimu <- list(z = z, means = means, pval = p, simulated=simind, + method=method, statistic = indstat, + alternative = alternative, isSeq = attr(x, "isSeq")) + out <- list(statistic = ind, oecosimu = oecosimu) + attr(out, "call") <- match.call() + class(out) <- "oecosimu" + out } Modified: pkg/vegan/R/print.oecosimu.R =================================================================== --- pkg/vegan/R/print.oecosimu.R 2013-01-31 13:48:28 UTC (rev 2399) +++ pkg/vegan/R/print.oecosimu.R 2013-02-02 07:31:03 UTC (rev 2400) @@ -20,10 +20,10 @@ ## dim attribute is always there, but print all others cat("\n\n") - cl <- class(x) - if ((length(cl) > 1 && cl[2] != "list" ) && - !any(cl %in% c("adipart", "hiersimu", "multipart"))) { - NextMethod("print", x) + + if (!inherits(x, c("adipart", "hiersimu", "multipart")) && + !inherits(x$statistic, c("numeric", "list"))) { + print(x$statistic) cat("\n") } probs <- switch(x$oecosimu$alternative, Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-01-31 13:48:28 UTC (rev 2399) +++ pkg/vegan/inst/ChangeLog 2013-02-02 07:31:03 UTC (rev 2400) @@ -2,8 +2,21 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-24 (opened January 25, 2013) +Version 2.1-25 (opened February 2, 2013) + * oecosimu: changed the structure of the oecosimu() result + object. It now returns a list of two items: "statistic" is the + observed statistic, and "oecosimu" which contains the simulation + records. In previous version the function returned the statistic + and added item "oecosimu" there. Previously, the result object was + of type c("oecosimu", class(statistic)) as the original + "statistic" object was returned amended with an "oecosimu" item, + but now it is only of type "oecosimu" with the original + "statistic" as a separate item. So "statistic" is now one level + deeper instead of being the main object. + +Version 2.1-24 (closed February 2, 2013) + * simulate.nullmodel: output array inherits dimnames after the input data matrix, this is often required by oecosimu. Dimension names are now only stored once for all nsim @@ -20,9 +33,8 @@ (like would be the case if the 'statistic' was extracted from a data frame). It is now checked that only one 'statistic' is given and a comprehensible error message is issued instead of the - current confusing one. The changes were trickered in an attempt to - use picante::pd(), but this still fails because picante::pd() - needs column names that are not generated in nullmodel(). + current confusing one. The changes were trickered when testing + picante::pd(). * protest: huge speed-up. Instead of calling procrustes() in every permutation step, we only calculate the goodness of fit statistic Modified: pkg/vegan/man/oecosimu.Rd =================================================================== --- pkg/vegan/man/oecosimu.Rd 2013-01-31 13:48:28 UTC (rev 2399) +++ pkg/vegan/man/oecosimu.Rd 2013-02-02 07:31:03 UTC (rev 2400) @@ -164,13 +164,22 @@ } \value{ - Function \code{oecosimu} returns the result of \code{nestfun} added - with a component called \code{oecosimu}. The \code{oecosimu} - component contains the simulated values of the statistic (item - \code{simulated}), the name of the \code{method}, \eqn{P} value - (with given \code{alternative}), \eqn{z}-value of the statistic - based on simulation (also known as standardized effect size), and - the mean of simulations. + + Function \code{oecosimu} returns an object of class + \code{"oecosimu"}. The result object has items \code{statistic} and + \code{oecosimu}. The \code{statistic} contains the complete object + returned by \code{nestedfun} for the original data. The + \code{oecosimu} component contains the following items: + \item{statistic}{Observed values of the statistic.} + \item{simulated}{Simulated values of the statistic.} + \item{means}{Mean values of the statistic from simulations.} + \item{z}{\eqn{z}-values or the standardized effect sizes of the observed + statistic based on simulations.} + \item{pval}{The \eqn{P}-values of the statistic based on simulations.} + \item{alternative}{The type of testing as given in argument \code{alternative}.} + \item{method}{The \code{method} used in \code{\link{nullmodel}}.} + \item{isSeq}{\code{TRUE} if \code{method} was sequential.} + } \references{ From noreply at r-forge.r-project.org Sat Feb 2 17:43:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 17:43:42 +0100 (CET) Subject: [Vegan-commits] r2401 - in pkg/vegan: R inst Message-ID: <20130202164342.D8263183DDF@r-forge.r-project.org> Author: jarioksa Date: 2013-02-02 17:43:42 +0100 (Sat, 02 Feb 2013) New Revision: 2401 Modified: pkg/vegan/R/simulate.rda.R pkg/vegan/inst/ChangeLog Log: simulate for rda & cca also return dimnames (like does simulate.nullmodel since r2396) Modified: pkg/vegan/R/simulate.rda.R =================================================================== --- pkg/vegan/R/simulate.rda.R 2013-02-02 07:31:03 UTC (rev 2400) +++ pkg/vegan/R/simulate.rda.R 2013-02-02 16:43:42 UTC (rev 2401) @@ -53,6 +53,8 @@ ans <- ans[,,1] attributes(ans) <- attributes(ftd) } else { + dimnames(ans) <- list(rownames(ftd), colnames(ftd), + paste("sim", seq_len(nsim), sep = "_")) attr(ans, "data") <- round(ftd + object$CA$Xbar, 12) attr(ans, "method") <- paste("simulate", ifelse(is.null(indx), "parametric", "index")) @@ -131,6 +133,8 @@ ans <- ans[,,1] attributes(ans) <- attributes(ftd) } else { + dimnames(ans) <- list(rownames(ftd), colnames(ftd), + paste("sim", seq_len(nsim), sep = "_")) obsdata <- ftd + object$CA$Xbar obsdata <- (obsdata * sqrt(rc) + rc) * object$grand.total attr(ans, "data") <- round(obsdata, 12) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-02 07:31:03 UTC (rev 2400) +++ pkg/vegan/inst/ChangeLog 2013-02-02 16:43:42 UTC (rev 2401) @@ -14,6 +14,11 @@ but now it is only of type "oecosimu" with the original "statistic" as a separate item. So "statistic" is now one level deeper instead of being the main object. + + * simulate: the simulate functions for "rda" and "cca" return + objects with original row and column names. Function capscale() + already did so, and simulate.nullmodel() was changed so in vegan + 2.1-24 (r2396). Version 2.1-24 (closed February 2, 2013) From noreply at r-forge.r-project.org Sun Feb 3 08:28:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Feb 2013 08:28:53 +0100 (CET) Subject: [Vegan-commits] r2402 - branches/2.0/inst Message-ID: <20130203072853.7025418121E@r-forge.r-project.org> Author: jarioksa Date: 2013-02-03 08:28:53 +0100 (Sun, 03 Feb 2013) New Revision: 2402 Modified: branches/2.0/inst/NEWS.Rd Log: skeleton of NEWS: prepare for a February release of vegan 2.0-6 Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-02-02 16:43:42 UTC (rev 2401) +++ branches/2.0/inst/NEWS.Rd 2013-02-03 07:28:53 UTC (rev 2402) @@ -2,6 +2,54 @@ \title{vegan News} \encoding{UTF-8} +\section{Changes in version 2.0-6}{ + + \subsection{BUG FIXES}{ + + \itemize{ + + \item \code{capscale} scaled species scores wrongly when other + dissimilarties than Euclidean distances were used. + + \item \code{clamtest} + + \item \code{envfit} handles unused factor levels. + + \item \code{multipart} printed wrong information about the + analysis type (but did analysis correctly). + + \item \code{procrustes} + + \item \code{treedive} and \code{treedist} name matching. + + } + + } % bug fixes + + \subsection{NEW FEATURES}{ + + \itemize{ + + \item \code{dispindmorisita} gains \eqn{P}-value. + + \item \code{metaMDS} and \code{monoMDS} have new default + convergence criteria. + + \item \code{ordiR2step} gained new argument \code{R2scope} and + handles partial redundancy analysis (pRDA). + + \item \code{orditorp} gained argument \code{select} + + \item \code{protest} prints both \eqn{m_{12}^2}{squared m12} and + \eqn{R^2}{R2}. + + } + + } % new features + + +} % end 2.0-6 + \section{Changes in version 2.0-5}{ \subsection{BUG FIXES}{ From noreply at r-forge.r-project.org Sun Feb 3 16:50:31 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Feb 2013 16:50:31 +0100 (CET) Subject: [Vegan-commits] r2403 - branches/2.0/inst www Message-ID: <20130203155031.D986B1849A0@r-forge.r-project.org> Author: jarioksa Date: 2013-02-03 16:50:31 +0100 (Sun, 03 Feb 2013) New Revision: 2403 Modified: branches/2.0/inst/NEWS.Rd www/NEWS.html Log: NEWS about release 2.0-6 Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-02-03 07:28:53 UTC (rev 2402) +++ branches/2.0/inst/NEWS.Rd 2013-02-03 15:50:31 UTC (rev 2403) @@ -8,20 +8,41 @@ \itemize{ - \item \code{capscale} scaled species scores wrongly when other - dissimilarties than Euclidean distances were used. + \item The species scores were scaled correctly in + \code{capscale()} only when Euclidean distances were used. Most + graphics will change and should be redone. The function also + now displays the value of the additive constant when argument + \code{add = TRUE} was used. - \item \code{clamtest} + \item Function \code{clamtest()} failed to set the minimum + abundance threshold in some cases. The output was wrong when + some of the possible species groups were missing. The problems + were reported by Richard Telford (Bergen, Norway). - \item \code{envfit} handles unused factor levels. + \item Plotting an object fitted by \code{envfit()} would fail if + \code{p.max} was used and there were unused levels for one or + more factors. The unused levels could result from deletion of + observations with missing values or simply the result of + supplying a subset of a larger data set to \code{envfit()}. - \item \code{multipart} printed wrong information about the - analysis type (but did analysis correctly). + \item \code{multipart()} printed wrong information about the + analysis type (but did analysis correctly). Reported by Valerie + Coudrain. - \item \code{procrustes} + \item \code{oecosimu()} failed if its \code{nestedfun} returned + a data frame. A more fundamental fix will be in \pkg{vegan} + 2.2-0. - \item \code{treedive} and \code{treedist} name matching. + \item The plot of two-dimensional \code{procrustes()} solutions + often draw original axes in a wrong angle. The problem was + reported by Elizabeth Ottesen (MIT). + \item Function \code{treedive()} for functional diversity did + not correctly match the species names in the community data and + classification tree when the tree containted species that did + not occur in the data. Related function \code{treedist()} for + phylogenetic distances did not try to match the names at all. + } } % bug fixes @@ -30,19 +51,48 @@ \itemize{ - \item \code{dispindmorisita} gains \eqn{P}-value. + \item \code{dispindmorisita()} output gained a new column for + Chi-squared based probabilities that the null hypothesis (random + distribution) is true. - \item \code{metaMDS} and \code{monoMDS} have new default - convergence criteria. + \item \code{metaMDS()} and \code{monoMDS()} have new default + convergence criteria. Most importantly, scale factor of the + gradient (\code{sfgrmin}) is stricter. The former limit was too + slack with large data sets and iterations stopped early without + getting close to the solution. In addition, \code{scores()} + ignore now requests to dimensions beyond those calculated + instead of failing, and \code{scores()} for \code{metaMDS()} + results do not drop dimensions. - \item \code{ordiR2step} gained new argument \code{R2scope} and - handles partial redundancy analysis (pRDA). + \item \code{msoplot()} gained \code{legend} argument for + positioning the legend. - \item \code{orditorp} gained argument \code{select} + \item Nestedness function \code{nestednodf()} gained a \code{plot} + method. - \item \code{protest} prints both \eqn{m_{12}^2}{squared m12} and - \eqn{R^2}{R2}. + \item \code{ordiR2step()} gained new argument \code{R2scope} + (defaults \code{TRUE}) which can be used to turn off the + criterion of stopping when the adjusted \eqn{R^2}{R2} of the + current model exceeds that of the scope. This option allows + model building when the \code{scope} would be overdetermined + (number of predictors higher than number of observations). + \code{ordiR2step()} now handles partial redundancy analysis + (pRDA). + + \item \code{orditorp()} gained argument \code{select} to select + the rows or columns of the results to display. + + \item \code{protest()} prints the standardized residual sum of + squared \eqn{m_{12}^2}{squared m12} in addition to the squared + Procrustes correlation \eqn{R^2}{R2}. Both were calculated, but + only the latter was displayed. + + \item \code{wcmdscale()} gained methods for \code{print}, + \code{plot} etc. of the results. These methods are only used if + the full \code{wcmdscale} result is returned with, e.g., + argument \code{eig = TRUE}. + } } % new features Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-02-03 07:28:53 UTC (rev 2402) +++ www/NEWS.html 2013-02-03 15:50:31 UTC (rev 2403) @@ -8,6 +8,121 @@

vegan News

+

Changes in version 2.0-6

+ + + + +

BUG FIXES

+ + + + + + + + +

NEW FEATURES

+ + + + + + + +

Changes in version 2.0-5

From noreply at r-forge.r-project.org Mon Feb 4 14:18:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 14:18:50 +0100 (CET) Subject: [Vegan-commits] r2404 - pkg/vegan/man Message-ID: <20130204131850.3B5E9183EB7@r-forge.r-project.org> Author: jarioksa Date: 2013-02-04 14:18:49 +0100 (Mon, 04 Feb 2013) New Revision: 2404 Modified: pkg/vegan/man/cca.Rd Log: refer Legendre & Legendre presentation of the RDA algorithm in vegan Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2013-02-03 15:50:31 UTC (rev 2403) +++ pkg/vegan/man/cca.Rd 2013-02-04 13:18:49 UTC (rev 2404) @@ -65,7 +65,10 @@ regression on constraining variables, and the fitted values are submitted to correspondence analysis performed via singular value decomposition (\code{\link{svd}}). Function \code{rda} is similar, but uses - ordinary, unweighted linear regression and unweighted SVD. + ordinary, unweighted linear regression and unweighted SVD. Legendre & + Legendre (2012), Table 11.5 (p. 650) give a skeleton of the RDA + algorithm of \pgk{vegan}. The algorithm of CCA is similar, but + involves standardization by row and column weights. The functions can be called either with matrix-like entries for community data and constraints, or with formula interface. In general, the From noreply at r-forge.r-project.org Mon Feb 4 18:01:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 18:01:56 +0100 (CET) Subject: [Vegan-commits] r2405 - branches/2.0/man Message-ID: <20130204170156.41A3B184BAA@r-forge.r-project.org> Author: jarioksa Date: 2013-02-04 18:01:55 +0100 (Mon, 04 Feb 2013) New Revision: 2405 Modified: branches/2.0/man/cca.Rd Log: merge r2404: cca.Rd refers to L&L description of the RDA algorithm Modified: branches/2.0/man/cca.Rd =================================================================== --- branches/2.0/man/cca.Rd 2013-02-04 13:18:49 UTC (rev 2404) +++ branches/2.0/man/cca.Rd 2013-02-04 17:01:55 UTC (rev 2405) @@ -65,7 +65,10 @@ regression on constraining variables, and the fitted values are submitted to correspondence analysis performed via singular value decomposition (\code{\link{svd}}). Function \code{rda} is similar, but uses - ordinary, unweighted linear regression and unweighted SVD. + ordinary, unweighted linear regression and unweighted SVD. Legendre & + Legendre (2012), Table 11.5 (p. 650) give a skeleton of the RDA + algorithm of \pgk{vegan}. The algorithm of CCA is similar, but + involves standardization by row and column weights. The functions can be called either with matrix-like entries for community data and constraints, or with formula interface. In general, the From noreply at r-forge.r-project.org Mon Feb 4 18:45:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 18:45:14 +0100 (CET) Subject: [Vegan-commits] r2406 - in branches/2.0: R inst Message-ID: <20130204174514.AE38E18465A@r-forge.r-project.org> Author: jarioksa Date: 2013-02-04 18:45:14 +0100 (Mon, 04 Feb 2013) New Revision: 2406 Modified: branches/2.0/R/protest.R branches/2.0/inst/ChangeLog Log: merge r2388: faster protest, partly hand crafted Modified: branches/2.0/R/protest.R =================================================================== --- branches/2.0/R/protest.R 2013-02-04 17:01:55 UTC (rev 2405) +++ branches/2.0/R/protest.R 2013-02-04 17:45:14 UTC (rev 2406) @@ -3,14 +3,26 @@ { X <- scores(X, display = scores, ...) Y <- scores(Y, display = scores, ...) - sol <- procrustes(X, Y, symmetric = TRUE) + ## Centre and normalize X & Y here so that the permutations will + ## be faster + X <- scale(X, scale = FALSE) + Y <- scale(Y, scale = FALSE) + X <- X/sqrt(sum(X^2)) + Y <- Y/sqrt(sum(Y^2)) + ## Transformed X and Y will yield symmetric procrustes() and we + ## need not specify that in the call (but we set it symmetric + ## after the call). + sol <- procrustes(X, Y, symmetric = FALSE) + sol$symmetric <- TRUE sol$t0 <- sqrt(1 - sol$ss) N <- nrow(X) perm <- rep(0, permutations) for (i in 1:permutations) { take <- permuted.index(N, strata) - tmp <- procrustes(X, Y[take, ], symmetric = TRUE)$ss - perm[i] <- sqrt(1 - tmp) + ## avoid overhead of procrustes() and only evaluate the + ## statistic by svd (hand crafted from r2388 of the devel + ## branch). + perm[i] <- sum(svd(crossprod(X, Y[take,]), nv = 0, nu = 0)$d) } Pval <- (sum(perm >= sol$t0) + 1)/(permutations + 1) if (!missing(strata)) { Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-04 17:01:55 UTC (rev 2405) +++ branches/2.0/inst/ChangeLog 2013-02-04 17:45:14 UTC (rev 2406) @@ -4,10 +4,15 @@ Version 2.0-6 (opened October 8, 2012) + * merge 2404: refer Legendre & Legendre for the vegan rda + algorithm. * merge 2934 (partial, mc): oecosimu handles nestedfun() returning data.frame. Not merged: checking length of statistic when setting its name. * merge 2932,3: matching names in treedive() and treedist(). + * merge 2388 (partial): faster protest, the part of evaluating the + test statistic hand crafted, because parallelizations caused + conflicts here. * merge 2385, 7: protest print, faster sum of squares in procrustes. * merge 2384: new FAQ entries. * merge 2383: remove alias to print.wcmdscale. From noreply at r-forge.r-project.org Mon Feb 4 19:05:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 19:05:25 +0100 (CET) Subject: [Vegan-commits] r2407 - branches/2.0/inst www Message-ID: <20130204180525.4EC4A183EFD@r-forge.r-project.org> Author: jarioksa Date: 2013-02-04 19:05:25 +0100 (Mon, 04 Feb 2013) New Revision: 2407 Modified: branches/2.0/inst/NEWS.Rd www/NEWS.html Log: NEWS about merge of faster protest + tweaks Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-02-04 17:45:14 UTC (rev 2406) +++ branches/2.0/inst/NEWS.Rd 2013-02-04 18:05:25 UTC (rev 2407) @@ -39,7 +39,7 @@ \item Function \code{treedive()} for functional diversity did not correctly match the species names in the community data and - classification tree when the tree containted species that did + classification tree when the tree contained species that did not occur in the data. Related function \code{treedist()} for phylogenetic distances did not try to match the names at all. @@ -83,11 +83,15 @@ \item \code{orditorp()} gained argument \code{select} to select the rows or columns of the results to display. - \item \code{protest()} prints the standardized residual sum of - squared \eqn{m_{12}^2}{squared m12} in addition to the squared + \item \code{protest()} prints the standardized residual + statistic \eqn{m_{12}^2}{squared m12} in addition to the squared Procrustes correlation \eqn{R^2}{R2}. Both were calculated, but only the latter was displayed. + Permutation tests are much faster in \code{protest()}. Instead + of calling repeatedly \code{procrustes()}, the goodness of fit + statistic is evaluated within then function. + \item \code{wcmdscale()} gained methods for \code{print}, \code{plot} etc. of the results. These methods are only used if the full \code{wcmdscale} result is returned with, e.g., Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-02-04 17:45:14 UTC (rev 2406) +++ www/NEWS.html 2013-02-04 18:05:25 UTC (rev 2407) @@ -55,7 +55,7 @@
  • Function treedive() for functional diversity did not correctly match the species names in the community data and -classification tree when the tree containted species that did +classification tree when the tree contained species that did not occur in the data. Related function treedist() for phylogenetic distances did not try to match the names at all.

    @@ -107,11 +107,15 @@ the rows or columns of the results to display.

  • -
  • protest() prints the standardized residual sum of -squared squared m12 in addition to the squared +

  • protest() prints the standardized residual +statistic squared m12 in addition to the squared Procrustes correlation R2. Both were calculated, but only the latter was displayed.

    +

    Permutation tests are much faster in protest(). Instead +of calling repeatedly procrustes(), the goodness of fit +statistic is evaluated within then function. +

  • wcmdscale() gained methods for print, plot etc. of the results. These methods are only used if From noreply at r-forge.r-project.org Tue Feb 5 09:53:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 09:53:23 +0100 (CET) Subject: [Vegan-commits] r2408 - pkg/vegan/inst/doc Message-ID: <20130205085323.A4A1118083B@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 09:53:23 +0100 (Tue, 05 Feb 2013) New Revision: 2408 Modified: pkg/vegan/inst/doc/FAQ-vegan.texi Log: FAQ on random effects in cca, rda, capscale & adonis Modified: pkg/vegan/inst/doc/FAQ-vegan.texi =================================================================== --- pkg/vegan/inst/doc/FAQ-vegan.texi 2013-02-04 18:05:25 UTC (rev 2407) +++ pkg/vegan/inst/doc/FAQ-vegan.texi 2013-02-05 08:53:23 UTC (rev 2408) @@ -8,7 +8,7 @@ @setfilename FAQ- at pkg{vegan}.info @settitle @pkg{vegan} FAQ @setchapternewpage on - at set FAQ_YEAR 2012 + at set FAQ_YEAR 2013 @afourpaper @c %**end of header @@ -26,7 +26,7 @@ Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. -Copyright @copyright{} 2008-2012 Jari Oksanen +Copyright @copyright{} 2008-2013 Jari Oksanen @end quotation @end copying @@ -324,7 +324,7 @@ @chapter Ordination @menu -* I have only numeric and positive data but @pkg{vegan} still complaints:: +* I have only numeric and positive data but @pkg{vegan} still complains:: * Can I analyse binary or cover class data?:: * Why dissimilarities in @pkg{vegan} differ from other sources?:: * Why NMDS stress is sometimes 0.1 and sometimes 10?:: @@ -335,6 +335,7 @@ * How the RDA results are scaled?:: * cca fails with ``data.frame expected'' or ``"site.env" missing'':: * Variance explained by ordination axes:: +* Can I have random effects in constrained ordination or in @code{adonis}?:: * Is it possible to have passive points in ordination?:: * Class variables and dummies:: * How are environmental arrows scaled?:: @@ -348,9 +349,9 @@ * Can I zoom into an ordination plot?:: @end menu - at node I have only numeric and positive data but @pkg{vegan} still complaints, Can I analyse binary or cover class data?, Ordination, Ordination + at node I have only numeric and positive data but @pkg{vegan} still complains, Can I analyse binary or cover class data?, Ordination, Ordination @comment node-name, next, previous, up - at section I have only numeric and positive data but @pkg{vegan} still complaints + at section I have only numeric and positive data but @pkg{vegan} still complains You are wrong! Computers are painfully pedantic, and if they find non-numeric or negative data entries, you really have them. Check your @@ -361,7 +362,7 @@ the data). Another common reason is that you had empty cells in your input data, and these were interpreted as missing values. - at node Can I analyse binary or cover class data?, Why dissimilarities in @pkg{vegan} differ from other sources?, I have only numeric and positive data but @pkg{vegan} still complaints, Ordination + at node Can I analyse binary or cover class data?, Why dissimilarities in @pkg{vegan} differ from other sources?, I have only numeric and positive data but @pkg{vegan} still complains, Ordination @section Can I analyse binary or cover class data? Yes. Most @pkg{vegan} methods can handle binary data or cover abundance data. @@ -488,7 +489,7 @@ you do not need package @pkg{ade4}, you can detach it with command @code{detach(package:ade4)}. - at node Variance explained by ordination axes, Is it possible to have passive points in ordination?, cca fails with ``data.frame expected'' or ``"site.env" missing'', Ordination + at node Variance explained by ordination axes, Can I have random effects in constrained ordination or in @code{adonis}?, cca fails with ``data.frame expected'' or ``"site.env" missing'', Ordination @section Variance explained by ordination axes. In general, @pkg{vegan} does not directly give any statistics on the @@ -547,7 +548,46 @@ @end itemize - at node Is it possible to have passive points in ordination?, Class variables and dummies, Variance explained by ordination axes, Ordination + at node Can I have random effects in constrained ordination or in @code{adonis}?, Is it possible to have passive points in ordination?, Variance explained by ordination axes, Ordination + at section Can I have random effects in constrained ordination or in @code{adonis}? + +No. Strictly speaking, this is impossible. However, you can define +models that respond to similar goals as random effects models, although +they strictly speaking use only fixed effects. + +Constrained ordination functions @code{cca}, @code{rda} and + at code{capscale} can have @code{Condition()} terms in their formula. The + at code{Condition()} define partial terms that are fitted before other +constraints and can be used to remove the effects of background +variables, and their contribution to decomposing inertia (variance) is +reported separately. These partial terms are often regarded as similar +to random effects, but they are still fitted in the same way as other +terms and strictly speaking they are fixed terms. + +Function @code{adonis} evaluates terms sequentially. In a model with +right-hand-side @code{~ A + B} the effects of @code{A} are evaluated +first, and the effects of @code{B} after removing the effects of + at code{A}. Sequential tests are also available in @code{anova} function +for constrained ordination results by setting argument @code{by = "term"}. +In this way, the first terms can serve in a similar role as +random effects, although they are fitted in the same way as all other +terms, and strictly speaking they are fixed terms. + +The permutation tests can usually have a @code{strata} argument which +restricts the permutations within levels of a factor given in the +argument. This can be used to restrict the permutations within levels of +factor regarded as a random term. More structured permutations are +available with the @pkg{permute} package. + +A major reason why real random effects models are impossible in most + at pkg{vegan} functions is that their tests are based on the permutation +of the data. The data are given, that is fixed, and therefore +permutation tests are basically tests of fixed terms on fixed data. +Random effect terms would require permutations of data with a random +component instead of the given, fixed data, and such tests are not +available in @pkg{vegan}. + + at node Is it possible to have passive points in ordination?, Class variables and dummies, Can I have random effects in constrained ordination or in @code{adonis}?, Ordination @section Is it possible to have passive points in ordination? @pkg{Vegan} does not have a concept of passive points, or a point that should From noreply at r-forge.r-project.org Tue Feb 5 09:54:13 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 09:54:13 +0100 (CET) Subject: [Vegan-commits] r2409 - www Message-ID: <20130205085413.31E3118083B@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 09:54:12 +0100 (Tue, 05 Feb 2013) New Revision: 2409 Modified: www/FAQ-vegan.html Log: update HTML version of the FAQ Modified: www/FAQ-vegan.html =================================================================== --- www/FAQ-vegan.html 2013-02-05 08:53:23 UTC (rev 2408) +++ www/FAQ-vegan.html 2013-02-05 08:54:12 UTC (rev 2409) @@ -1,41 +1,40 @@ - - - + -vegan FAQ: vegan FAQ +vegan FAQ - - + + - - + + @@ -53,116 +54,114 @@ - - + - +
    [Top]
    [Top] [Contents] [Index] [ ? ]
    +

    vegan FAQ

    This document contains answers to some of the most frequently asked questions about R package vegan. -This is version of $Date: 2013-01-07 12:58:43 +0200 (Mon, 07 Jan 2013) $. - -

    -

    This work is licensed under the Creative Commons Attribution 3.0 +This is version of $Date: 2013-01-22 19:55:06 +0200 (Tue, 22 Jan 2013) $. +

    +

    This work is licensed under the Creative Commons Attribution 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. - -

    Copyright © 2008-2012 Jari Oksanen +

    +

    Copyright © 2008-2013 Jari Oksanen

    - - - -
    - - + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1. Introduction

    + +

    1. Introduction

    - - - - - - - - - - - - - - -
    - - + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.1 What is vegan?

    + +

    1.1 What is vegan?

    Vegan is an R package for community ecologists. It contains the most popular methods of multivariate analysis needed in analysing ecological @@ -171,96 +170,96 @@ R statistical environment, and it also depends on many other R packages. Vegan is free software and distributed under GPL2 license. - -


    - - +

    +
    + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.2 What is R?

    + +

    1.2 What is R?

    R is a system for statistical computation and graphics. It consists of a language plus a run-time environment with graphics, a debugger, access to certain system functions, and the ability to run programs stored in script files. - -

    R has a home page at http://www.R-project.org/. It is +

    +

    R has a home page at http://www.R-project.org/. It is free software -distributed under a GNU-style +distributed under a GNU-style copyleft, and an -official part of the GNU project -("GNU S"). - -


    - - +official part of the GNU project +(“GNU S”). +

    +
    + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.3 How to obtain vegan and R?

    + +

    1.3 How to obtain vegan and R?

    Both R and latest release version of vegan can be obtained through CRAN. Unstable development version of vegan can be obtained through R-Forge. -

    +
    - - + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.4 What R packages vegan depends on?

    + +

    1.4 What R packages vegan depends on?

    Vegan depends on the permute package which will provide advanced and flexible permutation routines for vegan (but currently only a small part of functions use permute). The permute package is developed together with vegan in R-Forge. - -

    Some individual vegan functions depend on packages MASS, +

    +

    Some individual vegan functions depend on packages MASS, mgcv, cluster, lattice and tcltk. These all are base or recommended R packages that should be available in every R installation. In addition, some vegan functions require @@ -268,62 +267,62 @@ suggested ones, and you can install vegan and use most of its functions without these packages. The non-standard packages needed by some vegan functions are: -


    - - + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.5 What other packages are available for ecologists?

    + +

    1.5 What other packages are available for ecologists?

    -

    CRAN Task Views include entries like Environmetrics, Multivariate +

    CRAN Task Views include entries like Environmetrics, Multivariate and Spatial that describe several useful packages and functions. If you install R package ctv, you can inspect Task Views from your R session, and automatically install sets of most important packages. - -


    - - +

    +
    + - - + + - - - + + + - +
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]         [Top][Top] [Contents] [Index] [ ? ]
    -

    1.6 What other documentation is available for vegan?

    + +

    1.6 What other documentation is available for vegan?

    Vegan is a fully documented R package with standard help pages. These are the most authoritative sources of documentation (and as a last @@ -331,56 +330,56 @@ source). Vegan package ships with other documents which can be read with vegandocs command (documented in the vegan help). The documents included in the vegan package are -

    Web documents outside the package include: -


    - - + - - + + - - - + + + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2409 From noreply at r-forge.r-project.org Tue Feb 5 09:57:36 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 09:57:36 +0100 (CET) Subject: [Vegan-commits] r2410 - pkg/vegan/inst Message-ID: <20130205085736.888E218083B@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 09:57:36 +0100 (Tue, 05 Feb 2013) New Revision: 2410 Modified: pkg/vegan/inst/ChangeLog Log: add ChangeLog entry on random effect FAQ Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-05 08:54:12 UTC (rev 2409) +++ pkg/vegan/inst/ChangeLog 2013-02-05 08:57:36 UTC (rev 2410) @@ -4,6 +4,10 @@ Version 2.1-25 (opened February 2, 2013) + * FAQ: new entry on impossibility of using random effects in cca, + rda, capscale & adonis, and telling how to do this + approximately. Please comment and correct. + * oecosimu: changed the structure of the oecosimu() result object. It now returns a list of two items: "statistic" is the observed statistic, and "oecosimu" which contains the simulation From noreply at r-forge.r-project.org Tue Feb 5 11:58:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 11:58:58 +0100 (CET) Subject: [Vegan-commits] r2411 - pkg/vegan/man Message-ID: <20130205105858.E3699184649@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 11:58:58 +0100 (Tue, 05 Feb 2013) New Revision: 2411 Modified: pkg/vegan/man/cca.Rd Log: Warning: vegan/man/cca.Rd:70: unknown macro '\pgk' Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2013-02-05 08:57:36 UTC (rev 2410) +++ pkg/vegan/man/cca.Rd 2013-02-05 10:58:58 UTC (rev 2411) @@ -67,7 +67,7 @@ decomposition (\code{\link{svd}}). Function \code{rda} is similar, but uses ordinary, unweighted linear regression and unweighted SVD. Legendre & Legendre (2012), Table 11.5 (p. 650) give a skeleton of the RDA - algorithm of \pgk{vegan}. The algorithm of CCA is similar, but + algorithm of \pkg{vegan}. The algorithm of CCA is similar, but involves standardization by row and column weights. The functions can be called either with matrix-like entries for community From noreply at r-forge.r-project.org Tue Feb 5 12:38:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 12:38:37 +0100 (CET) Subject: [Vegan-commits] r2412 - in pkg/vegan: R inst man Message-ID: <20130205113837.CC8BE1847F4@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 12:38:37 +0100 (Tue, 05 Feb 2013) New Revision: 2412 Modified: pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/R/simulate.rda.R pkg/vegan/inst/ChangeLog pkg/vegan/man/predict.cca.Rd Log: predict.cca(..., type='work') & predict.rda(..., type='resp') handle partial models Modified: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2013-02-05 10:58:58 UTC (rev 2411) +++ pkg/vegan/R/predict.cca.R 2013-02-05 11:38:37 UTC (rev 2412) @@ -31,13 +31,16 @@ } if (take > 0) Xbar <- u %*% slam %*% t(v) - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") rc <- outer(rs, cs) - if (type == "response") + if (type == "response") { + if (!is.null(object$pCCA)) + warning("Conditional ('partial') component ignored") out <- (Xbar + 1) * rc * gtot - else # type == "working" + } else { # type == "working" out <- Xbar * sqrt(rc) + if (!is.null(object$pCCA)) + out <- out + object$pCCA$Fit + } } else if (type == "lc") { if (model == "CA") Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2013-02-05 10:58:58 UTC (rev 2411) +++ pkg/vegan/R/predict.rda.R 2013-02-05 11:38:37 UTC (rev 2412) @@ -25,8 +25,6 @@ w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) if (type %in% c("response", "working")) { - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", newdata = newdata, rank = take) @@ -52,7 +50,11 @@ if (!is.null(scal)) out <- sweep(out, 2, scal, "*") out <- sweep(out, 2, cent, "+") + if (!is.null(object$pCCA)) + out <- out + object$pCCA$Fit } else { + if (!is.null(object$pCCA)) + warning("Conditional ('partial') component ignored") out <- out/sqrt(nrow(out) - 1) } } Modified: pkg/vegan/R/simulate.rda.R =================================================================== --- pkg/vegan/R/simulate.rda.R 2013-02-05 10:58:58 UTC (rev 2411) +++ pkg/vegan/R/simulate.rda.R 2013-02-05 11:38:37 UTC (rev 2412) @@ -30,9 +30,6 @@ ## an array of response matrices ftd <- predict(object, type = "response", rank = rank) - ## pRDA: add partial Fit to the constrained - if (!is.null(object$pCCA)) - ftd <- ftd + object$pCCA$Fit ## Generate an array ans <- array(0, c(dim(ftd), nsim)) for (i in seq_len(nsim)) { @@ -102,9 +99,6 @@ sq.r <- sqrt(object$rowsum) ## Fitted value ftd <- predict(object, type = "working", rank = rank) - ## pCCA: add partial Fit to the constrained - if (!is.null(object$pCCA)) - ftd <- ftd + object$pCCA$Fit ## Residual Xbar need weighting and back-weighting Xbar <- sweep(object$CA$Xbar, 1, sq.r, "*") ## Simulation Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-05 10:58:58 UTC (rev 2411) +++ pkg/vegan/inst/ChangeLog 2013-02-05 11:38:37 UTC (rev 2412) @@ -8,6 +8,12 @@ rda, capscale & adonis, and telling how to do this approximately. Please comment and correct. + * predict.rda, predict.cca: The partial term is handled in + predict.rda(..., type = "response") and in predict.cca(..., type = + "working"). The partial term was earlier handled only in + corresponding simulate.rda(), simulate.cca() functions, but it was + now moved to these more basic functions. + * oecosimu: changed the structure of the oecosimu() result object. It now returns a list of two items: "statistic" is the observed statistic, and "oecosimu" which contains the simulation Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2013-02-05 10:58:58 UTC (rev 2411) +++ pkg/vegan/man/predict.cca.Rd 2013-02-05 11:38:37 UTC (rev 2412) @@ -136,13 +136,14 @@ \code{\link{rda}} and \code{\link{capscale}}. This is often known as calibration, bioindication or environmental reconstruction. Basically, the method is similar to projecting site scores onto biplot - arrows, but it uses regression coefficients. The function can be called - with \code{newdata} so that cross-validation is possible. The + arrows, but it uses regression coefficients. The function can be + called with \code{newdata} so that cross-validation is possible. The \code{newdata} may contain new sites, but species must match in the - original and new data The function - does not work with \sQuote{partial} models with \code{Condition} term, - and it cannot be used with \code{newdata} for \code{\link{capscale}} - results. The results may only be interpretable for continuous variables. + original and new data. The function may not work with + \sQuote{partial} models with \code{Condition} term, or the partial + term may be ignored with a warning. The function cannot be used with + \code{newdata} for \code{\link{capscale}} results. The results may + only be interpretable for continuous variables. Function \code{coef} will give the regression coefficients from centred environmental variables (constraints and conditions) to linear From noreply at r-forge.r-project.org Tue Feb 5 16:20:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 16:20:39 +0100 (CET) Subject: [Vegan-commits] r2413 - in pkg/vegan: R inst Message-ID: <20130205152039.35B87184BAE@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 16:20:38 +0100 (Tue, 05 Feb 2013) New Revision: 2413 Modified: pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/inst/ChangeLog Log: pCCA component handled both in type='resp' and type='work' in cca() and rda() results Modified: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2013-02-05 11:38:37 UTC (rev 2412) +++ pkg/vegan/R/predict.cca.R 2013-02-05 15:20:38 UTC (rev 2413) @@ -34,7 +34,7 @@ rc <- outer(rs, cs) if (type == "response") { if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") + Xbar <- Xbar + object$pCCA$Fit / sqrt(rc) out <- (Xbar + 1) * rc * gtot } else { # type == "working" out <- Xbar * sqrt(rc) Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2013-02-05 11:38:37 UTC (rev 2412) +++ pkg/vegan/R/predict.rda.R 2013-02-05 15:20:38 UTC (rev 2413) @@ -30,6 +30,8 @@ newdata = newdata, rank = take) } if (inherits(object, "capscale")) { + if (!is.null(object$pCCA)) + warning("Conditional ('partial') component ignored") if (take > 0) { out <- u %*% slam/sqrt(nr) if (type == "response") { @@ -54,7 +56,7 @@ out <- out + object$pCCA$Fit } else { if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") + out <- out + object$pCCA$Fit out <- out/sqrt(nrow(out) - 1) } } Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-05 11:38:37 UTC (rev 2412) +++ pkg/vegan/inst/ChangeLog 2013-02-05 15:20:38 UTC (rev 2413) @@ -9,10 +9,11 @@ approximately. Please comment and correct. * predict.rda, predict.cca: The partial term is handled in - predict.rda(..., type = "response") and in predict.cca(..., type = - "working"). The partial term was earlier handled only in - corresponding simulate.rda(), simulate.cca() functions, but it was - now moved to these more basic functions. + predict(..., type = "response") and in predict(..., type = + "working") for cca() and rda() result objects. The partial term + was earlier handled only in corresponding simulate.rda(), + simulate.cca() functions, but it was now moved to these more basic + functions. The partial capscale() results are still unhandled. * oecosimu: changed the structure of the oecosimu() result object. It now returns a list of two items: "statistic" is the From noreply at r-forge.r-project.org Tue Feb 5 18:31:22 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 18:31:22 +0100 (CET) Subject: [Vegan-commits] r2414 - pkg/vegan/R Message-ID: <20130205173122.78D441812ED@r-forge.r-project.org> Author: jarioksa Date: 2013-02-05 18:31:21 +0100 (Tue, 05 Feb 2013) New Revision: 2414 Modified: pkg/vegan/R/predict.rda.R Log: predict.capscale uses data adjustment returned instead of wrongly assuming the sqrt(nrows) Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2013-02-05 15:20:38 UTC (rev 2413) +++ pkg/vegan/R/predict.rda.R 2013-02-05 17:31:21 UTC (rev 2414) @@ -33,7 +33,7 @@ if (!is.null(object$pCCA)) warning("Conditional ('partial') component ignored") if (take > 0) { - out <- u %*% slam/sqrt(nr) + out <- u %*% slam/object$adjust if (type == "response") { out <- dist(out) if (!is.null(object$ac)) From noreply at r-forge.r-project.org Wed Feb 6 09:18:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Feb 2013 09:18:48 +0100 (CET) Subject: [Vegan-commits] r2415 - pkg/vegan/tests Message-ID: <20130206081848.920691813E7@r-forge.r-project.org> Author: jarioksa Date: 2013-02-06 09:18:48 +0100 (Wed, 06 Feb 2013) New Revision: 2415 Modified: pkg/vegan/tests/vegan-tests.R pkg/vegan/tests/vegan-tests.Rout.save Log: add tests for simulate.rda,cca,capscale these depend on and use predict functions and serve as a test for their integrity as well. Modified: pkg/vegan/tests/vegan-tests.R =================================================================== --- pkg/vegan/tests/vegan-tests.R 2013-02-05 17:31:21 UTC (rev 2414) +++ pkg/vegan/tests/vegan-tests.R 2013-02-06 08:18:48 UTC (rev 2415) @@ -164,3 +164,30 @@ pro$t rm(x, xp, pro) ### end protest + +### Check that functions related to predict.rda work correctly for all +### constrained ordination methods. + +### simulate.rda/cca/capscale: based on predict.* and the following +### should get back the data +data(dune, dune.env) +ind <- seq_len(nrow(dune)) +target <- as.matrix(dune) +## rda +mod <- rda(dune ~ Condition(Moisture) + Management + A1, dune.env) +dat <- simulate(mod, indx = ind) +all.equal(dat, target, check.attributes = FALSE) +## cca +mod <- cca(dune ~ Condition(Moisture) + Management + A1, dune.env) +dat <- simulate(mod, indx = ind) +all.equal(dat, target, check.attributes = FALSE) +## capscale: Euclidean distances -- non-Euclidean distances have an +## imaginary component and will not give back the data. +d <- dist(dune) +mod <- capscale(d ~ Condition(Moisture) + Management + A1, dune.env) +dat <- simulate(mod, indx = ind) +all.equal(dat, d, check.attributes = FALSE) +## clean up +rm(ind, target, mod, dat, d) +### end simulate.* + Modified: pkg/vegan/tests/vegan-tests.Rout.save =================================================================== --- pkg/vegan/tests/vegan-tests.Rout.save 2013-02-05 17:31:21 UTC (rev 2414) +++ pkg/vegan/tests/vegan-tests.Rout.save 2013-02-06 08:18:48 UTC (rev 2415) @@ -1,5 +1,5 @@ -R Under development (unstable) (2013-01-24 r61741) -- "Unsuffered Consequences" +R Under development (unstable) (2013-02-05 r61841) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) @@ -547,6 +547,36 @@ > rm(x, xp, pro) > ### end protest > +> ### Check that functions related to predict.rda work correctly for all +> ### constrained ordination methods. +> +> ### simulate.rda/cca/capscale: based on predict.* and the following +> ### should get back the data +> data(dune, dune.env) +> ind <- seq_len(nrow(dune)) +> target <- as.matrix(dune) +> ## rda +> mod <- rda(dune ~ Condition(Moisture) + Management + A1, dune.env) +> dat <- simulate(mod, indx = ind) +> all.equal(dat, target, check.attributes = FALSE) +[1] TRUE +> ## cca +> mod <- cca(dune ~ Condition(Moisture) + Management + A1, dune.env) +> dat <- simulate(mod, indx = ind) +> all.equal(dat, target, check.attributes = FALSE) +[1] TRUE +> ## capscale: Euclidean distances -- non-Euclidean distances have an +> ## imaginary component and will not give back the data. +> d <- dist(dune) +> mod <- capscale(d ~ Condition(Moisture) + Management + A1, dune.env) +> dat <- simulate(mod, indx = ind) +> all.equal(dat, d, check.attributes = FALSE) +[1] TRUE +> ## clean up +> rm(ind, target, mod, dat, d) +> ### end simulate.* +> +> > proc.time() user system elapsed - 2.892 0.036 2.933 + 2.912 0.028 2.947 From noreply at r-forge.r-project.org Wed Feb 6 17:32:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Feb 2013 17:32:12 +0100 (CET) Subject: [Vegan-commits] r2416 - in pkg/vegan: R inst man Message-ID: <20130206163212.E8539183B50@r-forge.r-project.org> Author: jarioksa Date: 2013-02-06 17:32:12 +0100 (Wed, 06 Feb 2013) New Revision: 2416 Modified: pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/R/simulate.rda.R pkg/vegan/inst/ChangeLog pkg/vegan/man/predict.cca.Rd Log: revert r2412-3: there should be no pCCA component in predict type='response' or 'working' Modified: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2013-02-06 08:18:48 UTC (rev 2415) +++ pkg/vegan/R/predict.cca.R 2013-02-06 16:32:12 UTC (rev 2416) @@ -31,16 +31,13 @@ } if (take > 0) Xbar <- u %*% slam %*% t(v) + if (!is.null(object$pCCA)) + warning("Conditional ('partial') component ignored") rc <- outer(rs, cs) - if (type == "response") { - if (!is.null(object$pCCA)) - Xbar <- Xbar + object$pCCA$Fit / sqrt(rc) + if (type == "response") out <- (Xbar + 1) * rc * gtot - } else { # type == "working" + else # type == "working" out <- Xbar * sqrt(rc) - if (!is.null(object$pCCA)) - out <- out + object$pCCA$Fit - } } else if (type == "lc") { if (model == "CA") Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2013-02-06 08:18:48 UTC (rev 2415) +++ pkg/vegan/R/predict.rda.R 2013-02-06 16:32:12 UTC (rev 2416) @@ -25,13 +25,13 @@ w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) if (type %in% c("response", "working")) { + if (!is.null(object$pCCA)) + warning("Conditional ('partial') component ignored") if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", newdata = newdata, rank = take) } if (inherits(object, "capscale")) { - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") if (take > 0) { out <- u %*% slam/object$adjust if (type == "response") { @@ -52,11 +52,7 @@ if (!is.null(scal)) out <- sweep(out, 2, scal, "*") out <- sweep(out, 2, cent, "+") - if (!is.null(object$pCCA)) - out <- out + object$pCCA$Fit } else { - if (!is.null(object$pCCA)) - out <- out + object$pCCA$Fit out <- out/sqrt(nrow(out) - 1) } } Modified: pkg/vegan/R/simulate.rda.R =================================================================== --- pkg/vegan/R/simulate.rda.R 2013-02-06 08:18:48 UTC (rev 2415) +++ pkg/vegan/R/simulate.rda.R 2013-02-06 16:32:12 UTC (rev 2416) @@ -30,6 +30,9 @@ ## an array of response matrices ftd <- predict(object, type = "response", rank = rank) + ## pRDA: add partial Fit to the constrained + if (!is.null(object$pCCA)) + ftd <- ftd + object$pCCA$Fit ## Generate an array ans <- array(0, c(dim(ftd), nsim)) for (i in seq_len(nsim)) { @@ -99,6 +102,9 @@ sq.r <- sqrt(object$rowsum) ## Fitted value ftd <- predict(object, type = "working", rank = rank) + ## pCCA: add partial Fit to the constrained + if (!is.null(object$pCCA)) + ftd <- ftd + object$pCCA$Fit ## Residual Xbar need weighting and back-weighting Xbar <- sweep(object$CA$Xbar, 1, sq.r, "*") ## Simulation Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-06 08:18:48 UTC (rev 2415) +++ pkg/vegan/inst/ChangeLog 2013-02-06 16:32:12 UTC (rev 2416) @@ -8,13 +8,6 @@ rda, capscale & adonis, and telling how to do this approximately. Please comment and correct. - * predict.rda, predict.cca: The partial term is handled in - predict(..., type = "response") and in predict(..., type = - "working") for cca() and rda() result objects. The partial term - was earlier handled only in corresponding simulate.rda(), - simulate.cca() functions, but it was now moved to these more basic - functions. The partial capscale() results are still unhandled. - * oecosimu: changed the structure of the oecosimu() result object. It now returns a list of two items: "statistic" is the observed statistic, and "oecosimu" which contains the simulation Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2013-02-06 08:18:48 UTC (rev 2415) +++ pkg/vegan/man/predict.cca.Rd 2013-02-06 16:32:12 UTC (rev 2416) @@ -136,14 +136,13 @@ \code{\link{rda}} and \code{\link{capscale}}. This is often known as calibration, bioindication or environmental reconstruction. Basically, the method is similar to projecting site scores onto biplot - arrows, but it uses regression coefficients. The function can be - called with \code{newdata} so that cross-validation is possible. The + arrows, but it uses regression coefficients. The function can be called + with \code{newdata} so that cross-validation is possible. The \code{newdata} may contain new sites, but species must match in the - original and new data. The function may not work with - \sQuote{partial} models with \code{Condition} term, or the partial - term may be ignored with a warning. The function cannot be used with - \code{newdata} for \code{\link{capscale}} results. The results may - only be interpretable for continuous variables. + original and new data The function + does not work with \sQuote{partial} models with \code{Condition} term, + and it cannot be used with \code{newdata} for \code{\link{capscale}} + results. The results may only be interpretable for continuous variables. Function \code{coef} will give the regression coefficients from centred environmental variables (constraints and conditions) to linear From noreply at r-forge.r-project.org Wed Feb 6 18:01:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Feb 2013 18:01:02 +0100 (CET) Subject: [Vegan-commits] r2417 - in pkg/vegan: R inst man Message-ID: <20130206170103.11D8718455C@r-forge.r-project.org> Author: jarioksa Date: 2013-02-06 18:01:02 +0100 (Wed, 06 Feb 2013) New Revision: 2417 Modified: pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/inst/ChangeLog pkg/vegan/man/predict.cca.Rd Log: do not warn about ignoring pCCA component, because that is the documented intention Modified: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2013-02-06 16:32:12 UTC (rev 2416) +++ pkg/vegan/R/predict.cca.R 2013-02-06 17:01:02 UTC (rev 2417) @@ -31,8 +31,6 @@ } if (take > 0) Xbar <- u %*% slam %*% t(v) - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") rc <- outer(rs, cs) if (type == "response") out <- (Xbar + 1) * rc * gtot Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2013-02-06 16:32:12 UTC (rev 2416) +++ pkg/vegan/R/predict.rda.R 2013-02-06 17:01:02 UTC (rev 2417) @@ -25,8 +25,6 @@ w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) if (type %in% c("response", "working")) { - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", newdata = newdata, rank = take) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-06 16:32:12 UTC (rev 2416) +++ pkg/vegan/inst/ChangeLog 2013-02-06 17:01:02 UTC (rev 2417) @@ -19,6 +19,15 @@ "statistic" as a separate item. So "statistic" is now one level deeper instead of being the main object. + * predict.cca, predict.rda: In rev2412, 2413 we studied including + partial (pCCA) component in predict(..., type="response") and + predict(..., type="working") models, but then adopted a policy of + never having partial component, but always returning only the + component requested for. Therefore warning messages of ignoring + pCCA component were removed. This log entry was made to emphasize + that there is a policy decision, and an alternative policy can be + tracked in the repository. + * simulate: the simulate functions for "rda" and "cca" return objects with original row and column names. Function capscale() already did so, and simulate.nullmodel() was changed so in vegan Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2013-02-06 16:32:12 UTC (rev 2416) +++ pkg/vegan/man/predict.cca.Rd 2013-02-06 17:01:02 UTC (rev 2417) @@ -38,23 +38,21 @@ \item{object}{A result object from \code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}} or \code{\link{decorana}}. } \item{model}{Show constrained (\code{"CCA"}) or unconstrained - (\code{"CA"}) results. For \code{\link{capscale}} this can also be - \code{"Imaginary"} for imaginary components with negative - eigenvalues. } - + (\code{"CA"}) results. For \code{fitted} method of + \code{\link{capscale}} this can also be \code{"Imaginary"} for + imaginary components with negative eigenvalues. } \item{newdata}{New data frame to be used in prediction or in calibration. Usually this a new community data frame, but with - \code{type = "lc"} and for constrained component with - \code{type = "response"} and \code{type = "working"} it must be a - data frame. The \code{newdata} must have the same number of rows as - the original community data for a \code{\link{cca}} result with + \code{type = "lc"} and for constrained component with \code{type = + "response"} and \code{type = "working"} it must be a data frame of + constraints. The \code{newdata} must have the same number of rows + as the original community data for a \code{\link{cca}} result with \code{type = "response"} or \code{type = "working"}. If the original model had row or column names, then new data must contain rows or columns with the same names (row names for species scores, column names for \code{"wa"} scores and constraint names of \code{"lc"} scores). In other cases the rows or columns must match directly. } - \item{type}{The type of prediction, fitted values or residuals: \code{"response"} scales results so that the same ordination gives the same results, and \code{"working"} gives the values used @@ -71,28 +69,30 @@ \item{rank}{The rank or the number of axes used in the approximation. The default is to use all axes (full rank) of the \code{"model"} or all available four axes in \code{predict.decorana}.} - \item{scaling}{Scaling or predicted scores - with the same meaning as in \code{\link{cca}}, \code{\link{rda}} and - \code{\link{capscale}}.} + \item{scaling}{Scaling or predicted scores with the same meaning as + in \code{\link{cca}}, \code{\link{rda}} and + \code{\link{capscale}}.} \item{\dots}{Other parameters to the functions.} } \details{ + Function \code{fitted} gives the approximation of the original data - matrix or dissimilarities from the ordination result either in the - scale of the response - or as scaled internally by the function. Function \code{residuals} gives - the approximation of the original data from the unconstrained - ordination. With argument \code{type = "response"} the - \code{fitted.cca} and \code{residuals.cca} function + matrix or dissimilarities from the ordination result either in the + scale of the response or as scaled internally by the function. + Function \code{residuals} gives the approximation of the original + data from the unconstrained ordination. With argument \code{type = + "response"} the \code{fitted.cca} and \code{residuals.cca} function both give the same marginal totals as the original data matrix, and - their entries do not add up to the original data. - Functions \code{fitted.capscale} and \code{residuals.capscale} give the - dissimilarities with \code{type = "response"}, but these are not additive, - but the \code{"working"} scores are additive. - All variants of \code{fitted} and \code{residuals} are defined so - that for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal - to constrained ordination, and \code{cca(residuals(mod))} is equal to - unconstrained part of the ordination. + fitted and residuals do not add up to the original data. Functions + \code{fitted.capscale} and \code{residuals.capscale} give the + dissimilarities with \code{type = "response"}, but these are not + additive, but the \code{"working"} scores are additive. All + variants of \code{fitted} and \code{residuals} are defined so that + for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal + to constrained ordination, and \code{cca(residuals(mod))} is equal + to unconstrained part of the ordination. The \code{Condition()} + terms or the partial component is always ignored and will not be + included in \code{predict}ed or \code{fitted} response. Function \code{predict} can find the estimate of the original data matrix or dissimilarities (\code{type = "response"}) with any rank. @@ -105,8 +105,8 @@ explicit \code{scaling} to add those scores to ordination diagrams. With \code{type = "wa"} the function finds the site scores from species scores. In that case, the new data can contain new sites, - but species must match in the original and new data. With \code{type - = "sp"} the function finds species scores from site constraints + but species must match in the original and new data. With \code{type="sp"} + the function finds species scores from site constraints (linear combination scores). In that case the new data can contain new species, but sites must match in the original and new data. With \code{type = "lc"} the function finds the linear combination scores @@ -117,7 +117,7 @@ if constrained component is desired, and community data matrix if residual or unconstrained component is desired. With these types, the function uses \code{newdata} to find new \code{"lc"} (constrained) or - \code{"wa"} scores (unconstrained) and then finding the response or + \code{"wa"} scores (unconstrained) and then finds the response or working data from these new row scores and species scores. The original site (row) and species (column) weights are used for \code{type = "response"} and \code{type = "working"} in correspondence @@ -127,7 +127,7 @@ If a completely new data frame is created, extreme care is needed defining variables similarly as in the original model, in particular with (ordered) factors. If ordination was performed with the formula - interface, the \code{newdata} also can be a data frame or matrix, but + interface, the \code{newdata} can be a data frame or matrix, but extreme care is needed that the columns match in the original and \code{newdata}. From noreply at r-forge.r-project.org Wed Feb 6 18:32:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Feb 2013 18:32:03 +0100 (CET) Subject: [Vegan-commits] r2418 - in pkg/vegan: R inst man Message-ID: <20130206173203.45ED2183B50@r-forge.r-project.org> Author: jarioksa Date: 2013-02-06 18:32:02 +0100 (Wed, 06 Feb 2013) New Revision: 2418 Modified: pkg/vegan/R/fitted.capscale.R pkg/vegan/R/fitted.cca.R pkg/vegan/R/fitted.rda.R pkg/vegan/inst/ChangeLog pkg/vegan/man/predict.cca.Rd Log: fitted.rda,cca,capscale can return the pCCA component Modified: pkg/vegan/R/fitted.capscale.R =================================================================== --- pkg/vegan/R/fitted.capscale.R 2013-02-06 17:01:02 UTC (rev 2417) +++ pkg/vegan/R/fitted.capscale.R 2013-02-06 17:32:02 UTC (rev 2418) @@ -1,5 +1,5 @@ -fitted.capscale <- - function(object, model = c("CCA", "CA", "Imaginary"), +`fitted.capscale` <- + function(object, model = c("CCA", "CA", "pCCA", "Imaginary"), type = c("response", "working"), ...) { model <- match.arg(model) @@ -8,7 +8,8 @@ U <- switch(model, CCA = object$CCA$u.eig, CA = object$CA$u.eig, - Imaginary = object$CA$imaginary.u.eig) + Imaginary = object$CA$imaginary.u.eig, + pCCA = object$pCCA$Fit/object$adjust) ## Distances or working scores U if (type == "response") { U <- dist(U) Modified: pkg/vegan/R/fitted.cca.R =================================================================== --- pkg/vegan/R/fitted.cca.R 2013-02-06 17:01:02 UTC (rev 2417) +++ pkg/vegan/R/fitted.cca.R 2013-02-06 17:32:02 UTC (rev 2418) @@ -1,11 +1,15 @@ -"fitted.cca" <- -function (object, model = c("CCA","CA"), type = c("response", "working"), ...) +`fitted.cca` <- + function (object, model = c("CCA","CA","pCCA"), type = c("response", "working"), + ...) { type <- match.arg(type) model <- match.arg(model) gtot <- object$grand.total rc <- object$rowsum %o% object$colsum - Xbar <- object[[model]]$Xbar + if (model == "pCCA") + Xbar <- object$pCCA$Fit + else + Xbar <- object[[model]]$Xbar if (model == "CCA") Xbar <- qr.fitted(object$CCA$QR, Xbar) if (type == "response") Modified: pkg/vegan/R/fitted.rda.R =================================================================== --- pkg/vegan/R/fitted.rda.R 2013-02-06 17:01:02 UTC (rev 2417) +++ pkg/vegan/R/fitted.rda.R 2013-02-06 17:32:02 UTC (rev 2418) @@ -1,9 +1,12 @@ -"fitted.rda" <- - function (object, model = c("CCA", "CA"), type = c("response", "working"), ...) +`fitted.rda` <- + function (object, model = c("CCA", "CA", "pCCA"), type = c("response", "working"), ...) { type <- match.arg(type) model <- match.arg(model) - Xbar <- object[[model]]$Xbar + if (model == "pCCA") + Xbar <- object$pCCA$Fit + else + Xbar <- object[[model]]$Xbar if (model == "CCA") Xbar <- qr.fitted(object$CCA$QR, Xbar) if (type == "response") { Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-06 17:01:02 UTC (rev 2417) +++ pkg/vegan/inst/ChangeLog 2013-02-06 17:32:02 UTC (rev 2418) @@ -28,6 +28,9 @@ that there is a policy decision, and an alternative policy can be tracked in the repository. + * fitted.[cca,rda,capscale]: can now return partial component with + argument 'model = "pCCA"'. + * simulate: the simulate functions for "rda" and "cca" return objects with original row and column names. Function capscale() already did so, and simulate.nullmodel() was changed so in vegan Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2013-02-06 17:01:02 UTC (rev 2417) +++ pkg/vegan/man/predict.cca.Rd 2013-02-06 17:32:02 UTC (rev 2418) @@ -21,9 +21,9 @@ response data. } \usage{ -\method{fitted}{cca}(object, model = c("CCA", "CA"), +\method{fitted}{cca}(object, model = c("CCA", "CA", "pCCA"), type = c("response", "working"), ...) -\method{fitted}{capscale}(object, model = c("CCA", "CA", "Imaginary"), +\method{fitted}{capscale}(object, model = c("CCA", "CA", "pCCA", "Imaginary"), type = c("response", "working"), ...) \method{residuals}{cca}(object, ...) \method{predict}{cca}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), @@ -37,10 +37,11 @@ \arguments{ \item{object}{A result object from \code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}} or \code{\link{decorana}}. } - \item{model}{Show constrained (\code{"CCA"}) or unconstrained - (\code{"CA"}) results. For \code{fitted} method of - \code{\link{capscale}} this can also be \code{"Imaginary"} for - imaginary components with negative eigenvalues. } + \item{model}{Show constrained (\code{"CCA"}), unconstrained + (\code{"CA"}) or conditioned \dQuote{partial} (\code{"pCCA"}) + results. For \code{fitted} method of \code{\link{capscale}} this + can also be \code{"Imaginary"} for imaginary components with + negative eigenvalues. } \item{newdata}{New data frame to be used in prediction or in calibration. Usually this a new community data frame, but with \code{type = "lc"} and for constrained component with \code{type = From noreply at r-forge.r-project.org Thu Feb 7 17:20:38 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Feb 2013 17:20:38 +0100 (CET) Subject: [Vegan-commits] r2419 - pkg/vegan/man Message-ID: <20130207162038.B0BCD184C2F@r-forge.r-project.org> Author: jarioksa Date: 2013-02-07 17:20:38 +0100 (Thu, 07 Feb 2013) New Revision: 2419 Modified: pkg/vegan/man/predict.cca.Rd Log: tweak docs Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2013-02-06 17:32:02 UTC (rev 2418) +++ pkg/vegan/man/predict.cca.Rd 2013-02-07 16:20:38 UTC (rev 2419) @@ -91,9 +91,7 @@ variants of \code{fitted} and \code{residuals} are defined so that for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal to constrained ordination, and \code{cca(residuals(mod))} is equal - to unconstrained part of the ordination. The \code{Condition()} - terms or the partial component is always ignored and will not be - included in \code{predict}ed or \code{fitted} response. + to unconstrained part of the ordination. Function \code{predict} can find the estimate of the original data matrix or dissimilarities (\code{type = "response"}) with any rank. @@ -140,7 +138,7 @@ arrows, but it uses regression coefficients. The function can be called with \code{newdata} so that cross-validation is possible. The \code{newdata} may contain new sites, but species must match in the - original and new data The function + original and new data. The function does not work with \sQuote{partial} models with \code{Condition} term, and it cannot be used with \code{newdata} for \code{\link{capscale}} results. The results may only be interpretable for continuous variables. From noreply at r-forge.r-project.org Thu Feb 7 18:39:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Feb 2013 18:39:55 +0100 (CET) Subject: [Vegan-commits] r2420 - pkg/vegan/man Message-ID: <20130207173955.43470181132@r-forge.r-project.org> Author: jarioksa Date: 2013-02-07 18:39:54 +0100 (Thu, 07 Feb 2013) New Revision: 2420 Modified: pkg/vegan/man/capscale.Rd pkg/vegan/man/cca.Rd pkg/vegan/man/cca.object.Rd Log: add cross references to cca methods so that people do not request features that already are there Modified: pkg/vegan/man/capscale.Rd =================================================================== --- pkg/vegan/man/capscale.Rd 2013-02-07 16:20:38 UTC (rev 2419) +++ pkg/vegan/man/capscale.Rd 2013-02-07 17:39:54 UTC (rev 2420) @@ -213,7 +213,14 @@ \seealso{\code{\link{rda}}, \code{\link{cca}}, \code{\link{plot.cca}}, \code{\link{anova.cca}}, \code{\link{vegdist}}, - \code{\link{dist}}, \code{\link{cmdscale}}.} + \code{\link{dist}}, \code{\link{cmdscale}}. + + The function returns similar result object as \code{\link{rda}} (see + \code{\link{cca.object}}). This section for \code{\link{rda}} gives a + more complete list of functions that can be used to access and + analyse \code{capscale} results. + +} \examples{ data(varespec) data(varechem) Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2013-02-07 16:20:38 UTC (rev 2419) +++ pkg/vegan/man/cca.Rd 2013-02-07 17:39:54 UTC (rev 2420) @@ -194,25 +194,61 @@ } \seealso{ - There is a special documentation for \code{\link{plot.cca}} and - \code{\link{summary.cca}} functions - with their helper functions (\code{\link{text.cca}}, - \code{\link{points.cca}}, \code{\link{scores.cca}}). - Function \code{\link{anova.cca}} provides an ANOVA like permutation - test for the ``significance'' of constraints. Automatic model building - (dangerous!) is discussed in \code{\link{deviance.cca}}. Diagnostic - tools, prediction and adding new points in ordination are discussed in - \code{\link{goodness.cca}} and \code{\link{predict.cca}}. - Function \code{\link[ade4]{cca}} (library \pkg{ade4}) provide alternative - implementations of CCA (these are internally quite - different). Function \code{\link{capscale}} is a non-Euclidean generalization of - \code{rda}. The result object is described in - \code{\link{cca.object}}. - You can use \code{\link{as.mlm}} to refit ordination result as a - multiple response linear model to find some descriptive statistics. - Design decisions are explained in - \code{\link{vignette}} \file{decision-vegan} which also can be accessed - with \code{\link{vegandocs}}. + + This help page describes two constrained ordination functions, + \code{cca} and \code{rda}. A related method, distance-based + redundancy analysis (dbRDA) is described separately + (\code{\link{capscale}}). All these function return similar objects + (described in \code{\link{cca.object}}). There are numerous support + functions that can used to access the result object. In the list + below, functions of type \code{cca} will handle all ordination + objects, and functions of \code{rda} only handle \code{rda} and + \code{\link{capscale}} results. + + The main plotting functions are \code{\link{plot.cca}} for all + methods, and \code{\link{biplot.rda}} for RDA and dbRDA. However, + generic \pkg{vegan} plotting functions can also handle the results. + The scores can be accessed and scaled with \code{\link{scores.cca}}, + and summarized with \code{\link{summary.cca}}. The eigenvalues can + be accessed with \code{\link{eigenvals.cca}} and the regression + coefficients for constraints with \code{\link{coef.cca}}. The + eigenvalues can be plotted with \code{\link{screeplot.cca}}, and the + (adjusted) \eqn{R^2}{R-squared} can be found with + \code{\link{RsquareAdj.rda}}. The scores can be also calculated for + new data sets with \code{\link{predict.cca}} which allows adding + points to ordinations. The values of constraints can be inferred + from ordination and community composition with + \code{\link{calibrate.cca}}. + + Diagnostic statistics can be found with \code{\link{goodness.cca}}, + \code{\link{inertcomp}}, \code{\link{spenvcor}}, + \code{\link{intersetcor}} and \code{\link{vif.cca}}. Function + \code{\link{as.mlm.cca}} refits the result object as a multiple + \code{\link{lm}} object, and this allows finding influence + statistics (\code{\link{lm.influence}}, \code{\link{cooks.distance}} + etc.). + + Permutation based signficance for the overall model, single + constraining variables or axes can be found with + \code{\link{anova.cca}}. Automatic model building with \R{} + \code{\link{step}} function is possible with + \code{\link{deviance.cca}}, \code{\link{add1.cca}} and + \code{\link{drop1.cca}}. Functions \code{\link{ordistep}} and + \code{\link{ordiR2step}} (for RDA) are special functions for + constrained ordination. Randomized data sets can be generated with + \code{\link{simulate.cca}}. + + Separate methods based on constrained ordination model are principal + response curves (\code{\link{prc}}) and variance partioning between + several components (\code{\link{varpart}}). + + Design decisions are explained in \code{\link{vignette}} + \file{decision-vegan} which also can be accessed with + \code{\link{vegandocs}}. + + Package \pkg{ade4} provides alternative constrained ordination + functions \code{\link[ade4]{cca}} and \code{\link[ade4]{pcaiv}}. + } \examples{ Modified: pkg/vegan/man/cca.object.Rd =================================================================== --- pkg/vegan/man/cca.object.Rd 2013-02-07 16:20:38 UTC (rev 2419) +++ pkg/vegan/man/cca.object.Rd 2013-02-07 17:39:54 UTC (rev 2420) @@ -190,6 +190,10 @@ linear model (\code{\link{lm}}) in order to more easily find some statistics (which in principle could be directly found from the \code{cca.object} as well). + + This section in \code{\link{cca}} gives a more complete list of + methods to handle the constrained ordination result object. + } \references{ Legendre, P. and Legendre, L. (2012) \emph{Numerical Ecology}. 3rd English From noreply at r-forge.r-project.org Thu Feb 7 18:55:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Feb 2013 18:55:39 +0100 (CET) Subject: [Vegan-commits] r2421 - in branches/2.0: R inst inst/doc man Message-ID: <20130207175539.67A9E1847B7@r-forge.r-project.org> Author: jarioksa Date: 2013-02-07 18:55:39 +0100 (Thu, 07 Feb 2013) New Revision: 2421 Modified: branches/2.0/R/fitted.capscale.R branches/2.0/R/fitted.cca.R branches/2.0/R/fitted.rda.R branches/2.0/R/predict.cca.R branches/2.0/R/predict.rda.R branches/2.0/inst/ChangeLog branches/2.0/inst/doc/FAQ-vegan.texi branches/2.0/man/capscale.Rd branches/2.0/man/cca.Rd branches/2.0/man/cca.object.Rd branches/2.0/man/predict.cca.Rd branches/2.0/man/procrustes.Rd Log: selected merges in 2389:2420. Mainly predict.cca/fitted.cca etc and doc upgrades (FAQ, cca x-refs) Modified: branches/2.0/R/fitted.capscale.R =================================================================== --- branches/2.0/R/fitted.capscale.R 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/R/fitted.capscale.R 2013-02-07 17:55:39 UTC (rev 2421) @@ -1,5 +1,5 @@ -fitted.capscale <- - function(object, model = c("CCA", "CA", "Imaginary"), +`fitted.capscale` <- + function(object, model = c("CCA", "CA", "pCCA", "Imaginary"), type = c("response", "working"), ...) { model <- match.arg(model) @@ -8,7 +8,8 @@ U <- switch(model, CCA = object$CCA$u.eig, CA = object$CA$u.eig, - Imaginary = object$CA$imaginary.u.eig) + Imaginary = object$CA$imaginary.u.eig, + pCCA = object$pCCA$Fit/object$adjust) ## Distances or working scores U if (type == "response") { U <- dist(U) Modified: branches/2.0/R/fitted.cca.R =================================================================== --- branches/2.0/R/fitted.cca.R 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/R/fitted.cca.R 2013-02-07 17:55:39 UTC (rev 2421) @@ -1,11 +1,15 @@ -"fitted.cca" <- -function (object, model = c("CCA","CA"), type = c("response", "working"), ...) +`fitted.cca` <- + function (object, model = c("CCA","CA","pCCA"), type = c("response", "working"), + ...) { type <- match.arg(type) model <- match.arg(model) gtot <- object$grand.total rc <- object$rowsum %o% object$colsum - Xbar <- object[[model]]$Xbar + if (model == "pCCA") + Xbar <- object$pCCA$Fit + else + Xbar <- object[[model]]$Xbar if (model == "CCA") Xbar <- qr.fitted(object$CCA$QR, Xbar) if (type == "response") Modified: branches/2.0/R/fitted.rda.R =================================================================== --- branches/2.0/R/fitted.rda.R 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/R/fitted.rda.R 2013-02-07 17:55:39 UTC (rev 2421) @@ -1,9 +1,12 @@ -"fitted.rda" <- - function (object, model = c("CCA", "CA"), type = c("response", "working"), ...) +`fitted.rda` <- + function (object, model = c("CCA", "CA", "pCCA"), type = c("response", "working"), ...) { type <- match.arg(type) model <- match.arg(model) - Xbar <- object[[model]]$Xbar + if (model == "pCCA") + Xbar <- object$pCCA$Fit + else + Xbar <- object[[model]]$Xbar if (model == "CCA") Xbar <- qr.fitted(object$CCA$QR, Xbar) if (type == "response") { Modified: branches/2.0/R/predict.cca.R =================================================================== --- branches/2.0/R/predict.cca.R 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/R/predict.cca.R 2013-02-07 17:55:39 UTC (rev 2421) @@ -31,8 +31,6 @@ } if (take > 0) Xbar <- u %*% slam %*% t(v) - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") rc <- outer(rs, cs) if (type == "response") out <- (Xbar + 1) * rc * gtot Modified: branches/2.0/R/predict.rda.R =================================================================== --- branches/2.0/R/predict.rda.R 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/R/predict.rda.R 2013-02-07 17:55:39 UTC (rev 2421) @@ -25,15 +25,13 @@ w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) if (type %in% c("response", "working")) { - if (!is.null(object$pCCA)) - warning("Conditional ('partial') component ignored") if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", newdata = newdata, rank = take) } if (inherits(object, "capscale")) { if (take > 0) { - out <- u %*% slam/sqrt(nr) + out <- u %*% slam/object$adjust if (type == "response") { out <- dist(out) if (!is.null(object$ac)) Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/inst/ChangeLog 2013-02-07 17:55:39 UTC (rev 2421) @@ -4,15 +4,19 @@ Version 2.0-6 (opened October 8, 2012) - * merge 2404: refer Legendre & Legendre for the vegan rda - algorithm. + * merge 2420: cca cross references. + * merge 2417 thru 2419: predict & fitted upgraded for cca etc. + * merge 2414: adjustment in predict.capscale. + * merge 2408: FAQ on random effects in cca etc. + * merge 2404,2411: refer Legendre & Legendre for the vegan rda + algorithm. * merge 2934 (partial, mc): oecosimu handles nestedfun() returning data.frame. Not merged: checking length of statistic when setting its name. * merge 2932,3: matching names in treedive() and treedist(). - * merge 2388 (partial): faster protest, the part of evaluating the - test statistic hand crafted, because parallelizations caused - conflicts here. + * merge 2388 (partial), 2389, 2390: faster protest, the part of + evaluating the test statistic hand crafted, because + parallelizations caused conflicts here. * merge 2385, 7: protest print, faster sum of squares in procrustes. * merge 2384: new FAQ entries. * merge 2383: remove alias to print.wcmdscale. Modified: branches/2.0/inst/doc/FAQ-vegan.texi =================================================================== --- branches/2.0/inst/doc/FAQ-vegan.texi 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/inst/doc/FAQ-vegan.texi 2013-02-07 17:55:39 UTC (rev 2421) @@ -8,7 +8,7 @@ @setfilename FAQ- at pkg{vegan}.info @settitle @pkg{vegan} FAQ @setchapternewpage on - at set FAQ_YEAR 2012 + at set FAQ_YEAR 2013 @afourpaper @c %**end of header @@ -26,7 +26,7 @@ Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. -Copyright @copyright{} 2008-2012 Jari Oksanen +Copyright @copyright{} 2008-2013 Jari Oksanen @end quotation @end copying @@ -324,7 +324,7 @@ @chapter Ordination @menu -* I have only numeric and positive data but @pkg{vegan} still complaints:: +* I have only numeric and positive data but @pkg{vegan} still complains:: * Can I analyse binary or cover class data?:: * Why dissimilarities in @pkg{vegan} differ from other sources?:: * Why NMDS stress is sometimes 0.1 and sometimes 10?:: @@ -335,6 +335,7 @@ * How the RDA results are scaled?:: * cca fails with ``data.frame expected'' or ``"site.env" missing'':: * Variance explained by ordination axes:: +* Can I have random effects in constrained ordination or in @code{adonis}?:: * Is it possible to have passive points in ordination?:: * Class variables and dummies:: * How are environmental arrows scaled?:: @@ -348,9 +349,9 @@ * Can I zoom into an ordination plot?:: @end menu - at node I have only numeric and positive data but @pkg{vegan} still complaints, Can I analyse binary or cover class data?, Ordination, Ordination + at node I have only numeric and positive data but @pkg{vegan} still complains, Can I analyse binary or cover class data?, Ordination, Ordination @comment node-name, next, previous, up - at section I have only numeric and positive data but @pkg{vegan} still complaints + at section I have only numeric and positive data but @pkg{vegan} still complains You are wrong! Computers are painfully pedantic, and if they find non-numeric or negative data entries, you really have them. Check your @@ -361,7 +362,7 @@ the data). Another common reason is that you had empty cells in your input data, and these were interpreted as missing values. - at node Can I analyse binary or cover class data?, Why dissimilarities in @pkg{vegan} differ from other sources?, I have only numeric and positive data but @pkg{vegan} still complaints, Ordination + at node Can I analyse binary or cover class data?, Why dissimilarities in @pkg{vegan} differ from other sources?, I have only numeric and positive data but @pkg{vegan} still complains, Ordination @section Can I analyse binary or cover class data? Yes. Most @pkg{vegan} methods can handle binary data or cover abundance data. @@ -488,7 +489,7 @@ you do not need package @pkg{ade4}, you can detach it with command @code{detach(package:ade4)}. - at node Variance explained by ordination axes, Is it possible to have passive points in ordination?, cca fails with ``data.frame expected'' or ``"site.env" missing'', Ordination + at node Variance explained by ordination axes, Can I have random effects in constrained ordination or in @code{adonis}?, cca fails with ``data.frame expected'' or ``"site.env" missing'', Ordination @section Variance explained by ordination axes. In general, @pkg{vegan} does not directly give any statistics on the @@ -547,7 +548,46 @@ @end itemize - at node Is it possible to have passive points in ordination?, Class variables and dummies, Variance explained by ordination axes, Ordination + at node Can I have random effects in constrained ordination or in @code{adonis}?, Is it possible to have passive points in ordination?, Variance explained by ordination axes, Ordination + at section Can I have random effects in constrained ordination or in @code{adonis}? + +No. Strictly speaking, this is impossible. However, you can define +models that respond to similar goals as random effects models, although +they strictly speaking use only fixed effects. + +Constrained ordination functions @code{cca}, @code{rda} and + at code{capscale} can have @code{Condition()} terms in their formula. The + at code{Condition()} define partial terms that are fitted before other +constraints and can be used to remove the effects of background +variables, and their contribution to decomposing inertia (variance) is +reported separately. These partial terms are often regarded as similar +to random effects, but they are still fitted in the same way as other +terms and strictly speaking they are fixed terms. + +Function @code{adonis} evaluates terms sequentially. In a model with +right-hand-side @code{~ A + B} the effects of @code{A} are evaluated +first, and the effects of @code{B} after removing the effects of + at code{A}. Sequential tests are also available in @code{anova} function +for constrained ordination results by setting argument @code{by = "term"}. +In this way, the first terms can serve in a similar role as +random effects, although they are fitted in the same way as all other +terms, and strictly speaking they are fixed terms. + +The permutation tests can usually have a @code{strata} argument which +restricts the permutations within levels of a factor given in the +argument. This can be used to restrict the permutations within levels of +factor regarded as a random term. More structured permutations are +available with the @pkg{permute} package. + +A major reason why real random effects models are impossible in most + at pkg{vegan} functions is that their tests are based on the permutation +of the data. The data are given, that is fixed, and therefore +permutation tests are basically tests of fixed terms on fixed data. +Random effect terms would require permutations of data with a random +component instead of the given, fixed data, and such tests are not +available in @pkg{vegan}. + + at node Is it possible to have passive points in ordination?, Class variables and dummies, Can I have random effects in constrained ordination or in @code{adonis}?, Ordination @section Is it possible to have passive points in ordination? @pkg{Vegan} does not have a concept of passive points, or a point that should Modified: branches/2.0/man/capscale.Rd =================================================================== --- branches/2.0/man/capscale.Rd 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/man/capscale.Rd 2013-02-07 17:55:39 UTC (rev 2421) @@ -213,7 +213,14 @@ \seealso{\code{\link{rda}}, \code{\link{cca}}, \code{\link{plot.cca}}, \code{\link{anova.cca}}, \code{\link{vegdist}}, - \code{\link{dist}}, \code{\link{cmdscale}}.} + \code{\link{dist}}, \code{\link{cmdscale}}. + + The function returns similar result object as \code{\link{rda}} (see + \code{\link{cca.object}}). This section for \code{\link{rda}} gives a + more complete list of functions that can be used to access and + analyse \code{capscale} results. + +} \examples{ data(varespec) data(varechem) Modified: branches/2.0/man/cca.Rd =================================================================== --- branches/2.0/man/cca.Rd 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/man/cca.Rd 2013-02-07 17:55:39 UTC (rev 2421) @@ -67,7 +67,7 @@ decomposition (\code{\link{svd}}). Function \code{rda} is similar, but uses ordinary, unweighted linear regression and unweighted SVD. Legendre & Legendre (2012), Table 11.5 (p. 650) give a skeleton of the RDA - algorithm of \pgk{vegan}. The algorithm of CCA is similar, but + algorithm of \pkg{vegan}. The algorithm of CCA is similar, but involves standardization by row and column weights. The functions can be called either with matrix-like entries for community @@ -194,25 +194,61 @@ } \seealso{ - There is a special documentation for \code{\link{plot.cca}} and - \code{\link{summary.cca}} functions - with their helper functions (\code{\link{text.cca}}, - \code{\link{points.cca}}, \code{\link{scores.cca}}). - Function \code{\link{anova.cca}} provides an ANOVA like permutation - test for the ``significance'' of constraints. Automatic model building - (dangerous!) is discussed in \code{\link{deviance.cca}}. Diagnostic - tools, prediction and adding new points in ordination are discussed in - \code{\link{goodness.cca}} and \code{\link{predict.cca}}. - Function \code{\link[ade4]{cca}} (library \pkg{ade4}) provide alternative - implementations of CCA (these are internally quite - different). Function \code{\link{capscale}} is a non-Euclidean generalization of - \code{rda}. The result object is described in - \code{\link{cca.object}}. - You can use \code{\link{as.mlm}} to refit ordination result as a - multiple response linear model to find some descriptive statistics. - Design decisions are explained in - \code{\link{vignette}} \file{decision-vegan} which also can be accessed - with \code{\link{vegandocs}}. + + This help page describes two constrained ordination functions, + \code{cca} and \code{rda}. A related method, distance-based + redundancy analysis (dbRDA) is described separately + (\code{\link{capscale}}). All these function return similar objects + (described in \code{\link{cca.object}}). There are numerous support + functions that can used to access the result object. In the list + below, functions of type \code{cca} will handle all ordination + objects, and functions of \code{rda} only handle \code{rda} and + \code{\link{capscale}} results. + + The main plotting functions are \code{\link{plot.cca}} for all + methods, and \code{\link{biplot.rda}} for RDA and dbRDA. However, + generic \pkg{vegan} plotting functions can also handle the results. + The scores can be accessed and scaled with \code{\link{scores.cca}}, + and summarized with \code{\link{summary.cca}}. The eigenvalues can + be accessed with \code{\link{eigenvals.cca}} and the regression + coefficients for constraints with \code{\link{coef.cca}}. The + eigenvalues can be plotted with \code{\link{screeplot.cca}}, and the + (adjusted) \eqn{R^2}{R-squared} can be found with + \code{\link{RsquareAdj.rda}}. The scores can be also calculated for + new data sets with \code{\link{predict.cca}} which allows adding + points to ordinations. The values of constraints can be inferred + from ordination and community composition with + \code{\link{calibrate.cca}}. + + Diagnostic statistics can be found with \code{\link{goodness.cca}}, + \code{\link{inertcomp}}, \code{\link{spenvcor}}, + \code{\link{intersetcor}} and \code{\link{vif.cca}}. Function + \code{\link{as.mlm.cca}} refits the result object as a multiple + \code{\link{lm}} object, and this allows finding influence + statistics (\code{\link{lm.influence}}, \code{\link{cooks.distance}} + etc.). + + Permutation based signficance for the overall model, single + constraining variables or axes can be found with + \code{\link{anova.cca}}. Automatic model building with \R{} + \code{\link{step}} function is possible with + \code{\link{deviance.cca}}, \code{\link{add1.cca}} and + \code{\link{drop1.cca}}. Functions \code{\link{ordistep}} and + \code{\link{ordiR2step}} (for RDA) are special functions for + constrained ordination. Randomized data sets can be generated with + \code{\link{simulate.cca}}. + + Separate methods based on constrained ordination model are principal + response curves (\code{\link{prc}}) and variance partioning between + several components (\code{\link{varpart}}). + + Design decisions are explained in \code{\link{vignette}} + \file{decision-vegan} which also can be accessed with + \code{\link{vegandocs}}. + + Package \pkg{ade4} provides alternative constrained ordination + functions \code{\link[ade4]{cca}} and \code{\link[ade4]{pcaiv}}. + } \examples{ Modified: branches/2.0/man/cca.object.Rd =================================================================== --- branches/2.0/man/cca.object.Rd 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/man/cca.object.Rd 2013-02-07 17:55:39 UTC (rev 2421) @@ -190,6 +190,10 @@ linear model (\code{\link{lm}}) in order to more easily find some statistics (which in principle could be directly found from the \code{cca.object} as well). + + This section in \code{\link{cca}} gives a more complete list of + methods to handle the constrained ordination result object. + } \references{ Legendre, P. and Legendre, L. (2012) \emph{Numerical Ecology}. 3rd English Modified: branches/2.0/man/predict.cca.Rd =================================================================== --- branches/2.0/man/predict.cca.Rd 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/man/predict.cca.Rd 2013-02-07 17:55:39 UTC (rev 2421) @@ -21,9 +21,9 @@ response data. } \usage{ -\method{fitted}{cca}(object, model = c("CCA", "CA"), +\method{fitted}{cca}(object, model = c("CCA", "CA", "pCCA"), type = c("response", "working"), ...) -\method{fitted}{capscale}(object, model = c("CCA", "CA", "Imaginary"), +\method{fitted}{capscale}(object, model = c("CCA", "CA", "pCCA", "Imaginary"), type = c("response", "working"), ...) \method{residuals}{cca}(object, ...) \method{predict}{cca}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), @@ -37,24 +37,23 @@ \arguments{ \item{object}{A result object from \code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}} or \code{\link{decorana}}. } - \item{model}{Show constrained (\code{"CCA"}) or unconstrained - (\code{"CA"}) results. For \code{\link{capscale}} this can also be - \code{"Imaginary"} for imaginary components with negative - eigenvalues. } - + \item{model}{Show constrained (\code{"CCA"}), unconstrained + (\code{"CA"}) or conditioned \dQuote{partial} (\code{"pCCA"}) + results. For \code{fitted} method of \code{\link{capscale}} this + can also be \code{"Imaginary"} for imaginary components with + negative eigenvalues. } \item{newdata}{New data frame to be used in prediction or in calibration. Usually this a new community data frame, but with - \code{type = "lc"} and for constrained component with - \code{type = "response"} and \code{type = "working"} it must be a - data frame. The \code{newdata} must have the same number of rows as - the original community data for a \code{\link{cca}} result with + \code{type = "lc"} and for constrained component with \code{type = + "response"} and \code{type = "working"} it must be a data frame of + constraints. The \code{newdata} must have the same number of rows + as the original community data for a \code{\link{cca}} result with \code{type = "response"} or \code{type = "working"}. If the original model had row or column names, then new data must contain rows or columns with the same names (row names for species scores, column names for \code{"wa"} scores and constraint names of \code{"lc"} scores). In other cases the rows or columns must match directly. } - \item{type}{The type of prediction, fitted values or residuals: \code{"response"} scales results so that the same ordination gives the same results, and \code{"working"} gives the values used @@ -71,28 +70,28 @@ \item{rank}{The rank or the number of axes used in the approximation. The default is to use all axes (full rank) of the \code{"model"} or all available four axes in \code{predict.decorana}.} - \item{scaling}{Scaling or predicted scores - with the same meaning as in \code{\link{cca}}, \code{\link{rda}} and - \code{\link{capscale}}.} + \item{scaling}{Scaling or predicted scores with the same meaning as + in \code{\link{cca}}, \code{\link{rda}} and + \code{\link{capscale}}.} \item{\dots}{Other parameters to the functions.} } \details{ + Function \code{fitted} gives the approximation of the original data - matrix or dissimilarities from the ordination result either in the - scale of the response - or as scaled internally by the function. Function \code{residuals} gives - the approximation of the original data from the unconstrained - ordination. With argument \code{type = "response"} the - \code{fitted.cca} and \code{residuals.cca} function + matrix or dissimilarities from the ordination result either in the + scale of the response or as scaled internally by the function. + Function \code{residuals} gives the approximation of the original + data from the unconstrained ordination. With argument \code{type = + "response"} the \code{fitted.cca} and \code{residuals.cca} function both give the same marginal totals as the original data matrix, and - their entries do not add up to the original data. - Functions \code{fitted.capscale} and \code{residuals.capscale} give the - dissimilarities with \code{type = "response"}, but these are not additive, - but the \code{"working"} scores are additive. - All variants of \code{fitted} and \code{residuals} are defined so - that for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal - to constrained ordination, and \code{cca(residuals(mod))} is equal to - unconstrained part of the ordination. + fitted and residuals do not add up to the original data. Functions + \code{fitted.capscale} and \code{residuals.capscale} give the + dissimilarities with \code{type = "response"}, but these are not + additive, but the \code{"working"} scores are additive. All + variants of \code{fitted} and \code{residuals} are defined so that + for model \code{mod <- cca(y ~ x)}, \code{cca(fitted(mod))} is equal + to constrained ordination, and \code{cca(residuals(mod))} is equal + to unconstrained part of the ordination. Function \code{predict} can find the estimate of the original data matrix or dissimilarities (\code{type = "response"}) with any rank. @@ -105,8 +104,8 @@ explicit \code{scaling} to add those scores to ordination diagrams. With \code{type = "wa"} the function finds the site scores from species scores. In that case, the new data can contain new sites, - but species must match in the original and new data. With \code{type - = "sp"} the function finds species scores from site constraints + but species must match in the original and new data. With \code{type="sp"} + the function finds species scores from site constraints (linear combination scores). In that case the new data can contain new species, but sites must match in the original and new data. With \code{type = "lc"} the function finds the linear combination scores @@ -117,7 +116,7 @@ if constrained component is desired, and community data matrix if residual or unconstrained component is desired. With these types, the function uses \code{newdata} to find new \code{"lc"} (constrained) or - \code{"wa"} scores (unconstrained) and then finding the response or + \code{"wa"} scores (unconstrained) and then finds the response or working data from these new row scores and species scores. The original site (row) and species (column) weights are used for \code{type = "response"} and \code{type = "working"} in correspondence @@ -127,7 +126,7 @@ If a completely new data frame is created, extreme care is needed defining variables similarly as in the original model, in particular with (ordered) factors. If ordination was performed with the formula - interface, the \code{newdata} also can be a data frame or matrix, but + interface, the \code{newdata} can be a data frame or matrix, but extreme care is needed that the columns match in the original and \code{newdata}. @@ -139,7 +138,7 @@ arrows, but it uses regression coefficients. The function can be called with \code{newdata} so that cross-validation is possible. The \code{newdata} may contain new sites, but species must match in the - original and new data The function + original and new data. The function does not work with \sQuote{partial} models with \code{Condition} term, and it cannot be used with \code{newdata} for \code{\link{capscale}} results. The results may only be interpretable for continuous variables. Modified: branches/2.0/man/procrustes.Rd =================================================================== --- branches/2.0/man/procrustes.Rd 2013-02-07 17:39:54 UTC (rev 2420) +++ branches/2.0/man/procrustes.Rd 2013-02-07 17:55:39 UTC (rev 2421) @@ -135,15 +135,16 @@ function canot be used with \code{newdata} for \code{symmetric} analysis. - Function \code{protest} calls \code{procrustes(..., symmetric = TRUE)} + Function \code{protest} performs symmetric Procrustes analysis repeatedly to estimate the `significance' of the Procrustes statistic. Function \code{protest} uses a correlation-like statistic derived from the symmetric Procrustes sum of squares \eqn{ss} as - \eqn{r =\sqrt{(1-ss)}}, and sometimes called \eqn{m_{12}}. Function - \code{protest} has own \code{print} method, but otherwise uses - \code{procrustes} methods. Thus \code{plot} with a \code{protest} object - yields a ``Procrustean superimposition plot.'' -} + \eqn{r =\sqrt{1-ss}}{r = sqrt(1-ss)}, and also prints the sum of + squares of the symmetric analysis, sometimes called + \eqn{m_{12}^2}{squared m12}. Function \code{protest} has own + \code{print} method, but otherwise uses \code{procrustes} + methods. Thus \code{plot} with a \code{protest} object yields a + ``Procrustean superimposition plot.'' } \value{ Function \code{procrustes} returns an object of class From noreply at r-forge.r-project.org Fri Feb 8 09:08:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Feb 2013 09:08:21 +0100 (CET) Subject: [Vegan-commits] r2422 - branches/2.0/inst www Message-ID: <20130208080821.2DA1B1844E2@r-forge.r-project.org> Author: jarioksa Date: 2013-02-08 09:08:20 +0100 (Fri, 08 Feb 2013) New Revision: 2422 Modified: branches/2.0/inst/NEWS.Rd www/NEWS.html Log: expand NEWS and remove linebreaks within \code{} Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-02-07 17:55:39 UTC (rev 2421) +++ branches/2.0/inst/NEWS.Rd 2013-02-08 08:08:20 UTC (rev 2422) @@ -9,39 +9,41 @@ \itemize{ \item The species scores were scaled correctly in - \code{capscale()} only when Euclidean distances were used. Most - graphics will change and should be redone. The function also - now displays the value of the additive constant when argument - \code{add = TRUE} was used. + \code{capscale()} only when Euclidean distances were used. Usually + \code{capscale()} is used with non-Euclidean distances, and in + these cases the scaling was wrong. Most graphics will change and + should be redone. The change of scaling mainly influences the + spread of species scores with respect to the site scores. \item Function \code{clamtest()} failed to set the minimum - abundance threshold in some cases. The output was wrong when - some of the possible species groups were missing. The problems - were reported by Richard Telford (Bergen, Norway). + abundance threshold in some cases. In addition, the output was + wrong when some of the possible species groups were missing. The + problems were reported by Richard Telford (Bergen, Norway). \item Plotting an object fitted by \code{envfit()} would fail if \code{p.max} was used and there were unused levels for one or more factors. The unused levels could result from deletion of - observations with missing values or simply the result of + observations with missing values or simply as the result of supplying a subset of a larger data set to \code{envfit()}. \item \code{multipart()} printed wrong information about the analysis type (but did analysis correctly). Reported by Valerie Coudrain. - \item \code{oecosimu()} failed if its \code{nestedfun} returned - a data frame. A more fundamental fix will be in \pkg{vegan} - 2.2-0. + \item \code{oecosimu()} failed if its \code{nestedfun} returned a + data frame. A more fundamental fix will be in \pkg{vegan} 2.2-0, + where the structure of the \code{oecosimu()} result will change. \item The plot of two-dimensional \code{procrustes()} solutions often draw original axes in a wrong angle. The problem was reported by Elizabeth Ottesen (MIT). - \item Function \code{treedive()} for functional diversity did - not correctly match the species names in the community data and - classification tree when the tree contained species that did - not occur in the data. Related function \code{treedist()} for - phylogenetic distances did not try to match the names at all. + \item Function \code{treedive()} for functional or phylogenetic + diversity did not correctly match the species names between the + community data and species tree when the tree contained species + that did not occur in the data. Related function + \code{treedist()} for phylogenetic distances did not try to match + the names at all. } @@ -51,6 +53,14 @@ \itemize{ + \item The output of \code{capscale()} displays the value of the + additive constant when argument \code{add = TRUE} was used. + + \item \code{fitted()} functions for \code{cca()}, \code{rda()} and + \code{capscale()} can now return conditioned (partial) component + of the response: Argument \code{model} gained a new alternative + \code{model = "pCCA"}. + \item \code{dispindmorisita()} output gained a new column for Chi-squared based probabilities that the null hypothesis (random distribution) is true. @@ -71,11 +81,11 @@ method. \item \code{ordiR2step()} gained new argument \code{R2scope} - (defaults \code{TRUE}) which can be used to turn off the - criterion of stopping when the adjusted \eqn{R^2}{R2} of the - current model exceeds that of the scope. This option allows - model building when the \code{scope} would be overdetermined - (number of predictors higher than number of observations). + (defaults \code{TRUE}) which can be used to turn off the criterion + of stopping when the adjusted \eqn{R^2}{R-squared} of the current + model exceeds that of the scope. This option allows model + building when the \code{scope} would be overdetermined (number of + predictors higher than number of observations). \code{ordiR2step()} now handles partial redundancy analysis (pRDA). @@ -83,19 +93,21 @@ \item \code{orditorp()} gained argument \code{select} to select the rows or columns of the results to display. - \item \code{protest()} prints the standardized residual - statistic \eqn{m_{12}^2}{squared m12} in addition to the squared - Procrustes correlation \eqn{R^2}{R2}. Both were calculated, but - only the latter was displayed. + \item \code{protest()} prints the standardized residual statistic + \eqn{m_{12}^2}{squared m12} in addition to the squared Procrustes + correlation \eqn{R^2}{R-squared}. Both were calculated, but only + the latter was displayed. Permutation tests are much faster in \code{protest()}. Instead of calling repeatedly \code{procrustes()}, the goodness of fit - statistic is evaluated within then function. + statistic is evaluated within the function. \item \code{wcmdscale()} gained methods for \code{print}, \code{plot} etc. of the results. These methods are only used if - the full \code{wcmdscale} result is returned with, e.g., - argument \code{eig = TRUE}. + the full \code{wcmdscale} result is returned with, e.g., argument + \code{eig = TRUE}. The default is still to return only a matrix of + scores similarly as the standard \R function \code{cmdscale()}, + and in that case the new methods are not used. } @@ -110,9 +122,9 @@ \itemize{ - \item \code{anova(, ...)} failed with \code{by = - "axis"} and \code{by = "term"}. The bug was reported by Dr Sven - Neulinger (Christian Albrecht University, Kiel, Germany). + \item \code{anova(, ...)} failed with + \code{by = "axis"} and \code{by = "term"}. The bug was reported by + Dr Sven Neulinger (Christian Albrecht University, Kiel, Germany). \item \code{radlattice} did not honour argument \code{BIC = TRUE}, but always displayed AIC. @@ -218,8 +230,8 @@ \item \code{envfit} failed with unused factor levels. - \item \code{predict} for \code{cca} results with \code{type = - "response"} or \code{type = "working"} failed with + \item \code{predict} for \code{cca} results with + \code{type = "response"} or \code{type = "working"} failed with \code{newdata} if the number of rows did not match with the original data. Now the \code{newdata} is ignored if it has a wrong number of rows. The number of rows must match because @@ -395,10 +407,10 @@ \item \code{stressplot} and \code{goodness} sometimes failed when \code{metaMDS} was based on \code{isoMDS} (\pkg{MASS} package) because \code{metaMDSdist} did not use the same defaults for - step-across (extended) dissimilarities as \code{metaMDS(..., - engine = "isoMDS")}. The change of defaults can also influence - triggering of step-across in \code{capscale(..., metaMDSdist = - TRUE)}. + step-across (extended) dissimilarities as + \code{metaMDS(..., engine = "isoMDS")}. The change of defaults can + also influence triggering of step-across in + \code{capscale(..., metaMDSdist = TRUE)}. \item \code{adonis} contained a minor bug resulting from incomplete implementation of a speed-up that did not affect the Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-02-07 17:55:39 UTC (rev 2421) +++ www/NEWS.html 2013-02-08 08:08:20 UTC (rev 2422) @@ -19,22 +19,23 @@
    • The species scores were scaled correctly in -capscale() only when Euclidean distances were used. Most -graphics will change and should be redone. The function also -now displays the value of the additive constant when argument -add = TRUE was used. +capscale() only when Euclidean distances were used. Usually +capscale() is used with non-Euclidean distances, and in +these cases the scaling was wrong. Most graphics will change and +should be redone. The change of scaling mainly influences the +spread of species scores with respect to the site scores.

    • Function clamtest() failed to set the minimum -abundance threshold in some cases. The output was wrong when -some of the possible species groups were missing. The problems -were reported by Richard Telford (Bergen, Norway). +abundance threshold in some cases. In addition, the output was +wrong when some of the possible species groups were missing. The +problems were reported by Richard Telford (Bergen, Norway).

    • Plotting an object fitted by envfit() would fail if p.max was used and there were unused levels for one or more factors. The unused levels could result from deletion of -observations with missing values or simply the result of +observations with missing values or simply as the result of supplying a subset of a larger data set to envfit().

    • @@ -43,9 +44,9 @@ Coudrain.

      -
    • oecosimu() failed if its nestedfun returned -a data frame. A more fundamental fix will be in vegan -2.2-0. +

    • oecosimu() failed if its nestedfun returned a +data frame. A more fundamental fix will be in vegan 2.2-0, +where the structure of the oecosimu() result will change.

    • The plot of two-dimensional procrustes() solutions @@ -53,11 +54,12 @@ reported by Elizabeth Ottesen (MIT).

    • -
    • Function treedive() for functional diversity did -not correctly match the species names in the community data and -classification tree when the tree contained species that did -not occur in the data. Related function treedist() for -phylogenetic distances did not try to match the names at all. +

    • Function treedive() for functional or phylogenetic +diversity did not correctly match the species names between the +community data and species tree when the tree contained species +that did not occur in the data. Related function +treedist() for phylogenetic distances did not try to match +the names at all.

    @@ -69,6 +71,16 @@
      +
    • The output of capscale() displays the value of the +additive constant when argument add = TRUE was used. +

      +
    • +
    • fitted() functions for cca(), rda() and +capscale() can now return conditioned (partial) component +of the response: Argument model gained a new alternative +model = "pCCA". +

      +
    • dispindmorisita() output gained a new column for Chi-squared based probabilities that the null hypothesis (random distribution) is true. @@ -93,11 +105,11 @@

    • ordiR2step() gained new argument R2scope -(defaults TRUE) which can be used to turn off the -criterion of stopping when the adjusted R2 of the -current model exceeds that of the scope. This option allows -model building when the scope would be overdetermined -(number of predictors higher than number of observations). +(defaults TRUE) which can be used to turn off the criterion +of stopping when the adjusted R-squared of the current +model exceeds that of the scope. This option allows model +building when the scope would be overdetermined (number of +predictors higher than number of observations).

      ordiR2step() now handles partial redundancy analysis (pRDA). @@ -107,20 +119,22 @@ the rows or columns of the results to display.

    • -
    • protest() prints the standardized residual -statistic squared m12 in addition to the squared -Procrustes correlation R2. Both were calculated, but -only the latter was displayed. +

    • protest() prints the standardized residual statistic +squared m12 in addition to the squared Procrustes +correlation R-squared. Both were calculated, but only +the latter was displayed.

      Permutation tests are much faster in protest(). Instead of calling repeatedly procrustes(), the goodness of fit -statistic is evaluated within then function. +statistic is evaluated within the function.

    • wcmdscale() gained methods for print, plot etc. of the results. These methods are only used if -the full wcmdscale result is returned with, e.g., -argument eig = TRUE. +the full wcmdscale result is returned with, e.g., argument +eig = TRUE. The default is still to return only a matrix of +scores similarly as the standard R function cmdscale(), +and in that case the new methods are not used.

    @@ -137,9 +151,9 @@
      -
    • anova(<cca_object>, ...) failed with by = - "axis" and by = "term". The bug was reported by Dr Sven -Neulinger (Christian Albrecht University, Kiel, Germany). +

    • anova(<cca_object>, ...) failed with +by = "axis" and by = "term". The bug was reported by +Dr Sven Neulinger (Christian Albrecht University, Kiel, Germany).

    • radlattice did not honour argument BIC = TRUE, @@ -267,8 +281,8 @@

    • envfit failed with unused factor levels.

    • -
    • predict for cca results with type = - "response" or type = "working" failed with +

    • predict for cca results with +type = "response" or type = "working" failed with newdata if the number of rows did not match with the original data. Now the newdata is ignored if it has a wrong number of rows. The number of rows must match because @@ -485,10 +499,10 @@

    • stressplot and goodness sometimes failed when metaMDS was based on isoMDS (MASS package) because metaMDSdist did not use the same defaults for -step-across (extended) dissimilarities as metaMDS(..., - engine = "isoMDS"). The change of defaults can also influence -triggering of step-across in capscale(..., metaMDSdist = - TRUE). +step-across (extended) dissimilarities as +metaMDS(..., engine = "isoMDS"). The change of defaults can +also influence triggering of step-across in +capscale(..., metaMDSdist = TRUE).

    • adonis contained a minor bug resulting from From noreply at r-forge.r-project.org Fri Feb 8 09:34:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Feb 2013 09:34:53 +0100 (CET) Subject: [Vegan-commits] r2423 - pkg/vegan/man Message-ID: <20130208083453.C6BF4184CC0@r-forge.r-project.org> Author: jarioksa Date: 2013-02-08 09:34:53 +0100 (Fri, 08 Feb 2013) New Revision: 2423 Modified: pkg/vegan/man/oecosimu.Rd Log: more correct guess for the move to commsim Modified: pkg/vegan/man/oecosimu.Rd =================================================================== --- pkg/vegan/man/oecosimu.Rd 2013-02-08 08:08:20 UTC (rev 2422) +++ pkg/vegan/man/oecosimu.Rd 2013-02-08 08:34:53 UTC (rev 2423) @@ -210,7 +210,7 @@ names in the References (and more in \code{\link{nestedtemp}}). The internal structure of the function was radically changed in - \pkg{vegan 2.0-2} with introduction of \code{\link{commsim}} and + \pkg{vegan 2.2-0} with introduction of \code{\link{commsim}} and \code{\link{nullmodel}} and deprecation of \code{\link{commsimulator}}. However, the results and the basic user interface remain the same (except that \code{method = "r0_old"} must From noreply at r-forge.r-project.org Fri Feb 8 10:39:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Feb 2013 10:39:43 +0100 (CET) Subject: [Vegan-commits] r2424 - pkg/vegan/man Message-ID: <20130208093943.3362D184CC5@r-forge.r-project.org> Author: jarioksa Date: 2013-02-08 10:39:42 +0100 (Fri, 08 Feb 2013) New Revision: 2424 Modified: pkg/vegan/man/decostand.Rd Log: remove duplicate reference accidentally added in r2150 Modified: pkg/vegan/man/decostand.Rd =================================================================== --- pkg/vegan/man/decostand.Rd 2013-02-08 08:34:53 UTC (rev 2423) +++ pkg/vegan/man/decostand.Rd 2013-02-08 09:39:42 UTC (rev 2424) @@ -117,10 +117,6 @@ estimation of population parameters. \emph{Biometrika} \strong{40}, 237--264. - 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. From noreply at r-forge.r-project.org Sat Feb 9 07:22:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Feb 2013 07:22:26 +0100 (CET) Subject: [Vegan-commits] r2425 - pkg/vegan/man Message-ID: <20130209062226.6077A18465C@r-forge.r-project.org> Author: jarioksa Date: 2013-02-09 07:22:25 +0100 (Sat, 09 Feb 2013) New Revision: 2425 Modified: pkg/vegan/man/cca.Rd Log: mention tolerance.cca Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2013-02-08 09:39:42 UTC (rev 2424) +++ pkg/vegan/man/cca.Rd 2013-02-09 06:22:25 UTC (rev 2425) @@ -222,11 +222,11 @@ Diagnostic statistics can be found with \code{\link{goodness.cca}}, \code{\link{inertcomp}}, \code{\link{spenvcor}}, - \code{\link{intersetcor}} and \code{\link{vif.cca}}. Function - \code{\link{as.mlm.cca}} refits the result object as a multiple - \code{\link{lm}} object, and this allows finding influence - statistics (\code{\link{lm.influence}}, \code{\link{cooks.distance}} - etc.). + \code{\link{intersetcor}}, \code{\link{tolerance.cca}}, and + \code{\link{vif.cca}}. Function \code{\link{as.mlm.cca}} refits the + result object as a multiple \code{\link{lm}} object, and this allows + finding influence statistics (\code{\link{lm.influence}}, + \code{\link{cooks.distance}} etc.). Permutation based signficance for the overall model, single constraining variables or axes can be found with From noreply at r-forge.r-project.org Sun Feb 10 07:49:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Feb 2013 07:49:20 +0100 (CET) Subject: [Vegan-commits] r2426 - in branches/2.0: inst man Message-ID: <20130210064920.8A43E18460E@r-forge.r-project.org> Author: jarioksa Date: 2013-02-10 07:49:19 +0100 (Sun, 10 Feb 2013) New Revision: 2426 Modified: branches/2.0/inst/ChangeLog branches/2.0/man/cca.Rd Log: merge r2245: tweak cca.Rd Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-09 06:22:25 UTC (rev 2425) +++ branches/2.0/inst/ChangeLog 2013-02-10 06:49:19 UTC (rev 2426) @@ -4,7 +4,7 @@ Version 2.0-6 (opened October 8, 2012) - * merge 2420: cca cross references. + * merge 2420, 2425: cca cross references. * merge 2417 thru 2419: predict & fitted upgraded for cca etc. * merge 2414: adjustment in predict.capscale. * merge 2408: FAQ on random effects in cca etc. Modified: branches/2.0/man/cca.Rd =================================================================== --- branches/2.0/man/cca.Rd 2013-02-09 06:22:25 UTC (rev 2425) +++ branches/2.0/man/cca.Rd 2013-02-10 06:49:19 UTC (rev 2426) @@ -222,11 +222,11 @@ Diagnostic statistics can be found with \code{\link{goodness.cca}}, \code{\link{inertcomp}}, \code{\link{spenvcor}}, - \code{\link{intersetcor}} and \code{\link{vif.cca}}. Function - \code{\link{as.mlm.cca}} refits the result object as a multiple - \code{\link{lm}} object, and this allows finding influence - statistics (\code{\link{lm.influence}}, \code{\link{cooks.distance}} - etc.). + \code{\link{intersetcor}}, \code{\link{tolerance.cca}}, and + \code{\link{vif.cca}}. Function \code{\link{as.mlm.cca}} refits the + result object as a multiple \code{\link{lm}} object, and this allows + finding influence statistics (\code{\link{lm.influence}}, + \code{\link{cooks.distance}} etc.). Permutation based signficance for the overall model, single constraining variables or axes can be found with From noreply at r-forge.r-project.org Mon Feb 11 08:35:40 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 08:35:40 +0100 (CET) Subject: [Vegan-commits] r2427 - branches/2.0/inst Message-ID: <20130211073540.6EAB5183BB4@r-forge.r-project.org> Author: jarioksa Date: 2013-02-11 08:35:39 +0100 (Mon, 11 Feb 2013) New Revision: 2427 Modified: branches/2.0/inst/ChangeLog branches/2.0/inst/NEWS.Rd Log: tweak NEWS Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-10 06:49:19 UTC (rev 2426) +++ branches/2.0/inst/ChangeLog 2013-02-11 07:35:39 UTC (rev 2427) @@ -2,7 +2,7 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ -Version 2.0-6 (opened October 8, 2012) +Version 2.0-6 (released February 11, 2013) * merge 2420, 2425: cca cross references. * merge 2417 thru 2419: predict & fitted upgraded for cca etc. Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-02-10 06:49:19 UTC (rev 2426) +++ branches/2.0/inst/NEWS.Rd 2013-02-11 07:35:39 UTC (rev 2427) @@ -8,16 +8,16 @@ \itemize{ - \item The species scores were scaled correctly in - \code{capscale()} only when Euclidean distances were used. Usually - \code{capscale()} is used with non-Euclidean distances, and in - these cases the scaling was wrong. Most graphics will change and - should be redone. The change of scaling mainly influences the - spread of species scores with respect to the site scores. + \item The species scores were scaled wrongly in + \code{capscale()}. They were scaled correctly only when Euclidean + distances were used, but usually \code{capscale()} is used with + non-Euclidean distances. Most graphics will change and should be + redone. The change of scaling mainly influences the spread of + species scores with respect to the site scores. \item Function \code{clamtest()} failed to set the minimum abundance threshold in some cases. In addition, the output was - wrong when some of the possible species groups were missing. The + wrong when some of the possible species groups were missing. Both problems were reported by Richard Telford (Bergen, Norway). \item Plotting an object fitted by \code{envfit()} would fail if @@ -27,8 +27,8 @@ supplying a subset of a larger data set to \code{envfit()}. \item \code{multipart()} printed wrong information about the - analysis type (but did analysis correctly). Reported by Valerie - Coudrain. + analysis type (but did the analysis correctly). Reported by + Valerie Coudrain. \item \code{oecosimu()} failed if its \code{nestedfun} returned a data frame. A more fundamental fix will be in \pkg{vegan} 2.2-0, From noreply at r-forge.r-project.org Mon Feb 11 08:36:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 08:36:14 +0100 (CET) Subject: [Vegan-commits] r2428 - www Message-ID: <20130211073614.9E8BE183BB4@r-forge.r-project.org> Author: jarioksa Date: 2013-02-11 08:36:14 +0100 (Mon, 11 Feb 2013) New Revision: 2428 Modified: www/NEWS.html Log: html version of tweaked NEWS Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-02-11 07:35:39 UTC (rev 2427) +++ www/NEWS.html 2013-02-11 07:36:14 UTC (rev 2428) @@ -12,23 +12,21 @@ -

      BUG FIXES

      -
        -
      • The species scores were scaled correctly in -capscale() only when Euclidean distances were used. Usually -capscale() is used with non-Euclidean distances, and in -these cases the scaling was wrong. Most graphics will change and -should be redone. The change of scaling mainly influences the -spread of species scores with respect to the site scores. +

      • The species scores were scaled wrongly in +capscale(). They were scaled correctly only when Euclidean +distances were used, but usually capscale() is used with +non-Euclidean distances. Most graphics will change and should be +redone. The change of scaling mainly influences the spread of +species scores with respect to the site scores.

      • Function clamtest() failed to set the minimum abundance threshold in some cases. In addition, the output was -wrong when some of the possible species groups were missing. The +wrong when some of the possible species groups were missing. Both problems were reported by Richard Telford (Bergen, Norway).

      • @@ -40,8 +38,8 @@

      • multipart() printed wrong information about the -analysis type (but did analysis correctly). Reported by Valerie -Coudrain. +analysis type (but did the analysis correctly). Reported by +Valerie Coudrain.

      • oecosimu() failed if its nestedfun returned a @@ -69,7 +67,6 @@

        NEW FEATURES

        -
        • The output of capscale() displays the value of the additive constant when argument add = TRUE was used. @@ -145,11 +142,9 @@ -

          BUG FIXES

          -
          • anova(<cca_object>, ...) failed with by = "axis" and by = "term". The bug was reported by @@ -167,7 +162,6 @@

            NEW FUNCTIONS

            -
            • Most vegan functions with permutation tests have now a density method that can be used to find empirical @@ -201,7 +195,6 @@

              NEW FEATURES

              -
              • Labels can now be set in the plot of envfit results. The labels must be given in the same order that the @@ -231,7 +224,6 @@

                INSTALLATION AND BUILDING

                -
                • Building of vegan vignettes failed with the latest version of LaTeX (TeXLive 2012). @@ -254,11 +246,9 @@ -

                  BUG FIXES

                  -
                  • adipart assumed constant gamma diversity in simulations when assessing the P-value. This could give @@ -299,7 +289,6 @@

                    NEW FEATURES

                    -
                    • Functions for diversity partitioning (adipart, hiersimu and multipart) have now formula @@ -370,11 +359,9 @@ -

                      NEW FUNCTIONS

                      -
                      • Added new nestedness functions nestedbetasor and nestedbetajac that implement multiple-site dissimilarity @@ -406,7 +393,6 @@

                        BUG FIXES

                        -
                        • betadisper() failed when the groups was a factor with empty levels. @@ -438,7 +424,6 @@

                          NEW FEATURES

                          -
                          • metaMDS argument noshare = 0 is now regarded as a numeric threshold that always triggers extended @@ -480,11 +465,9 @@ -

                            BUG FIXES

                            -
                            • Function capscale failed if constrained component had zero rank. This happened most likely in partial models when @@ -521,7 +504,6 @@

                              NEW FEATURES

                              -
                              • ordiarrows and ordisegments gained argument order.by that gives a variable to sort points within @@ -542,11 +524,9 @@ -

                                NEW FUNCTIONS

                                -
                                • clamtest: new function to classify species as generalists and specialists in two distinct habitats (CLAM test of @@ -582,7 +562,6 @@

                                  BUG FIXES

                                  -
                                  • Function meandist could scramble items and give wrong results, especially when the grouping was @@ -621,7 +600,6 @@

                                    ANALYSES

                                    -
                                    • nesteddisc is slacker and hence faster when trying to optimize the statistic for tied column frequencies. Tracing @@ -637,11 +615,9 @@ -

                                      GENERAL

                                      -
                                      • Peter Minchin joins the vegan team.

                                        @@ -672,7 +648,6 @@

                                        NEW FUNCTIONS

                                        -
                                        • monoMDS: a new function for non-metric multidimensional scaling (NMDS). This function replaces @@ -728,7 +703,6 @@

                                          NEW FEATURES

                                          -
                                          • adonis, anosim, meandist and mrpp warn on negative dissimilarities, and @@ -770,7 +744,6 @@

                                            DEPRECATED AND DEFUNCT

                                            -
                                            • metaMDSrotate was replaced with MDSrotate that can also handle the results of monoMDS. @@ -789,7 +762,6 @@

                                              ANALYSES

                                              -
                                              • treeheight uses much snappier code. The results should be unchanged. From noreply at r-forge.r-project.org Mon Feb 11 08:36:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 08:36:50 +0100 (CET) Subject: [Vegan-commits] r2429 - branches/2.0 Message-ID: <20130211073650.DB5E2183BB4@r-forge.r-project.org> Author: jarioksa Date: 2013-02-11 08:36:50 +0100 (Mon, 11 Feb 2013) New Revision: 2429 Modified: branches/2.0/DESCRIPTION Log: prepare to release 2.0-6 Modified: branches/2.0/DESCRIPTION =================================================================== --- branches/2.0/DESCRIPTION 2013-02-11 07:36:14 UTC (rev 2428) +++ branches/2.0/DESCRIPTION 2013-02-11 07:36:50 UTC (rev 2429) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package Version: 2.0-6 -Date: October 8, 2012 +Date: February 11, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner From noreply at r-forge.r-project.org Mon Feb 11 13:36:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 13:36:04 +0100 (CET) Subject: [Vegan-commits] r2430 - branches pkg/vegan pkg/vegan/inst Message-ID: <20130211123604.778481811FD@r-forge.r-project.org> Author: jarioksa Date: 2013-02-11 13:36:04 +0100 (Mon, 11 Feb 2013) New Revision: 2430 Modified: branches/vegan_releases.txt pkg/vegan/DESCRIPTION pkg/vegan/inst/ChangeLog pkg/vegan/inst/NEWS.Rd Log: wrap up vegan_2.0-6 for CRAN Modified: branches/vegan_releases.txt =================================================================== --- branches/vegan_releases.txt 2013-02-11 07:36:50 UTC (rev 2429) +++ branches/vegan_releases.txt 2013-02-11 12:36:04 UTC (rev 2430) @@ -13,6 +13,7 @@ vegan release: revision (date) directory at vegan-forge +2.0-6: r2429 (Mon, 11 Feb 2013) branches/2.0 2.0-5: r2315 (Mon, 8 Oct 2012) branches/2.0 2.0-4: r2222 (Mon, 18 Jun 2012) branches/2.0 2.0-3: r2119 (Sat, 03 Mar 2012) branches/2.0 Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-02-11 07:36:50 UTC (rev 2429) +++ pkg/vegan/DESCRIPTION 2013-02-11 12:36:04 UTC (rev 2430) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-25 -Date: February 2, 2013 +Version: 2.1-26 +Date: February 11, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-11 07:36:50 UTC (rev 2429) +++ pkg/vegan/inst/ChangeLog 2013-02-11 12:36:04 UTC (rev 2430) @@ -2,8 +2,13 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-25 (opened February 2, 2013) +Version 2.1-26 (opened February 11, 2013) + * New version opened with the release of vegan_2.0-6 on February + 11, 2013. + +Version 2.1-25 (closed February 11, 2013) + * FAQ: new entry on impossibility of using random effects in cca, rda, capscale & adonis, and telling how to do this approximately. Please comment and correct. Modified: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2013-02-11 07:36:50 UTC (rev 2429) +++ pkg/vegan/inst/NEWS.Rd 2013-02-11 12:36:04 UTC (rev 2430) @@ -2,15 +2,129 @@ \title{vegan News} \encoding{UTF-8} +\section{Changes in version 2.0-6}{ + + \subsection{BUG FIXES}{ + + \itemize{ + + \item The species scores were scaled wrongly in + \code{capscale()}. They were scaled correctly only when Euclidean + distances were used, but usually \code{capscale()} is used with + non-Euclidean distances. Most graphics will change and should be + redone. The change of scaling mainly influences the spread of + species scores with respect to the site scores. + + \item Function \code{clamtest()} failed to set the minimum + abundance threshold in some cases. In addition, the output was + wrong when some of the possible species groups were missing. Both + problems were reported by Richard Telford (Bergen, Norway). + + \item Plotting an object fitted by \code{envfit()} would fail if + \code{p.max} was used and there were unused levels for one or + more factors. The unused levels could result from deletion of + observations with missing values or simply as the result of + supplying a subset of a larger data set to \code{envfit()}. + + \item \code{multipart()} printed wrong information about the + analysis type (but did the analysis correctly). Reported by + Valerie Coudrain. + + \item \code{oecosimu()} failed if its \code{nestedfun} returned a + data frame. A more fundamental fix will be in \pkg{vegan} 2.2-0, + where the structure of the \code{oecosimu()} result will change. + + \item The plot of two-dimensional \code{procrustes()} solutions + often draw original axes in a wrong angle. The problem was + reported by Elizabeth Ottesen (MIT). + + \item Function \code{treedive()} for functional or phylogenetic + diversity did not correctly match the species names between the + community data and species tree when the tree contained species + that did not occur in the data. Related function + \code{treedist()} for phylogenetic distances did not try to match + the names at all. + + } + + } % bug fixes + + \subsection{NEW FEATURES}{ + + \itemize{ + + \item The output of \code{capscale()} displays the value of the + additive constant when argument \code{add = TRUE} was used. + + \item \code{fitted()} functions for \code{cca()}, \code{rda()} and + \code{capscale()} can now return conditioned (partial) component + of the response: Argument \code{model} gained a new alternative + \code{model = "pCCA"}. + + \item \code{dispindmorisita()} output gained a new column for + Chi-squared based probabilities that the null hypothesis (random + distribution) is true. + + \item \code{metaMDS()} and \code{monoMDS()} have new default + convergence criteria. Most importantly, scale factor of the + gradient (\code{sfgrmin}) is stricter. The former limit was too + slack with large data sets and iterations stopped early without + getting close to the solution. In addition, \code{scores()} + ignore now requests to dimensions beyond those calculated + instead of failing, and \code{scores()} for \code{metaMDS()} + results do not drop dimensions. + + \item \code{msoplot()} gained \code{legend} argument for + positioning the legend. + + \item Nestedness function \code{nestednodf()} gained a \code{plot} + method. + + \item \code{ordiR2step()} gained new argument \code{R2scope} + (defaults \code{TRUE}) which can be used to turn off the criterion + of stopping when the adjusted \eqn{R^2}{R-squared} of the current + model exceeds that of the scope. This option allows model + building when the \code{scope} would be overdetermined (number of + predictors higher than number of observations). + + \code{ordiR2step()} now handles partial redundancy analysis + (pRDA). + + \item \code{orditorp()} gained argument \code{select} to select + the rows or columns of the results to display. + + \item \code{protest()} prints the standardized residual statistic + \eqn{m_{12}^2}{squared m12} in addition to the squared Procrustes + correlation \eqn{R^2}{R-squared}. Both were calculated, but only + the latter was displayed. + + Permutation tests are much faster in \code{protest()}. Instead + of calling repeatedly \code{procrustes()}, the goodness of fit + statistic is evaluated within the function. + + \item \code{wcmdscale()} gained methods for \code{print}, + \code{plot} etc. of the results. These methods are only used if + the full \code{wcmdscale} result is returned with, e.g., argument + \code{eig = TRUE}. The default is still to return only a matrix of + scores similarly as the standard \R function \code{cmdscale()}, + and in that case the new methods are not used. + + } + + } % new features + + +} % end 2.0-6 + \section{Changes in version 2.0-5}{ \subsection{BUG FIXES}{ \itemize{ - \item \code{anova(, ...)} failed with \code{by = - "axis"} and \code{by = "term"}. The bug was reported by Dr Sven - Neulinger (Christian Albrecht University, Kiel, Germany). + \item \code{anova(, ...)} failed with + \code{by = "axis"} and \code{by = "term"}. The bug was reported by + Dr Sven Neulinger (Christian Albrecht University, Kiel, Germany). \item \code{radlattice} did not honour argument \code{BIC = TRUE}, but always displayed AIC. @@ -116,8 +230,8 @@ \item \code{envfit} failed with unused factor levels. - \item \code{predict} for \code{cca} results with \code{type = - "response"} or \code{type = "working"} failed with + \item \code{predict} for \code{cca} results with + \code{type = "response"} or \code{type = "working"} failed with \code{newdata} if the number of rows did not match with the original data. Now the \code{newdata} is ignored if it has a wrong number of rows. The number of rows must match because @@ -293,10 +407,10 @@ \item \code{stressplot} and \code{goodness} sometimes failed when \code{metaMDS} was based on \code{isoMDS} (\pkg{MASS} package) because \code{metaMDSdist} did not use the same defaults for - step-across (extended) dissimilarities as \code{metaMDS(..., - engine = "isoMDS")}. The change of defaults can also influence - triggering of step-across in \code{capscale(..., metaMDSdist = - TRUE)}. + step-across (extended) dissimilarities as + \code{metaMDS(..., engine = "isoMDS")}. The change of defaults can + also influence triggering of step-across in + \code{capscale(..., metaMDSdist = TRUE)}. \item \code{adonis} contained a minor bug resulting from incomplete implementation of a speed-up that did not affect the From noreply at r-forge.r-project.org Mon Feb 11 19:34:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 19:34:53 +0100 (CET) Subject: [Vegan-commits] r2431 - in pkg/vegan: . R inst man tests/Examples Message-ID: <20130211183453.EE0FA1844EC@r-forge.r-project.org> Author: jarioksa Date: 2013-02-11 19:34:53 +0100 (Mon, 11 Feb 2013) New Revision: 2431 Added: pkg/vegan/R/tabasco.R Modified: pkg/vegan/NAMESPACE pkg/vegan/inst/ChangeLog pkg/vegan/man/vegemite.Rd pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: add tabasco: a sister to vegemite to display compact tables, but hotter Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2013-02-11 12:36:04 UTC (rev 2430) +++ pkg/vegan/NAMESPACE 2013-02-11 18:34:53 UTC (rev 2431) @@ -25,7 +25,7 @@ rda, renyiaccum, renyi, rrarefy, scores, scoverage, showvarparts, simper, spandepth, spantree, specaccum, specnumber, specpool2vect, specpool, spenvcor, -stepacross, stressplot, swan, taxa2dist, taxondive, tolerance, +stepacross, stressplot, swan, tabasco, taxa2dist, taxondive, tolerance, treedist, treedive, treeheight, tsallisaccum, tsallis, varpart, vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores, wcmdscale, wisconsin) Added: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R (rev 0) +++ pkg/vegan/R/tabasco.R 2013-02-11 18:34:53 UTC (rev 2431) @@ -0,0 +1,81 @@ +### The function displays (ordered) heatmaps of community data. It +### copies vegemite() for handling 'use', 'sp.ind', 'site.ind' and +### 'select', but then switches to heatmap() to display the +### data. Unlike heatmap(), it does not insist on showing dendrograms, +### but only uses these for sites, and only if given as 'use'. + +`tabasco` <- + function (x, use, sp.ind = NULL, site.ind = NULL, + select, ...) +{ + Rowv <- Colv <- NA + if (!missing(use)) { + if (!is.list(use) && is.vector(use)) { + if (is.null(site.ind)) + site.ind <- order(use) + if (is.null(sp.ind)) + sp.ind <- order(wascores(use, x)) + } + else if (inherits(use, "hclust")) { + if (is.null(site.ind)) + site.ind <- use$order + if (is.null(sp.ind)) + sp.ind <- order(wascores(order(site.ind), x)) + Colv <- as.dendrogram(use) + } + else if (inherits(use, "dendrogram")) { + if (is.null(site.ind)) { + site.ind <- 1:nrow(x) + names(site.ind) <- rownames(x) + site.ind <- site.ind[labels(use)] + } + if (is.null(sp.ind)) + sp.ind <- order(wascores(order(site.ind), x)) + Colv <- use + } + else if (is.list(use)) { + tmp <- scores(use, choices = 1, display = "sites") + if (is.null(site.ind)) + site.ind <- order(tmp) + if (is.null(sp.ind)) + sp.ind <- try(order(scores(use, choices = 1, + display = "species"))) + if (inherits(sp.ind, "try-error")) + sp.ind <- order(wascores(tmp, x)) + } + else if (is.matrix(use)) { + tmp <- scores(use, choices = 1, display = "sites") + if (is.null(site.ind)) + site.ind <- order(tmp) + if (is.null(sp.ind)) + sp.ind <- order(wascores(tmp, x)) + } + } + if (!is.null(sp.ind) && is.logical(sp.ind)) + sp.ind <- (1:ncol(x))[sp.ind] + if (!is.null(site.ind) && is.logical(site.ind)) + site.ind <- (1:nrow(x))[site.ind] + if (is.null(sp.ind)) + sp.ind <- 1:ncol(x) + if (is.null(site.ind)) + site.ind <- 1:nrow(x) + if (!missing(select)) { + if (!is.logical(select)) + select <- sort(site.ind) %in% select + stake <- colSums(x[select, , drop = FALSE]) > 0 + site.ind <- site.ind[select[site.ind]] + site.ind <- site.ind[!is.na(site.ind)] + } + else { + stake <- colSums(x[site.ind, ]) > 0 + } + sp.ind <- sp.ind[stake[sp.ind]] + x <- x[site.ind, sp.ind] + x <- as.matrix(x) + x <- t(x) + sp.nam <- rownames(x) + sp.len <- max(nchar(sp.nam)) + heatmap((max(x) - x), Rowv, Colv, scale = "none", ...) + out <- list(sites = site.ind, species = sp.ind) + invisible(out) +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-11 12:36:04 UTC (rev 2430) +++ pkg/vegan/inst/ChangeLog 2013-02-11 18:34:53 UTC (rev 2431) @@ -6,6 +6,9 @@ * New version opened with the release of vegan_2.0-6 on February 11, 2013. + + * tabasco: a sister function of vegemite() to display a compact + community table using heatmap(). Version 2.1-25 (closed February 11, 2013) Modified: pkg/vegan/man/vegemite.Rd =================================================================== --- pkg/vegan/man/vegemite.Rd 2013-02-11 12:36:04 UTC (rev 2430) +++ pkg/vegan/man/vegemite.Rd 2013-02-11 18:34:53 UTC (rev 2431) @@ -1,16 +1,21 @@ \name{vegemite} \alias{vegemite} +\alias{tabasco} \alias{coverscale} -\title{Prints a Compact, Ordered Vegetation Table } +\title{Display Compact Ordered Community Tables } \description{ - The function prints a compact vegetation table, where species are - rows, and each site takes only one column without spaces. The - vegetation table can be ordered by explicit indexing, by environmental - variables or results from an ordination or cluster analysis. + The functions display compact community tables. Function + \code{vegemite} prints text tables where species are rows, and each + site takes only one column without spaces. Function \code{tabasco} + provides interface for \code{\link{heatmap}} for a colour map of + the data. The community table can be ordered by explicit indexing, + by environmental variables or results from an ordination or cluster + analysis. } \usage{ vegemite(x, use, scale, sp.ind, site.ind, zero=".", select ,...) +tabasco(x, use, sp.ind = NULL, site.ind = NULL, select, ...) coverscale(x, scale=c("Braun.Blanquet", "Domin", "Hult", "Hill", "fix","log"), maxabund) } @@ -32,19 +37,28 @@ \item{maxabund}{Maximum abundance used with \code{scale = "log"}. Data maximum in the \code{select}ed subset will be used if this is missing.} - \item{...}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}).} + \item{...}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}) in + \code{vegemite} and to \code{\link{heatmap}} in \code{tabasco}.} } \details{ - The function prints a traditional vegetation table. + The function \code{vegemite} prints a traditional community table. Unlike in ordinary data matrices, species are used as rows and sites as columns. The table is printed in compact form: only one character can be used for abundance, and there are no spaces between columns. Species with no occurrences are dropped from the table. + Function \code{tabasco} produces a similar table as \code{vegemite} + using \code{\link{heatmap}}, where abundances are coded by heatmap + colours. + The parameter \code{use} can be a vector or an object from \code{\link{hclust}}, a \code{\link{dendrogram}} or any ordination result recognized by \code{\link{scores}} (all ordination methods in - \pkg{vegan} and some of those not in \pkg{vegan}). + \pkg{vegan} and some of those not in \pkg{vegan}). The + \code{\link{hclust}} an \code{\link{dendrogram}} must be for + sites. The dendrogram is displayed in above the sites in + \code{tabasco}. + If \code{use} is a vector, it is used for ordering sites. If \code{use} is an object from ordination, both sites and species are arranged by the first axis. @@ -106,15 +120,19 @@ } \author{Jari Oksanen} -\seealso{\code{\link{cut}} and \code{\link{approx}} for making your own - `cover scales', \code{\link{wascores}} for weighted averages. +\seealso{\code{\link{cut}} and \code{\link{approx}} for making your + own \sQuote{cover scales} for \code{vegemite}. Function + \code{tabasco} is based on \code{\link{heatmap}}. Both functions + order species with weighted averages using \code{\link{wascores}}. } -\note{ This function was called \code{vegetab} in older versions of - \code{vegan}. The new name was chosen because the output is so - compact (and to avoid confusion with the \code{vegtab} function in the - \pkg{labdsv} package). - } +\note{ + + The name \code{vegemite} was chosen because the output is so + compact, and the \code{tabasco} because it is just as compact, but + uses heat colours. + +} \examples{ data(varespec) ## Print only more common species @@ -129,6 +147,15 @@ sel <- vegemite(varespec, use=dca, select = cl == 3, scale="Br") # Re-create previous vegemite(varespec, sp=sel$sp, site=sel$site, scale="Hult") + +## Abundance values have such a wide range that they must be rescaled +## or all abundances will not be shown in tabasco +tabasco(decostand(varespec, "log"), clus) +## reorder dendrogram by the first DCA axis +clus <- as.dendrogram(clus) +clus <- reorder(clus, scores(dca, choices=1, display="sites")) +tabasco(decostand(varespec, "log"), clus) + } \keyword{ print } \keyword{ manip } Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-11 12:36:04 UTC (rev 2430) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-11 18:34:53 UTC (rev 2431) @@ -1,8 +1,8 @@ -R Under development (unstable) (2013-01-21 r61719) -- "Unsuffered Consequences" -Copyright (C) 2013 The R Foundation for Statistical Computing +R version 2.15.2 (2012-10-26) -- "Trick or Treat" +Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 -Platform: x86_64-unknown-linux-gnu (64-bit) +Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -23,7 +23,7 @@ > options(warn = 1) > library('vegan') Loading required package: permute -This is vegan 2.1-23 +This is vegan 2.1-26 > > assign(".oldSearch", search(), pos = 'CheckExEnv') > cleanEx() @@ -161,7 +161,7 @@ Formula: y ~ poly(x1, 1) + poly(x2, 1) - + Total model degrees of freedom 3 GCV score: 0.04278782 @@ -227,7 +227,7 @@ hump at max 7.8160 9.0487 0.01191 * Combined 0.03338 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > plot(mod) > par(op) > ## Confidence Limits @@ -305,14 +305,14 @@ > marr <- nls(S ~ SSarrhenius(sipoo.area, k, z)) > marr Nonlinear regression model - model: S ~ SSarrhenius(sipoo.area, k, z) - data: parent.frame() + model: S ~ SSarrhenius(sipoo.area, k, z) + data: parent.frame() k z 3.4062 0.4364 residual sum-of-squares: 78.1 Number of iterations to convergence: 5 -Achieved convergence tolerance: 1.056e-06 +Achieved convergence tolerance: 1.056e-06 > ## confidence limits from profile likelihood > confint(marr) Waiting for profiling to be done... @@ -348,14 +348,14 @@ > mlom <- nls(S ~ SSlomolino(sipoo.area, Smax, A50, Hill)) > mlom Nonlinear regression model - model: S ~ SSlomolino(sipoo.area, Smax, A50, Hill) - data: parent.frame() + model: S ~ SSlomolino(sipoo.area, Smax, A50, Hill) + data: parent.frame() Smax A50 Hill 53.493 94.697 2.018 residual sum-of-squares: 55.37 Number of iterations to convergence: 6 -Achieved convergence tolerance: 9.715e-07 +Achieved convergence tolerance: 9.715e-07 > lines(xtmp, predict(mlom, newdata=data.frame(sipoo.area=xtmp)), + lwd=2, col = 4) > ## One canned model of standard R: @@ -402,7 +402,7 @@ + Manure 4 88.832 1.5251 199 0.025 * + Use 2 89.134 1.1431 99 0.250 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: AIC=86.61 dune ~ Moisture @@ -415,7 +415,7 @@ + Manure 4 87.342 1.3143 199 0.090 . - Moisture 3 87.657 2.2536 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Call: cca(formula = dune ~ Moisture, data = dune.env) Inertia Proportion Rank @@ -453,7 +453,7 @@ Use 2 91.032 1.1741 99 0.180 Manure 4 89.232 1.9539 199 0.010 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > m0 <- update(m0, . ~ . + Management) > add1(m0, scope=formula(mbig), test="perm") Df AIC F N.Perm Pr(>F) @@ -463,7 +463,7 @@ Use 2 88.284 1.0510 99 0.430 Manure 3 87.517 1.3902 199 0.130 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > m0 <- update(m0, . ~ . + Moisture) > ## -- included variables still significant? > drop1(m0, test="perm") @@ -472,7 +472,7 @@ Management 3 87.707 2.1769 199 0.010 ** Moisture 3 87.082 1.9764 199 0.015 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > add1(m0, scope=formula(mbig), test="perm") Df AIC F N.Perm Pr(>F) 85.567 @@ -536,7 +536,7 @@ gamma 35.000 0.00 35.000 35.000 35.000 35.000 1.00 beta.1 19.886 38.43 12.656 12.392 12.700 12.968 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > adipart(mite ~ ., levsm, index="richness", nsimul=19) adipart object @@ -556,7 +556,7 @@ beta.2 3.250 13.1373 0.18421 0.00000 0.00000 0.6375 0.05 * beta.3 2.000 0.0000 0.00000 0.00000 0.00000 0.0000 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Hierarchical null model testing > ## diversity analysis (similar to adipart) > hiersimu(mite, FUN=diversity, relative=TRUE, nsimul=19) @@ -572,7 +572,7 @@ level_1 0.76064 -71.195 0.93904 0.93487 0.93856 0.9444 0.05 * leve_2 1.00000 0.000 1.00000 1.00000 1.00000 1.0000 1.00 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > hiersimu(mite ~., levsm, FUN=diversity, relative=TRUE, nsimul=19) hiersimu object @@ -589,7 +589,7 @@ l3 0.92791 -417.338 0.99940 0.99904 0.99943 0.9996 0.05 * l4 1.00000 0.000 1.00000 1.00000 1.00000 1.0000 1.00 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Hierarchical testing with the Morisita index > morfun <- function(x) dispindmorisita(x)$imst > hiersimu(mite ~., levsm, morfun, drop.highest=TRUE, nsimul=19) @@ -607,7 +607,7 @@ l2 0.60234 14.3854 0.153047 0.096700 0.150434 0.1969 0.05 * l3 0.67509 20.3162 -0.182473 -0.234793 -0.195937 -0.0988 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -642,7 +642,7 @@ Residuals 12 1.8004 0.15003 0.41878 Total 19 4.2990 1.00000 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > ### Example of use with strata, for nested (e.g., block) designs. @@ -668,10 +668,6 @@ > library(lattice) > dotplot(total ~ NO3, dat, jitter.x=TRUE, groups=field, + type=c('p','a'), xlab="NO3", auto.key=list(columns=3, lines=TRUE) ) -Warning in FUN(X[[8L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[9L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[8L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[9L]], ...) : 'x' is NULL so the result will be NULL > > Y <- data.frame(Agropyron, Schizachyrium) > mod <- metaMDS(Y) @@ -679,7 +675,7 @@ Run 1 stress 0.1560544 Run 2 stress 0.08556586 ... New best solution -... procrustes: rmse 1.094382e-06 max resid 1.88838e-06 +... procrustes: rmse 1.094365e-06 max resid 1.88838e-06 *** Solution reached > plot(mod) > ### Hulls show treatment @@ -701,7 +697,7 @@ Residuals 10 0.138667 0.013867 0.71286 Total 11 0.194524 1.00000 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > ### Incorrect (no strata) > adonis(Y ~ NO3, data=dat, perm=999) @@ -716,7 +712,7 @@ Residuals 10 0.138667 0.013867 0.71286 Total 11 0.194524 1.00000 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -800,7 +796,7 @@ Model 3 0.6441 2.9840 199 0.005 ** Residual 20 1.4391 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Test for axes > anova(vare.cca, by="axis", perm.max=500) Model: cca(formula = varespec ~ Al + P + K, data = varechem) @@ -810,7 +806,7 @@ CCA3 1 0.1126 1.5651 399 0.100 . Residual 20 1.4391 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Sequential test for terms > anova(vare.cca, by="terms", permu=200) Permutation test for cca under reduced model @@ -823,7 +819,7 @@ K 1 0.1561 2.1688 199 0.030 * Residual 20 1.4391 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Marginal or Type III effects > anova(vare.cca, by="margin") Permutation test for cca under reduced model @@ -836,7 +832,7 @@ K 1 0.1561 2.1688 599 0.02833 * Residual 20 1.4391 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Marginal test knows 'scope' > anova(vare.cca, by = "m", scope="P") Permutation test for cca under reduced model @@ -847,7 +843,7 @@ P 1 0.1681 2.3362 199 0.015 * Residual 20 1.4391 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -1141,7 +1137,7 @@ Groups 1 0.07931 0.079306 4.6156 0.04295 * Residuals 22 0.37801 0.017182 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > ## Permutation test for F > permutest(mod, pairwise = TRUE) @@ -1162,7 +1158,7 @@ Groups 1 0.07931 0.079306 4.6156 999 0.05 * Residuals 22 0.37801 0.017182 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Pairwise comparisons: (Observed p-value below diagonal, permuted p-value above diagonal) @@ -1290,7 +1286,7 @@ Groups 1 0.033468 0.033468 3.1749 100 0.06931 . Residuals 18 0.189749 0.010542 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > anova(mod3) Analysis of Variance Table @@ -1299,7 +1295,7 @@ Groups 1 0.033468 0.033468 3.1749 0.09166 . Residuals 18 0.189749 0.010542 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > plot(mod3) > boxplot(mod3) > plot(TukeyHSD(mod3)) @@ -1563,7 +1559,7 @@ Model 3 0.99717 2.2324 199 0.005 ** Residual 19 2.82904 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Avoid negative eigenvalues with additive constant > capscale(varespec ~ N + P + K + Condition(Al), varechem, + dist="bray", add =TRUE) @@ -2286,7 +2282,7 @@ Pearson's Chi-squared test -data: dune +data: dune X-squared = 1448.956, df = 551, p-value < 2.2e-16 > deviance(cca(dune)) @@ -2641,7 +2637,7 @@ Humdepth 0.932909 -0.360112 0.5200 0.002 ** pH -0.648094 0.761560 0.2308 0.060 . --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 P values based on 999 permutations. @@ -3503,7 +3499,7 @@ D.cl.12 8.526186 66.000000 NA NA NA D.cl.13 9.254550 32.000000 NA NA NA --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > # or: print(mite.correlog) > # or: print.mantel.correlog(mite.correlog) > plot(mite.correlog) @@ -3542,7 +3538,7 @@ D.cl.12 8.526186 66.000000 -0.054242 0.04 0.24 D.cl.13 9.254550 32.000000 -0.066677 0.02 0.26 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > plot(mite.correlog2) > > # NOTE: 'nperm' argument usually needs to be larger than 49. @@ -3633,7 +3629,7 @@ Run 0 stress 0.1067169 Run 1 stress 0.1067169 ... New best solution -... procrustes: rmse 1.234853e-05 max resid 2.993582e-05 +... procrustes: rmse 1.234853e-05 max resid 2.993581e-05 *** Solution reached > sol @@ -3837,7 +3833,7 @@ > plot(dune.ord <- metaMDS(dune), type="text", display="sites" ) Run 0 stress 0.1192678 Run 1 stress 0.119268 -... procrustes: rmse 8.185687e-05 max resid 0.0001982896 +... procrustes: rmse 8.18569e-05 max resid 0.0001982896 *** Solution reached > ordihull(dune.ord, dune.env$Management) > @@ -4039,7 +4035,7 @@ beta.2 1.0710 30.431 1.00339 0.99912 1.00340 1.0059 0.05 * beta.3 1.1794 460.550 1.00148 1.00083 1.00148 1.0021 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > multipart(mite ~ ., levsm, index="renyi", scales=1, nsimul=19) multipart object @@ -4059,7 +4055,7 @@ beta.2 1.0710 33.423 1.0041 1.0015 1.0035 1.0078 0.05 * beta.3 1.1794 419.166 1.0015 1.0008 1.0016 1.0023 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > multipart(mite ~ ., levsm, index="renyi", scales=1, nsimul=19, relative=TRUE) multipart object @@ -4079,7 +4075,7 @@ beta.2 0.535514 35.966 0.501994 0.500294 0.502062 0.5035 0.05 * beta.3 0.589695 404.814 0.500885 0.500583 0.500848 0.5013 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > multipart(mite ~ ., levsm, index="renyi", scales=1, nsimul=19, global=TRUE) multipart object @@ -4099,7 +4095,7 @@ beta.2 1.2603 102.695 1.00483 0.99985 1.00484 1.0077 0.05 * beta.3 1.1794 378.335 1.00154 1.00104 1.00144 1.0025 0.05 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -4161,7 +4157,7 @@ statistic z mean 2.5% 50% 97.5% Pr(sim.) C.score 2.2588 -28.92 9.2234 8.6935 9.2384 9.6053 0.01 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -4289,7 +4285,7 @@ statistic z mean 2.5% 50% 97.5% Pr(sim.) statistic 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 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## sequential model, one-sided test, a vector statistic > out <- oecosimu(sipoo, decorana, "swap", burnin=100, thin=10, + statistic="evals", alt = "less") @@ -4322,7 +4318,7 @@ DCA3 0.166788 0.5209 0.155941 0.105269 0.155716 0.1859 0.30 DCA4 0.087226 -1.9822 0.130151 0.066742 0.126492 0.1649 0.99 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Inspect the swap sequence as a time series object > plot(as.ts(out)) > lag.plot(as.ts(out)) @@ -4348,7 +4344,7 @@ statistic z mean 2.5% 50% 97.5% Pr(sim.) statistic 0.64565 14.66 0.46734 0.44069 0.46760 0.4903 0.01 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > ## Define your own null model as a 'commsim' function: shuffle cells > ## in each row @@ -4372,7 +4368,7 @@ statistic z mean 2.5% 50% 97.5% Pr(sim.) statistic 0.64565 3.1832 0.63514 0.63016 0.63441 0.6419 0.03 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > > @@ -4650,14 +4646,14 @@ + A1 1 89.591 1.9217 199 0.035 * + Use 2 91.032 1.1741 99 0.310 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: dune ~ Management Df AIC F N.Perm Pr(>F) - Management 3 89.62 2.84 99 0.01 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Df AIC F N.Perm Pr(>F) + Moisture 3 85.567 1.9764 199 0.005 ** @@ -4665,7 +4661,7 @@ + A1 1 87.424 1.2965 99 0.240 + Use 2 88.284 1.0510 99 0.480 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: dune ~ Management + Moisture @@ -4673,7 +4669,7 @@ - Moisture 3 87.082 1.9764 99 0.02 * - Management 3 87.707 2.1769 99 0.01 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Df AIC F N.Perm Pr(>F) + Manure 3 85.762 1.1225 99 0.26 @@ -4726,7 +4722,7 @@ - Manure 3 85.567 1.1225 99 0.30 - Moisture 3 87.517 1.5788 99 0.03 * --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: dune ~ Moisture + Manure @@ -4734,7 +4730,7 @@ - Manure 4 87.707 1.8598 99 0.02 * - Moisture 3 89.232 2.3275 99 0.01 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Call: rda(formula = dune ~ Moisture + Manure, data = dune.env) @@ -4784,7 +4780,7 @@ Df AIC F N.Perm Pr(>F) + WatrCont 1 -84.336 25.35 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: R2.adj= 0.2608453 Call: mite.hel ~ WatrCont @@ -4801,7 +4797,7 @@ Df AIC F N.Perm Pr(>F) + Shrub 2 -88.034 3.836 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: R2.adj= 0.3177536 Call: mite.hel ~ WatrCont + Shrub @@ -4818,7 +4814,7 @@ Df AIC F N.Perm Pr(>F) + Substrate 6 -87.768 1.8251 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: R2.adj= 0.3653551 Call: mite.hel ~ WatrCont + Shrub + Substrate @@ -4835,7 +4831,7 @@ Df AIC F N.Perm Pr(>F) + Topo 1 -90.924 4.5095 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: R2.adj= 0.4004249 Call: mite.hel ~ WatrCont + Shrub + Substrate + Topo @@ -4852,7 +4848,7 @@ Df AIC F N.Perm Pr(>F) + SubsDens 1 -94.489 4.7999 199 0.005 ** --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +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 @@ -4875,7 +4871,7 @@ + SubsDens 0.43670 1 -94.489 4.7999 199 0.005 ** 0.43670 --- -Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > ## Example of ordiR2step with direction = "forward" > ## Not run: @@ -4912,7 +4908,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.45 total = 7.45 @@ -4928,7 +4924,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.12 total = 7.12 @@ -4940,13 +4936,13 @@ > ## Get fitted values > calibrate(fit) 1 2 3 4 5 6 7 -22.0596536 6.0185658 3.6298560 4.1000950 8.9833602 5.9067474 8.6617386 +22.0596535 6.0185659 3.6298559 4.1000950 8.9833600 5.9067472 8.6617389 8 9 10 11 12 13 14 -11.0812151 0.6432692 35.2567122 10.4452454 7.2748480 5.5780162 24.6561684 +11.0812152 0.6432691 35.2567124 10.4452454 7.2748478 5.5780162 24.6561685 15 16 17 18 19 20 21 -18.8879904 29.7642960 5.6095921 9.5945523 3.2753635 2.6966144 10.7869350 +18.8879906 29.7642964 5.6095920 9.5945524 3.2753633 2.6966143 10.7869351 22 23 24 - 2.9902833 9.8082238 7.3406584 + 2.9902832 9.8082237 7.3406581 > > ## Plot method > plot(fit, what = "contour") @@ -5063,10 +5059,6 @@ > ordicloud(ord, form = CA2 ~ CA3*CA1, groups = Manure, data = dune.env) > ordicloud(ord, form = CA2 ~ CA3*CA1 | Management, groups = Manure, + data = dune.env, auto.key = TRUE, type = c("p","h")) -Warning in FUN(X[[8L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[9L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[8L]], ...) : 'x' is NULL so the result will be NULL -Warning in FUN(X[[9L]], ...) : 'x' is NULL so the result will be NULL > > > @@ -5100,7 +5092,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.93 total = 9.93 @@ -5113,7 +5105,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 7.75 total = 8.75 @@ -5126,7 +5118,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.9 total = 9.9 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2431 From noreply at r-forge.r-project.org Tue Feb 12 13:45:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Feb 2013 13:45:53 +0100 (CET) Subject: [Vegan-commits] r2432 - pkg/vegan/man Message-ID: <20130212124553.49270184BC9@r-forge.r-project.org> Author: jarioksa Date: 2013-02-12 13:45:52 +0100 (Tue, 12 Feb 2013) New Revision: 2432 Modified: pkg/vegan/man/cca.Rd Log: language and tweaks Modified: pkg/vegan/man/cca.Rd =================================================================== --- pkg/vegan/man/cca.Rd 2013-02-11 18:34:53 UTC (rev 2431) +++ pkg/vegan/man/cca.Rd 2013-02-12 12:45:52 UTC (rev 2432) @@ -105,9 +105,9 @@ frames). The formula can include a special term \code{Condition} for conditioning variables (``covariables'') ``partialled out'' before - analysis. So the following commands are equivalent: \code{cca(X, Y, - Z)}, \code{cca(X ~ Y + Condition(Z))}, where \code{Y} and \code{Z} - refer to constraints and conditions matrices respectively. + analysis. So the following commands are equivalent: + \code{cca(X, Y, Z)}, \code{cca(X ~ Y + Condition(Z))}, where \code{Y} + and \code{Z} refer to constraints and conditions matrices respectively. Constrained correspondence analysis is indeed a constrained method: CCA does not try to display all variation in the @@ -198,12 +198,12 @@ This help page describes two constrained ordination functions, \code{cca} and \code{rda}. A related method, distance-based redundancy analysis (dbRDA) is described separately - (\code{\link{capscale}}). All these function return similar objects + (\code{\link{capscale}}). All these functions return similar objects (described in \code{\link{cca.object}}). There are numerous support - functions that can used to access the result object. In the list - below, functions of type \code{cca} will handle all ordination - objects, and functions of \code{rda} only handle \code{rda} and - \code{\link{capscale}} results. + functions that can be used to access the result object. In the list + below, functions of type \code{cca} will handle all three constrained + ordination objects, and functions of \code{rda} only handle \code{rda} + and \code{\link{capscale}} results. The main plotting functions are \code{\link{plot.cca}} for all methods, and \code{\link{biplot.rda}} for RDA and dbRDA. However, From noreply at r-forge.r-project.org Tue Feb 12 15:00:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Feb 2013 15:00:37 +0100 (CET) Subject: [Vegan-commits] r2433 - in pkg/vegan: R man Message-ID: <20130212140037.78E22181128@r-forge.r-project.org> Author: jarioksa Date: 2013-02-12 15:00:37 +0100 (Tue, 12 Feb 2013) New Revision: 2433 Modified: pkg/vegan/R/tabasco.R pkg/vegan/man/vegemite.Rd Log: tabasco did not correctly order sites when 'use' was a dendrogram because heatmap rearranged the once arranged data. site.ind/sp.ind take a preference over 'use' also in tabasco (like documented for vegemite) or given an error. 'select' or 'site.ind' given an error when 'use' is dendrogram/tree. Rd page updated for tabasco. Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-12 12:45:52 UTC (rev 2432) +++ pkg/vegan/R/tabasco.R 2013-02-12 14:00:37 UTC (rev 2433) @@ -17,20 +17,22 @@ sp.ind <- order(wascores(use, x)) } else if (inherits(use, "hclust")) { - if (is.null(site.ind)) - site.ind <- use$order + if (!is.null(site.ind)) + stop("'hclust' tree cannot be 'use'd with 'site.ind'") + site.ind <- seq_len(nrow(x)) if (is.null(sp.ind)) - sp.ind <- order(wascores(order(site.ind), x)) + sp.ind <- order(wascores(order(use$order), x)) Colv <- as.dendrogram(use) } else if (inherits(use, "dendrogram")) { - if (is.null(site.ind)) { - site.ind <- 1:nrow(x) - names(site.ind) <- rownames(x) - site.ind <- site.ind[labels(use)] - } + if (!is.null(site.ind)) + stop("'dendrogram' cannot be 'use'd with 'site.ind'") + site.ind <- seq_len(nrow(x)) + o <- seq_len(nrow(x)) + names(o) <- rownames(x) + o <- o[labels(use)] if (is.null(sp.ind)) - sp.ind <- order(wascores(order(site.ind), x)) + sp.ind <- order(wascores(order(o), x)) Colv <- use } else if (is.list(use)) { @@ -51,6 +53,13 @@ sp.ind <- order(wascores(tmp, x)) } } + ## see if sp.ind is a dendrogram or hclust tree + if (inherits(sp.ind, c("hclust", "dendrogram"))) { + if (!inherits(sp.ind, "dendrogram")) + sp.ind <- as.dendrogram(sp.ind) + Rowv <- sp.ind + sp.ind <- seq_len(ncol(x)) + } if (!is.null(sp.ind) && is.logical(sp.ind)) sp.ind <- (1:ncol(x))[sp.ind] if (!is.null(site.ind) && is.logical(site.ind)) @@ -60,6 +69,8 @@ if (is.null(site.ind)) site.ind <- 1:nrow(x) if (!missing(select)) { + if (inherits(use, c("hclust", "dendrogram"))) + stop("sites cannot be 'select'ed with dendrograms or hclust trees") if (!is.logical(select)) select <- sort(site.ind) %in% select stake <- colSums(x[select, , drop = FALSE]) > 0 Modified: pkg/vegan/man/vegemite.Rd =================================================================== --- pkg/vegan/man/vegemite.Rd 2013-02-12 12:45:52 UTC (rev 2432) +++ pkg/vegan/man/vegemite.Rd 2013-02-12 14:00:37 UTC (rev 2433) @@ -25,7 +25,8 @@ \item{use}{Either a vector, or an object from \code{cca}, \code{decorana} \emph{etc.} or \code{hclust} or a \code{\link{dendrogram}} for ordering sites and species.} - \item{sp.ind}{Species indices. } + \item{sp.ind}{Species indices. In \code{tabasco}, this can also be an + \code{\link{hclust}} tree or a \code{\link{dendrogram}}. } \item{site.ind}{Site indices. } \item{zero}{Character used for zeros. } \item{select}{Select a subset of sites. This can be a logical vector @@ -55,9 +56,10 @@ \code{\link{hclust}}, a \code{\link{dendrogram}} or any ordination result recognized by \code{\link{scores}} (all ordination methods in \pkg{vegan} and some of those not in \pkg{vegan}). The - \code{\link{hclust}} an \code{\link{dendrogram}} must be for - sites. The dendrogram is displayed in above the sites in - \code{tabasco}. + \code{\link{hclust}} and \code{\link{dendrogram}} must be for + sites. The dendrogram is displayed above the sites in + \code{tabasco}. No dendrogram for species is displayed, except when + given in \code{sp.ind}. If \code{use} is a vector, it is used for ordering sites. If \code{use} is an object from ordination, both @@ -73,13 +75,19 @@ clustering, but in some cases species are still nicely ordered (please note that you can \code{\link{reorder.dendrogram}} to have such a natural order). - Alternatively, species and sites can be ordered explicitly giving - their indices or names in parameters \code{sp.ind} and - \code{site.ind}. If these are given, they take precedence over - \code{use}. A subset of sites can be displayed using argument - \code{select}, but this cannot be used to order sites, but you still - must give \code{use} or \code{site.ind}. + Species and sites can be ordered explicitly giving their indices or + names in parameters \code{sp.ind} and \code{site.ind}. If these are + given, they take precedence over \code{use}. A subset of sites can be + displayed using argument \code{select}, but this cannot be used to + order sites, but you still must give \code{use} or \code{site.ind}. + However, \code{tabasco} makes two exceptions: \code{site.ind} and + \code{select} cannot be used when \code{use} is an + \code{\link{hclust}} tree or a \code{\link{dendrogram}}. In addition, + the \code{sp.ind} can also be an \code{\link{hclust}} tree or a + \code{\link{dendrogram}}, and in that case the dendrogram is plotted + on the left side of the \code{\link{heatmap}}. + If \code{scale} is given, \code{vegemite} calls \code{coverscale} to transform percent cover scale or some other scales into traditional class scales used in @@ -102,13 +110,13 @@ 10 with \code{X} and positive values below 1 with \code{+}. } \value{ - The function is used mainly to print a table, but it returns + The functions are used mainly to display a table, but it returns (invisibly) a list with items: \item{species}{Ordered species indices} \item{sites}{Ordered site indices} These items can be used as arguments \code{sp.ind} and \code{site.ind} - to reproduce the table. In addition to the proper table, the function + to reproduce the table. In addition to the proper table, \code{vegemite} prints the numbers of species and sites and the name of the used cover scale at the end. } From noreply at r-forge.r-project.org Wed Feb 13 15:24:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Feb 2013 15:24:23 +0100 (CET) Subject: [Vegan-commits] r2434 - in pkg/vegan: R inst man Message-ID: <20130213142424.0DBBC184B71@r-forge.r-project.org> Author: jarioksa Date: 2013-02-13 15:24:23 +0100 (Wed, 13 Feb 2013) New Revision: 2434 Modified: pkg/vegan/R/wcmdscale.R pkg/vegan/inst/ChangeLog pkg/vegan/man/wcmdscale.Rd Log: return full wcmdscale object always with non-default arguments, including weights Modified: pkg/vegan/R/wcmdscale.R =================================================================== --- pkg/vegan/R/wcmdscale.R 2013-02-12 14:00:37 UTC (rev 2433) +++ pkg/vegan/R/wcmdscale.R 2013-02-13 14:24:23 UTC (rev 2434) @@ -8,6 +8,9 @@ } if (add) .NotYetUsed("add") + ## Force eig=TRUE if add, x.ret or !missing(w) + if(add || x.ret || !missing(w)) + eig <- TRUE ZERO <- sqrt(.Machine$double.eps) if (!inherits(d, "dist")) { op <- options(warn = 2) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-12 14:00:37 UTC (rev 2433) +++ pkg/vegan/inst/ChangeLog 2013-02-13 14:24:23 UTC (rev 2434) @@ -9,6 +9,12 @@ * tabasco: a sister function of vegemite() to display a compact community table using heatmap(). + + * wcmdscale: return a full "wcmdscale" object if any argument is + set to non-default value. This also implies that if weights 'w' + are set, the result will be full "wcmdscale" object with a + "weights" item, instead of a simple matrix with no information + about weights used. Version 2.1-25 (closed February 11, 2013) Modified: pkg/vegan/man/wcmdscale.Rd =================================================================== --- pkg/vegan/man/wcmdscale.Rd 2013-02-12 14:00:37 UTC (rev 2433) +++ pkg/vegan/man/wcmdscale.Rd 2013-02-13 14:24:23 UTC (rev 2434) @@ -49,10 +49,11 @@ With default options, the function returns only a matrix of scores scaled by eigenvalues for all real axes. If the function is called - with \code{eig = TRUE} or \code{x.ret = TRUE}, the function returns an - object of class \code{"wcmdscale"} with \code{print}, \code{plot}, - \code{scores}, \code{\link{eigenvals}} and \code{\link{stressplot}} - methods, and described in section Value. } + with \code{eig = TRUE} or \code{x.ret = TRUE} or with weights + \code{w}, the function returns an object of class \code{"wcmdscale"} + with \code{print}, \code{plot}, \code{scores}, \code{\link{eigenvals}} + and \code{\link{stressplot}} methods, and described in section Value. + } \value{ If \code{eig = FALSE} and \code{x.ret = FALSE} (default), a matrix with \code{k} columns whose rows give the coordinates of the From noreply at r-forge.r-project.org Wed Feb 13 17:52:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Feb 2013 17:52:34 +0100 (CET) Subject: [Vegan-commits] r2435 - pkg/vegan/R Message-ID: <20130213165234.C7BBD184C6C@r-forge.r-project.org> Author: jarioksa Date: 2013-02-13 17:52:34 +0100 (Wed, 13 Feb 2013) New Revision: 2435 Modified: pkg/vegan/R/tabasco.R Log: tabasco did not return (invisibly) correct indices when dendrograms were used Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-13 14:24:23 UTC (rev 2434) +++ pkg/vegan/R/tabasco.R 2013-02-13 16:52:34 UTC (rev 2435) @@ -19,20 +19,19 @@ else if (inherits(use, "hclust")) { if (!is.null(site.ind)) stop("'hclust' tree cannot be 'use'd with 'site.ind'") - site.ind <- seq_len(nrow(x)) + site.ind <- use$order if (is.null(sp.ind)) - sp.ind <- order(wascores(order(use$order), x)) + sp.ind <- order(wascores(order(site.ind), x)) Colv <- as.dendrogram(use) } else if (inherits(use, "dendrogram")) { if (!is.null(site.ind)) stop("'dendrogram' cannot be 'use'd with 'site.ind'") site.ind <- seq_len(nrow(x)) - o <- seq_len(nrow(x)) - names(o) <- rownames(x) - o <- o[labels(use)] + names(site.ind) <- rownames(x) + site.ind <- site.ind[labels(use)] if (is.null(sp.ind)) - sp.ind <- order(wascores(order(o), x)) + sp.ind <- order(wascores(order(site.ind), x)) Colv <- use } else if (is.list(use)) { @@ -59,6 +58,8 @@ sp.ind <- as.dendrogram(sp.ind) Rowv <- sp.ind sp.ind <- seq_len(ncol(x)) + names(sp.ind) <- colnames(x) + sp.ind <- sp.ind[labels(Rowv)] } if (!is.null(sp.ind) && is.logical(sp.ind)) sp.ind <- (1:ncol(x))[sp.ind] @@ -69,7 +70,7 @@ if (is.null(site.ind)) site.ind <- 1:nrow(x) if (!missing(select)) { - if (inherits(use, c("hclust", "dendrogram"))) + if (!is.na(Colv)) stop("sites cannot be 'select'ed with dendrograms or hclust trees") if (!is.logical(select)) select <- sort(site.ind) %in% select @@ -81,9 +82,19 @@ stake <- colSums(x[site.ind, ]) > 0 } sp.ind <- sp.ind[stake[sp.ind]] - x <- x[site.ind, sp.ind] - x <- as.matrix(x) - x <- t(x) + ## heatmap will reorder items by dendrogram so that we need to + ## give indices in the unsorted order if rows or columns have a + ## dendrogram + if (is.na(Colv[1])) + rind <- site.ind + else + rind <- sort(site.ind) + if (is.na(Rowv[1])) + cind <- sp.ind + else + cind <- sort(sp.ind) + ## we assume t() changes data.frame to a matrix + x <- t(x[rind, cind]) sp.nam <- rownames(x) sp.len <- max(nchar(sp.nam)) heatmap((max(x) - x), Rowv, Colv, scale = "none", ...) From noreply at r-forge.r-project.org Wed Feb 13 18:03:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Feb 2013 18:03:01 +0100 (CET) Subject: [Vegan-commits] r2436 - pkg/vegan/R Message-ID: <20130213170301.71B641808DF@r-forge.r-project.org> Author: jarioksa Date: 2013-02-13 18:03:01 +0100 (Wed, 13 Feb 2013) New Revision: 2436 Modified: pkg/vegan/R/tabasco.R Log: put tabasco origin to the upper left corner instead of lowerleft Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-13 16:52:34 UTC (rev 2435) +++ pkg/vegan/R/tabasco.R 2013-02-13 17:03:01 UTC (rev 2436) @@ -60,6 +60,8 @@ sp.ind <- seq_len(ncol(x)) names(sp.ind) <- colnames(x) sp.ind <- sp.ind[labels(Rowv)] + ## reverse: origin in the upper left corner + Rowv <- rev(Rowv) } if (!is.null(sp.ind) && is.logical(sp.ind)) sp.ind <- (1:ncol(x))[sp.ind] @@ -90,7 +92,8 @@ else rind <- sort(site.ind) if (is.na(Rowv[1])) - cind <- sp.ind + ## reverse: origin in the upper left corner + cind <- rev(sp.ind) else cind <- sort(sp.ind) ## we assume t() changes data.frame to a matrix From noreply at r-forge.r-project.org Wed Feb 13 18:26:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Feb 2013 18:26:46 +0100 (CET) Subject: [Vegan-commits] r2437 - in pkg/vegan: R inst Message-ID: <20130213172647.094671841A4@r-forge.r-project.org> Author: jarioksa Date: 2013-02-13 18:26:46 +0100 (Wed, 13 Feb 2013) New Revision: 2437 Modified: pkg/vegan/R/tabasco.R pkg/vegan/R/vegemite.R pkg/vegan/inst/ChangeLog Log: tabasco & vegemite know cluster::agnes trees, and tabasco can handle picante::phylo trees for species (not tested) Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-13 17:03:01 UTC (rev 2436) +++ pkg/vegan/R/tabasco.R 2013-02-13 17:26:46 UTC (rev 2437) @@ -24,7 +24,9 @@ sp.ind <- order(wascores(order(site.ind), x)) Colv <- as.dendrogram(use) } - else if (inherits(use, "dendrogram")) { + else if (inherits(use, c("dendrogram", "twins"))) { + if (!inherits(use, "dendrogram")) + use <- as.dendrogram(use) if (!is.null(site.ind)) stop("'dendrogram' cannot be 'use'd with 'site.ind'") site.ind <- seq_len(nrow(x)) @@ -53,7 +55,10 @@ } } ## see if sp.ind is a dendrogram or hclust tree - if (inherits(sp.ind, c("hclust", "dendrogram"))) { + if (inherits(sp.ind, c("hclust", "dendrogram", "twins", "phylo"))) { + ## phylo trees are from picante: they only have as.hclust method + if (inherits(sp.ind, "phylo")) + sp.ind <- as.hclust(sp.ind) if (!inherits(sp.ind, "dendrogram")) sp.ind <- as.dendrogram(sp.ind) Rowv <- sp.ind Modified: pkg/vegan/R/vegemite.R =================================================================== --- pkg/vegan/R/vegemite.R 2013-02-13 17:03:01 UTC (rev 2436) +++ pkg/vegan/R/vegemite.R 2013-02-13 17:26:46 UTC (rev 2437) @@ -9,7 +9,9 @@ if (is.null(sp.ind)) sp.ind <- order(wascores(use, x)) } - else if (inherits(use, "hclust")) { + else if (inherits(use, c("hclust", "twins"))) { + if (!inherits(use, "hclust")) + use <- as.hclust(use) if (is.null(site.ind)) site.ind <- use$order if (is.null(sp.ind)) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-13 17:03:01 UTC (rev 2436) +++ pkg/vegan/inst/ChangeLog 2013-02-13 17:26:46 UTC (rev 2437) @@ -8,7 +8,9 @@ 11, 2013. * tabasco: a sister function of vegemite() to display a compact - community table using heatmap(). + community table using heatmap(). Both vegemite() and tabasco() can + handle cluster::agnes() trees, and tabasco() can handle + picante::phylo() trees for species. * wcmdscale: return a full "wcmdscale" object if any argument is set to non-default value. This also implies that if weights 'w' From noreply at r-forge.r-project.org Wed Feb 13 20:59:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Feb 2013 20:59:53 +0100 (CET) Subject: [Vegan-commits] r2438 - in pkg/vegan: R inst Message-ID: <20130213195953.CD8F118388B@r-forge.r-project.org> Author: jarioksa Date: 2013-02-13 20:59:53 +0100 (Wed, 13 Feb 2013) New Revision: 2438 Modified: pkg/vegan/R/tabasco.R pkg/vegan/R/vegemite.R pkg/vegan/inst/ChangeLog Log: we need to require() packages for method functions, and we don't want to add picante to vegan dependencies Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-13 17:26:46 UTC (rev 2437) +++ pkg/vegan/R/tabasco.R 2013-02-13 19:59:53 UTC (rev 2438) @@ -25,8 +25,10 @@ Colv <- as.dendrogram(use) } else if (inherits(use, c("dendrogram", "twins"))) { - if (!inherits(use, "dendrogram")) + if (inherits(use, "twins")) { + require(cluster) || stop("package cluster needed to handle 'use'") use <- as.dendrogram(use) + } if (!is.null(site.ind)) stop("'dendrogram' cannot be 'use'd with 'site.ind'") site.ind <- seq_len(nrow(x)) @@ -55,10 +57,9 @@ } } ## see if sp.ind is a dendrogram or hclust tree - if (inherits(sp.ind, c("hclust", "dendrogram", "twins", "phylo"))) { - ## phylo trees are from picante: they only have as.hclust method - if (inherits(sp.ind, "phylo")) - sp.ind <- as.hclust(sp.ind) + if (inherits(sp.ind, c("hclust", "dendrogram", "twins"))) { + if (inherits(sp.ind, "twins")) + require("cluster") || stop("package cluster needed to handle 'sp.ind'") if (!inherits(sp.ind, "dendrogram")) sp.ind <- as.dendrogram(sp.ind) Rowv <- sp.ind Modified: pkg/vegan/R/vegemite.R =================================================================== --- pkg/vegan/R/vegemite.R 2013-02-13 17:26:46 UTC (rev 2437) +++ pkg/vegan/R/vegemite.R 2013-02-13 19:59:53 UTC (rev 2438) @@ -1,4 +1,4 @@ -"vegemite" <- +`vegemite` <- function (x, use, scale, sp.ind = NULL, site.ind = NULL, zero = ".", select, ...) { @@ -10,8 +10,10 @@ sp.ind <- order(wascores(use, x)) } else if (inherits(use, c("hclust", "twins"))) { - if (!inherits(use, "hclust")) + if (inherits(use, "twins")) { + require(cluster) || stop("package cluster needed for 'use'") use <- as.hclust(use) + } if (is.null(site.ind)) site.ind <- use$order if (is.null(sp.ind)) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-13 17:26:46 UTC (rev 2437) +++ pkg/vegan/inst/ChangeLog 2013-02-13 19:59:53 UTC (rev 2438) @@ -9,8 +9,7 @@ * tabasco: a sister function of vegemite() to display a compact community table using heatmap(). Both vegemite() and tabasco() can - handle cluster::agnes() trees, and tabasco() can handle - picante::phylo() trees for species. + handle cluster::agnes() trees. * wcmdscale: return a full "wcmdscale" object if any argument is set to non-default value. This also implies that if weights 'w' From noreply at r-forge.r-project.org Thu Feb 14 18:32:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 14 Feb 2013 18:32:42 +0100 (CET) Subject: [Vegan-commits] r2439 - pkg/vegan/R Message-ID: <20130214173242.DBE92184A85@r-forge.r-project.org> Author: jarioksa Date: 2013-02-14 18:32:42 +0100 (Thu, 14 Feb 2013) New Revision: 2439 Modified: pkg/vegan/R/tabasco.R Log: liberate Rowv and Colv to be used as arguments of tabasco Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-13 19:59:53 UTC (rev 2438) +++ pkg/vegan/R/tabasco.R 2013-02-14 17:32:42 UTC (rev 2439) @@ -8,7 +8,7 @@ function (x, use, sp.ind = NULL, site.ind = NULL, select, ...) { - Rowv <- Colv <- NA + pltree <- sptree <- NA if (!missing(use)) { if (!is.list(use) && is.vector(use)) { if (is.null(site.ind)) @@ -18,11 +18,11 @@ } else if (inherits(use, "hclust")) { if (!is.null(site.ind)) - stop("'hclust' tree cannot be 'use'd with 'site.ind'") + stop("'site.ind' cannot be used with 'hclust' tree ") site.ind <- use$order if (is.null(sp.ind)) sp.ind <- order(wascores(order(site.ind), x)) - Colv <- as.dendrogram(use) + pltree <- as.dendrogram(use) } else if (inherits(use, c("dendrogram", "twins"))) { if (inherits(use, "twins")) { @@ -30,13 +30,13 @@ use <- as.dendrogram(use) } if (!is.null(site.ind)) - stop("'dendrogram' cannot be 'use'd with 'site.ind'") + stop("'site.ind' cannot be used with dendrogram") site.ind <- seq_len(nrow(x)) names(site.ind) <- rownames(x) site.ind <- site.ind[labels(use)] if (is.null(sp.ind)) sp.ind <- order(wascores(order(site.ind), x)) - Colv <- use + pltree <- use } else if (is.list(use)) { tmp <- scores(use, choices = 1, display = "sites") @@ -62,12 +62,12 @@ require("cluster") || stop("package cluster needed to handle 'sp.ind'") if (!inherits(sp.ind, "dendrogram")) sp.ind <- as.dendrogram(sp.ind) - Rowv <- sp.ind + sptree <- sp.ind sp.ind <- seq_len(ncol(x)) names(sp.ind) <- colnames(x) - sp.ind <- sp.ind[labels(Rowv)] + sp.ind <- sp.ind[labels(sptree)] ## reverse: origin in the upper left corner - Rowv <- rev(Rowv) + sptree <- rev(sptree) } if (!is.null(sp.ind) && is.logical(sp.ind)) sp.ind <- (1:ncol(x))[sp.ind] @@ -93,11 +93,11 @@ ## heatmap will reorder items by dendrogram so that we need to ## give indices in the unsorted order if rows or columns have a ## dendrogram - if (is.na(Colv[1])) + if (is.na(pltree[1])) rind <- site.ind else rind <- sort(site.ind) - if (is.na(Rowv[1])) + if (is.na(sptree[1])) ## reverse: origin in the upper left corner cind <- rev(sp.ind) else @@ -106,7 +106,7 @@ x <- t(x[rind, cind]) sp.nam <- rownames(x) sp.len <- max(nchar(sp.nam)) - heatmap((max(x) - x), Rowv, Colv, scale = "none", ...) + heatmap((max(x) - x), sptree, pltree, scale = "none", ...) out <- list(sites = site.ind, species = sp.ind) invisible(out) } From noreply at r-forge.r-project.org Fri Feb 15 09:37:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Feb 2013 09:37:02 +0100 (CET) Subject: [Vegan-commits] r2440 - pkg/vegan/R Message-ID: <20130215083702.C9A941847DB@r-forge.r-project.org> Author: jarioksa Date: 2013-02-15 09:37:02 +0100 (Fri, 15 Feb 2013) New Revision: 2440 Modified: pkg/vegan/R/tabasco.R Log: combine dendrogram handling in one place Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-14 17:32:42 UTC (rev 2439) +++ pkg/vegan/R/tabasco.R 2013-02-15 08:37:02 UTC (rev 2440) @@ -16,19 +16,12 @@ if (is.null(sp.ind)) sp.ind <- order(wascores(use, x)) } - else if (inherits(use, "hclust")) { - if (!is.null(site.ind)) - stop("'site.ind' cannot be used with 'hclust' tree ") - site.ind <- use$order - if (is.null(sp.ind)) - sp.ind <- order(wascores(order(site.ind), x)) - pltree <- as.dendrogram(use) - } - else if (inherits(use, c("dendrogram", "twins"))) { + else if (inherits(use, c("dendrogram", "hclust", "twins"))) { if (inherits(use, "twins")) { require(cluster) || stop("package cluster needed to handle 'use'") - use <- as.dendrogram(use) } + if (!inherits(use, "dendrogram")) + use <- as.dendrogram(use) if (!is.null(site.ind)) stop("'site.ind' cannot be used with dendrogram") site.ind <- seq_len(nrow(x)) From noreply at r-forge.r-project.org Fri Feb 15 11:23:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Feb 2013 11:23:19 +0100 (CET) Subject: [Vegan-commits] r2441 - in pkg/vegan: R man Message-ID: <20130215102319.4567618486F@r-forge.r-project.org> Author: jarioksa Date: 2013-02-15 11:23:18 +0100 (Fri, 15 Feb 2013) New Revision: 2441 Modified: pkg/vegan/R/tabasco.R pkg/vegan/man/vegemite.Rd Log: tabasco can reorder dendrograms automatically or by vectors Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2013-02-15 08:37:02 UTC (rev 2440) +++ pkg/vegan/R/tabasco.R 2013-02-15 10:23:18 UTC (rev 2441) @@ -6,7 +6,7 @@ `tabasco` <- function (x, use, sp.ind = NULL, site.ind = NULL, - select, ...) + select, Rowv = TRUE, Colv = TRUE, ...) { pltree <- sptree <- NA if (!missing(use)) { @@ -24,6 +24,19 @@ use <- as.dendrogram(use) if (!is.null(site.ind)) stop("'site.ind' cannot be used with dendrogram") + ## Reorder tree if Rowv specified + if (isTRUE(Rowv)) { + ## order by first CA axis -- decorana() is fastest + tmp <- decorana(x, ira = 1) + use <- reorder(use, scores(tmp, dis="sites", choices = 1), + agglo.FUN = mean) + } else if (length(Rowv) > 1) { + ## Rowv is a vector + if (length(Rowv) != nrow(x)) + stop(gettextf("Rowv has length %d, but 'x' has %d rows", + length(Rowv), nrow(x))) + use <- reorder(use, Rowv, agglo.FUN = mean) + } site.ind <- seq_len(nrow(x)) names(site.ind) <- rownames(x) site.ind <- site.ind[labels(use)] @@ -56,6 +69,16 @@ if (!inherits(sp.ind, "dendrogram")) sp.ind <- as.dendrogram(sp.ind) sptree <- sp.ind + ## Consider reordering species tree + if (isTRUE(Colv) && !is.null(site.ind)) { + sptree <- reorder(sptree, wascores(order(site.ind), x), + agglo.FUN = mean) + } else if (length(Colv) > 1) { + if (length(Colv) != ncol(x)) + stop(gettextf("Colv has length %d, but 'x' has %d columns", + length(Colv), ncol(x))) + sptree <- reorder(sptree, Colv, agglo.FUN = mean) + } sp.ind <- seq_len(ncol(x)) names(sp.ind) <- colnames(x) sp.ind <- sp.ind[labels(sptree)] @@ -71,7 +94,7 @@ if (is.null(site.ind)) site.ind <- 1:nrow(x) if (!missing(select)) { - if (!is.na(Colv)) + if (!is.na(pltree)) stop("sites cannot be 'select'ed with dendrograms or hclust trees") if (!is.logical(select)) select <- sort(site.ind) %in% select @@ -99,7 +122,8 @@ x <- t(x[rind, cind]) sp.nam <- rownames(x) sp.len <- max(nchar(sp.nam)) - heatmap((max(x) - x), sptree, pltree, scale = "none", ...) + heatmap((max(x) - x), Rowv = sptree, Colv = pltree, + scale = "none", ...) out <- list(sites = site.ind, species = sp.ind) invisible(out) } Modified: pkg/vegan/man/vegemite.Rd =================================================================== --- pkg/vegan/man/vegemite.Rd 2013-02-15 08:37:02 UTC (rev 2440) +++ pkg/vegan/man/vegemite.Rd 2013-02-15 10:23:18 UTC (rev 2441) @@ -15,7 +15,8 @@ } \usage{ vegemite(x, use, scale, sp.ind, site.ind, zero=".", select ,...) -tabasco(x, use, sp.ind = NULL, site.ind = NULL, select, ...) +tabasco(x, use, sp.ind = NULL, site.ind = NULL, select, + Rowv = TRUE, Colv = TRUE, ...) coverscale(x, scale=c("Braun.Blanquet", "Domin", "Hult", "Hill", "fix","log"), maxabund) } @@ -33,7 +34,13 @@ (\code{TRUE} for selected sites), or a vector of indices of selected sites. The order of indices does not influence results, but you must specify \code{use} or \code{site.ind} to reorder sites. - } + } + \item{Rowv, Colv}{Reorder dendrograms for the rows (sites) or columns + (species) of \code{x}. If the arguments are \code{TRUE}, row + dendrograms are ordered by the first axis of correspondence + analysis, and column dendrograms by the weighted average + (\code{\link{wascores}}) of the order in the row. Alternatively + these can be vectors that are used to reorder the dendrogram. } \item{scale}{Cover scale used (can be abbreviated).} \item{maxabund}{Maximum abundance used with \code{scale = "log"}. Data maximum in the \code{select}ed subset will be used if this is From noreply at r-forge.r-project.org Sun Feb 17 08:05:38 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 08:05:38 +0100 (CET) Subject: [Vegan-commits] r2442 - in pkg/vegan: man tests/Examples Message-ID: <20130217070538.85ABA1800CB@r-forge.r-project.org> Author: jarioksa Date: 2013-02-17 08:05:38 +0100 (Sun, 17 Feb 2013) New Revision: 2442 Modified: pkg/vegan/man/vegemite.Rd pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: upgdate vegemite.Rd for tabasco Modified: pkg/vegan/man/vegemite.Rd =================================================================== --- pkg/vegan/man/vegemite.Rd 2013-02-15 10:23:18 UTC (rev 2441) +++ pkg/vegan/man/vegemite.Rd 2013-02-17 07:05:38 UTC (rev 2442) @@ -5,12 +5,13 @@ \title{Display Compact Ordered Community Tables } \description{ - The functions display compact community tables. Function - \code{vegemite} prints text tables where species are rows, and each - site takes only one column without spaces. Function \code{tabasco} - provides interface for \code{\link{heatmap}} for a colour map of - the data. The community table can be ordered by explicit indexing, - by environmental variables or results from an ordination or cluster + Functions \code{vegemite} and \code{tabasco} display compact + community tables. Function \code{vegemite} prints text tables where + species are rows, and each site takes only one column without + spaces. Function \code{tabasco} provides interface for + \code{\link{heatmap}} for a colour \code{\link{image}} of the + data. The community table can be ordered by explicit indexing, by + environmental variables or results from an ordination or cluster analysis. } \usage{ @@ -22,78 +23,85 @@ } \arguments{ - \item{x}{Vegetation data. } + \item{x}{Community data. } \item{use}{Either a vector, or an object from \code{cca}, \code{decorana} \emph{etc.} or \code{hclust} or a \code{\link{dendrogram}} for ordering sites and species.} - \item{sp.ind}{Species indices. In \code{tabasco}, this can also be an - \code{\link{hclust}} tree or a \code{\link{dendrogram}}. } - \item{site.ind}{Site indices. } + \item{sp.ind, site.ind}{Species and site indices. In \code{tabasco}, + these can also be \code{\link{hclust}} tree, + \code{\link[cluster]{agnes}} clusterings or + \code{\link{dendrogram}}s. } \item{zero}{Character used for zeros. } \item{select}{Select a subset of sites. This can be a logical vector (\code{TRUE} for selected sites), or a vector of indices of selected sites. The order of indices does not influence results, but you must specify \code{use} or \code{site.ind} to reorder sites. } - \item{Rowv, Colv}{Reorder dendrograms for the rows (sites) or columns - (species) of \code{x}. If the arguments are \code{TRUE}, row + \item{Rowv, Colv}{Re-order dendrograms for the rows (sites) or + columns (species) of \code{x}. If the \code{Rowv = TRUE}, row dendrograms are ordered by the first axis of correspondence - analysis, and column dendrograms by the weighted average - (\code{\link{wascores}}) of the order in the row. Alternatively - these can be vectors that are used to reorder the dendrogram. } + analysis, and when \code{Colv = TRUE} column dendrograms by the + weighted average (\code{\link{wascores}}) of the row order. + Alternatively, the arguments can be vectors that are used to + reorder the dendrogram. } \item{scale}{Cover scale used (can be abbreviated).} \item{maxabund}{Maximum abundance used with \code{scale = "log"}. Data maximum in the \code{select}ed subset will be used if this is missing.} - \item{...}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}) in + \item{\dots}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}) in \code{vegemite} and to \code{\link{heatmap}} in \code{tabasco}.} } \details{ The function \code{vegemite} prints a traditional community table. - Unlike in ordinary data matrices, species are used as rows and sites - as columns. The table is printed in compact form: only one character + The display is transposed, so that species are in rows and sites in + columns. The table is printed in compact form: only one character can be used for abundance, and there are no spaces between columns. Species with no occurrences are dropped from the table. Function \code{tabasco} produces a similar table as \code{vegemite} - using \code{\link{heatmap}}, where abundances are coded by heatmap - colours. + using \code{\link{heatmap}}, where abundances are coded by + colours. The function can also display dendrograms for sites + (columns) or species if these are given as an argument (\code{use} + for sites, \code{sp.ind} for species). - The parameter \code{use} can be a vector or an object from - \code{\link{hclust}}, a \code{\link{dendrogram}} or any ordination - result recognized by \code{\link{scores}} (all ordination methods in - \pkg{vegan} and some of those not in \pkg{vegan}). The - \code{\link{hclust}} and \code{\link{dendrogram}} must be for - sites. The dendrogram is displayed above the sites in - \code{tabasco}. No dendrogram for species is displayed, except when - given in \code{sp.ind}. + The parameter \code{use} will be used to re-order output. The + \code{use} can be a vector or an object from \code{\link{hclust}} or + \code{\link[cluster]{agnes}}, a \code{\link{dendrogram}} or any + ordination result recognized by \code{\link{scores}} (all ordination + methods in \pkg{vegan} and some of those not in \pkg{vegan}). The + \code{\link{hclust}}, \code{\link[cluster]{agnes}} and + \code{\link{dendrogram}} must be for sites. The dendrogram is + displayed above the sites in \code{tabasco}, but is not shown in + \code{vegemite}. No dendrogram for species is displayed, except + when given in \code{sp.ind}. - If \code{use} is a vector, it is used - for ordering sites. If \code{use} is an object from ordination, both - sites and species are arranged by the first axis. - When \code{use} is an - object from \code{\link{hclust}} or a \code{\link{dendrogram}}, the - sites are ordered similarly - as in the cluster dendrogram. - If ordination methods provide species scores, these are used for - ordering species. In all cases where species scores are missing, - species are ordered by their weighted averages (\code{\link{wascores}}) - on site scores. There is no natural, unique ordering in hierarchic - clustering, but in some cases species are still nicely ordered (please - note that you can \code{\link{reorder.dendrogram}} to have such a - natural order). + If \code{use} is a vector, it is used for ordering sites. If + \code{use} is an object from ordination, both sites and species are + arranged by the first axis (provided that results are available both + also for species). When \code{use} is an object from + \code{\link{hclust}}, \code{\link[cluster]{agnes}} or a + \code{\link{dendrogram}}, the sites are ordered similarly as in the + cluster dendrogram. Function \code{tabasco} re-orders the + dendrogram if \code{Rowv = TRUE} or \code{Rowv} is a vector. Such + re-ordering is not available for \code{vegemite}, but it can be done + by hand using \code{\link{reorder.dendrogram}}. In all cases where + species scores are missing, species are ordered by their weighted + averages (\code{\link{wascores}}) on site order. Species and sites can be ordered explicitly giving their indices or names in parameters \code{sp.ind} and \code{site.ind}. If these are - given, they take precedence over \code{use}. A subset of sites can be - displayed using argument \code{select}, but this cannot be used to - order sites, but you still must give \code{use} or \code{site.ind}. - However, \code{tabasco} makes two exceptions: \code{site.ind} and - \code{select} cannot be used when \code{use} is an - \code{\link{hclust}} tree or a \code{\link{dendrogram}}. In addition, - the \code{sp.ind} can also be an \code{\link{hclust}} tree or a - \code{\link{dendrogram}}, and in that case the dendrogram is plotted - on the left side of the \code{\link{heatmap}}. + given, they take precedence over \code{use}. A subset of sites can + be displayed using argument \code{select}, but this cannot be used + to order sites, but you still must give \code{use} or + \code{site.ind}. However, \code{tabasco} makes two exceptions: + \code{site.ind} and \code{select} cannot be used when \code{use} is + a dendrogram (clustering result). In addition, the \code{sp.ind} can + be an \code{\link{hclust}} tree, \code{\link[cluster]{agnes}} + clustering or a \code{\link{dendrogram}}, and in that case the + dendrogram is plotted on the left side of the + \code{\link{heatmap}}. Phylogenetic trees cannot be directly used, + \code{\link[ape]{as.hclust.phylo}} (package \pkg{ape}) can transform + these to \code{\link{hclust}} trees. If \code{scale} is given, \code{vegemite} calls \code{coverscale} to transform percent cover @@ -117,11 +125,12 @@ 10 with \code{X} and positive values below 1 with \code{+}. } \value{ - The functions are used mainly to display a table, but it returns + The functions are used mainly to display a table, but they return (invisibly) a list with items: \item{species}{Ordered species indices} \item{sites}{Ordered site indices} + These items can be used as arguments \code{sp.ind} and \code{site.ind} to reproduce the table. In addition to the proper table, \code{vegemite} prints the numbers of species and sites and the name of the used cover @@ -137,9 +146,9 @@ \seealso{\code{\link{cut}} and \code{\link{approx}} for making your own \sQuote{cover scales} for \code{vegemite}. Function - \code{tabasco} is based on \code{\link{heatmap}}. Both functions - order species with weighted averages using \code{\link{wascores}}. - } + \code{tabasco} is based on \code{\link{heatmap}} which in turn is + based on \code{\link{image}}. Both functions order species with + weighted averages using \code{\link{wascores}}. } \note{ @@ -160,18 +169,31 @@ clus <- hclust(vegdist(varespec)) cl <- cutree(clus, 3) sel <- vegemite(varespec, use=dca, select = cl == 3, scale="Br") -# Re-create previous +## Re-create previous vegemite(varespec, sp=sel$sp, site=sel$site, scale="Hult") +## Re-order clusters by ordination +clus <- as.dendrogram(clus) +clus <- reorder(clus, scores(dca, choices=1, display="sites"), agglo.FUN = mean) +vegemite(varespec, clus, scale = "Hult") ## Abundance values have such a wide range that they must be rescaled ## or all abundances will not be shown in tabasco -tabasco(decostand(varespec, "log"), clus) -## reorder dendrogram by the first DCA axis -clus <- as.dendrogram(clus) -clus <- reorder(clus, scores(dca, choices=1, display="sites")) -tabasco(decostand(varespec, "log"), clus) +tabasco(decostand(varespec, "log"), dca) +## Classification trees for species +data(dune, dune.taxon) +taxontree <- hclust(taxa2dist(dune.taxon)) +plotree <- hclust(vegdist(dune), "average") +## Automatic reordering of clusters +tabasco(dune, plotree, sp.ind = taxontree) +## No reordering of taxonomy +tabasco(dune, plotree, sp.ind = taxontree, Colv = FALSE) +## Species cluster: most dissimilarity indices do a bad job when +## comparing rare and common species, but Raup-Crick makes sense +sptree <- hclust(vegdist(t(dune), "raup"), "average") +tabasco(dune, plotree, sptree) } -\keyword{ print } -\keyword{ manip } +\keyword{print} +\keyword{manip} +\keyword{hplot} Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-15 10:23:18 UTC (rev 2441) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-17 07:05:38 UTC (rev 2442) @@ -161,7 +161,7 @@ Formula: y ~ poly(x1, 1) + poly(x2, 1) - + Total model degrees of freedom 3 GCV score: 0.04278782 @@ -4908,7 +4908,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.45 total = 7.45 @@ -4924,7 +4924,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.12 total = 7.12 @@ -5092,7 +5092,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.93 total = 9.93 @@ -5105,7 +5105,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 7.75 total = 8.75 @@ -5118,7 +5118,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.9 total = 9.9 @@ -7692,7 +7692,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 2 total = 3 @@ -7941,7 +7941,7 @@ sites species 5 37 scale: Braun.Blanquet -> # Re-create previous +> ## Re-create previous > vegemite(varespec, sp=sel$sp, site=sel$site, scale="Hult") 1 12 @@ -7986,17 +7986,78 @@ sites species 5 37 scale: Hult +> ## Re-order clusters by ordination +> clus <- as.dendrogram(clus) +> clus <- reorder(clus, scores(dca, choices=1, display="sites"), agglo.FUN = mean) +> vegemite(varespec, clus, scale = "Hult") + + 1 111 1211221212222 + 431567380922149306254578 + Cet.niv 21.111.111....11........ + Cla.ama .1.1...1................ + Ste.sp 111211111....111.1.111.1 + Pol.pil ..111..1......111..1.... + Dip.mon .1...111.1...........1.. + Cla.phy ..1.....11...1.......... + Cla.ran 344544332133111223121121 + Cla.cer 1.........1..........1.. + Cla.ste 454121215555213111111.1. + Cla.arb 322344331111132222121111 + Vac.uli 11...2.1........1.1..111 + Cal.vul 111.1.311.11.1..11111... + Ich.eri ...1.1.......1...1...... + Cla.sp 1...1.11.1......111..11. + Cla.coc 1111111111...1111111.1.1 + Pin.syl 1.111.1111111111111111.1 + Cla.chl .1..111.111.1.11..1.1... + Cet.isl 1.1...1.11.111...1.111.1 + Cla.fim 11.11111111111111111.111 + Pel.aph ..1...11.......1.....11. + Cet.eri 11.1111111...1..111111.. + Cla.gra 11111111.111111111111111 + Poh.nut 111..11111.1111111111.11 + Pti.cil .11.1.11.11.2.11.1111111 + Bar.lyc ......1.....1.11......1. + Cla.cor 111111111111111111111111 + Vac.vit 113122132323412331223232 + Cla.cri 111111111111111111111111 + Emp.nig 111111122122312322111231 + Cla.bot ......1.....1.111...1.11 + Bet.pub ............1.....1..1.. + Cla.unc 111111111111131111112111 + Cla.def 11.111111111111111111111 + Dic.pol ..11.1..11..1.1111.11..1 + Pol.com ............111......11. + Led.pal ......1.....1.....1...11 + Pol.jun 1.111111111.111111.112.1 + Dic.fus 11111111111112111442.211 + Ple.sch 113111111111123333444455 + Vac.myr ......1..1..311..111..13 + Nep.arc .1...1.1........1....1.. + Dic.sp ......1....11...111133.1 + Des.fle 1....1......1.1...1..111 + Hyl.spl ................1....122 + sites species + 24 44 +scale: Hult > > ## Abundance values have such a wide range that they must be rescaled > ## or all abundances will not be shown in tabasco -> tabasco(decostand(varespec, "log"), clus) +> tabasco(decostand(varespec, "log"), dca) Warning: non-integer data: divided by smallest positive value -> ## reorder dendrogram by the first DCA axis -> clus <- as.dendrogram(clus) -> clus <- reorder(clus, scores(dca, choices=1, display="sites")) -> tabasco(decostand(varespec, "log"), clus) -Warning: non-integer data: divided by smallest positive value > +> ## Classification trees for species +> data(dune, dune.taxon) +> taxontree <- hclust(taxa2dist(dune.taxon)) +> plotree <- hclust(vegdist(dune), "average") +> ## Automatic reordering of clusters +> tabasco(dune, plotree, sp.ind = taxontree) +> ## No reordering of taxonomy +> tabasco(dune, plotree, sp.ind = taxontree, Colv = FALSE) +> ## Species cluster: most dissimilarity indices do a bad job when +> ## comparing rare and common species, but Raup-Crick makes sense +> sptree <- hclust(vegdist(t(dune), "raup"), "average") +> tabasco(dune, plotree, sptree) > > > @@ -8183,7 +8244,7 @@ > ### *

                                                > ### > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 104.54 1.972 107.111 0 0 +Time elapsed: 82.333 1.542 86.731 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sun Feb 17 08:27:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 08:27:12 +0100 (CET) Subject: [Vegan-commits] r2443 - pkg/vegan/man Message-ID: <20130217072712.EA643183E4D@r-forge.r-project.org> Author: jarioksa Date: 2013-02-17 08:27:12 +0100 (Sun, 17 Feb 2013) New Revision: 2443 Modified: pkg/vegan/man/cca.object.Rd Log: update description of cca.object Modified: pkg/vegan/man/cca.object.Rd =================================================================== --- pkg/vegan/man/cca.object.Rd 2013-02-17 07:05:38 UTC (rev 2442) +++ pkg/vegan/man/cca.object.Rd 2013-02-17 07:27:12 UTC (rev 2443) @@ -177,19 +177,25 @@ } } -\seealso{The description here provides a hacker's interface. For more - user friendly access to the \code{cca} object see +\seealso{The description here provides a hacker's interface. User + level functions for further analysis and handling of \code{cca} + objects are described in this section in \code{\link{cca}}. Also for + a hacker interface, it may be better to use following low level + functions to access the results: + \code{\link{scores.cca}} (which also scales results), + \code{\link{predict.cca}} (which can also use \code{newdata}), + \code{\link{fitted.cca}}, \code{\link{residuals.cca}}, \code{\link{alias.cca}}, \code{\link{coef.cca}}, - \code{\link{deviance.cca}}, \code{\link{predict.cca}}, - \code{\link{scores.cca}}, - \code{\link{summary.cca}}, \code{\link{vif.cca}}, - \code{\link{weights.cca}}, \code{\link{spenvcor}} or \code{rda} + \code{\link{model.frame.cca}}, \code{\link{model.matrix.cca}}, + \code{\link{deviance.cca}}, \code{\link{eigenvals.cca}}, + \code{\link{RsquareAdj.cca}}, + \code{\link{weights.cca}}, \code{\link{nobs.cca}}, or \code{rda} variants of these functions. You can use \code{\link{as.mlm}} to cast a \code{cca.object} into result of multiple response linear model (\code{\link{lm}}) in order to more easily find some statistics (which in principle could be directly found from the - \code{cca.object} as well). + \code{cca} object as well). This section in \code{\link{cca}} gives a more complete list of methods to handle the constrained ordination result object. From noreply at r-forge.r-project.org Sun Feb 17 08:28:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 08:28:05 +0100 (CET) Subject: [Vegan-commits] r2444 - pkg/vegan/tests/Examples Message-ID: <20130217072805.23A2D183E4D@r-forge.r-project.org> Author: jarioksa Date: 2013-02-17 08:28:04 +0100 (Sun, 17 Feb 2013) New Revision: 2444 Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: update tests to clean residuals Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-17 07:27:12 UTC (rev 2443) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-17 07:28:04 UTC (rev 2444) @@ -7803,7 +7803,7 @@ > ### Name: vegemite > ### Title: Display Compact Ordered Community Tables > ### Aliases: vegemite tabasco coverscale -> ### Keywords: print manip +> ### Keywords: print manip hplot > > ### ** Examples > @@ -8244,7 +8244,7 @@ > ### *
                                                > ### > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 82.333 1.542 86.731 0 0 +Time elapsed: 83.645 1.621 85.757 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sun Feb 17 15:05:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 15:05:43 +0100 (CET) Subject: [Vegan-commits] r2445 - in branches/2.0: R inst man Message-ID: <20130217140543.A52CE18490E@r-forge.r-project.org> Author: jarioksa Date: 2013-02-17 15:05:43 +0100 (Sun, 17 Feb 2013) New Revision: 2445 Modified: branches/2.0/R/wcmdscale.R branches/2.0/inst/ChangeLog branches/2.0/man/cca.Rd branches/2.0/man/cca.object.Rd branches/2.0/man/wcmdscale.Rd Log: merge r2432, 2443 (edit Rd) & 2434 (wcmdscale object) Modified: branches/2.0/R/wcmdscale.R =================================================================== --- branches/2.0/R/wcmdscale.R 2013-02-17 07:28:04 UTC (rev 2444) +++ branches/2.0/R/wcmdscale.R 2013-02-17 14:05:43 UTC (rev 2445) @@ -8,6 +8,9 @@ } if (add) .NotYetUsed("add") + ## Force eig=TRUE if add, x.ret or !missing(w) + if(add || x.ret || !missing(w)) + eig <- TRUE ZERO <- sqrt(.Machine$double.eps) if (!inherits(d, "dist")) { op <- options(warn = 2) Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-17 07:28:04 UTC (rev 2444) +++ branches/2.0/inst/ChangeLog 2013-02-17 14:05:43 UTC (rev 2445) @@ -2,6 +2,13 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ +Version 2.0-7 (opened February 17, 2013) + + * merge r2443: edit cca.object.Rd. + * merge r2434: return wcmdscale object always with non-default + arguments. + * merge r2432: edit cca.Rd. + Version 2.0-6 (released February 11, 2013) * merge 2420, 2425: cca cross references. Modified: branches/2.0/man/cca.Rd =================================================================== --- branches/2.0/man/cca.Rd 2013-02-17 07:28:04 UTC (rev 2444) +++ branches/2.0/man/cca.Rd 2013-02-17 14:05:43 UTC (rev 2445) @@ -105,9 +105,9 @@ frames). The formula can include a special term \code{Condition} for conditioning variables (``covariables'') ``partialled out'' before - analysis. So the following commands are equivalent: \code{cca(X, Y, - Z)}, \code{cca(X ~ Y + Condition(Z))}, where \code{Y} and \code{Z} - refer to constraints and conditions matrices respectively. + analysis. So the following commands are equivalent: + \code{cca(X, Y, Z)}, \code{cca(X ~ Y + Condition(Z))}, where \code{Y} + and \code{Z} refer to constraints and conditions matrices respectively. Constrained correspondence analysis is indeed a constrained method: CCA does not try to display all variation in the @@ -198,12 +198,12 @@ This help page describes two constrained ordination functions, \code{cca} and \code{rda}. A related method, distance-based redundancy analysis (dbRDA) is described separately - (\code{\link{capscale}}). All these function return similar objects + (\code{\link{capscale}}). All these functions return similar objects (described in \code{\link{cca.object}}). There are numerous support - functions that can used to access the result object. In the list - below, functions of type \code{cca} will handle all ordination - objects, and functions of \code{rda} only handle \code{rda} and - \code{\link{capscale}} results. + functions that can be used to access the result object. In the list + below, functions of type \code{cca} will handle all three constrained + ordination objects, and functions of \code{rda} only handle \code{rda} + and \code{\link{capscale}} results. The main plotting functions are \code{\link{plot.cca}} for all methods, and \code{\link{biplot.rda}} for RDA and dbRDA. However, Modified: branches/2.0/man/cca.object.Rd =================================================================== --- branches/2.0/man/cca.object.Rd 2013-02-17 07:28:04 UTC (rev 2444) +++ branches/2.0/man/cca.object.Rd 2013-02-17 14:05:43 UTC (rev 2445) @@ -177,19 +177,25 @@ } } -\seealso{The description here provides a hacker's interface. For more - user friendly access to the \code{cca} object see +\seealso{The description here provides a hacker's interface. User + level functions for further analysis and handling of \code{cca} + objects are described in this section in \code{\link{cca}}. Also for + a hacker interface, it may be better to use following low level + functions to access the results: + \code{\link{scores.cca}} (which also scales results), + \code{\link{predict.cca}} (which can also use \code{newdata}), + \code{\link{fitted.cca}}, \code{\link{residuals.cca}}, \code{\link{alias.cca}}, \code{\link{coef.cca}}, - \code{\link{deviance.cca}}, \code{\link{predict.cca}}, - \code{\link{scores.cca}}, - \code{\link{summary.cca}}, \code{\link{vif.cca}}, - \code{\link{weights.cca}}, \code{\link{spenvcor}} or \code{rda} + \code{\link{model.frame.cca}}, \code{\link{model.matrix.cca}}, + \code{\link{deviance.cca}}, \code{\link{eigenvals.cca}}, + \code{\link{RsquareAdj.cca}}, + \code{\link{weights.cca}}, \code{\link{nobs.cca}}, or \code{rda} variants of these functions. You can use \code{\link{as.mlm}} to cast a \code{cca.object} into result of multiple response linear model (\code{\link{lm}}) in order to more easily find some statistics (which in principle could be directly found from the - \code{cca.object} as well). + \code{cca} object as well). This section in \code{\link{cca}} gives a more complete list of methods to handle the constrained ordination result object. Modified: branches/2.0/man/wcmdscale.Rd =================================================================== --- branches/2.0/man/wcmdscale.Rd 2013-02-17 07:28:04 UTC (rev 2444) +++ branches/2.0/man/wcmdscale.Rd 2013-02-17 14:05:43 UTC (rev 2445) @@ -49,10 +49,11 @@ With default options, the function returns only a matrix of scores scaled by eigenvalues for all real axes. If the function is called - with \code{eig = TRUE} or \code{x.ret = TRUE}, the function returns an - object of class \code{"wcmdscale"} with \code{print}, \code{plot}, - \code{scores}, \code{\link{eigenvals}} and \code{\link{stressplot}} - methods, and described in section Value. } + with \code{eig = TRUE} or \code{x.ret = TRUE} or with weights + \code{w}, the function returns an object of class \code{"wcmdscale"} + with \code{print}, \code{plot}, \code{scores}, \code{\link{eigenvals}} + and \code{\link{stressplot}} methods, and described in section Value. + } \value{ If \code{eig = FALSE} and \code{x.ret = FALSE} (default), a matrix with \code{k} columns whose rows give the coordinates of the From noreply at r-forge.r-project.org Sun Feb 17 15:30:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 15:30:49 +0100 (CET) Subject: [Vegan-commits] r2446 - in branches/2.0: . R inst man Message-ID: <20130217143049.E5FA3184511@r-forge.r-project.org> Author: jarioksa Date: 2013-02-17 15:30:49 +0100 (Sun, 17 Feb 2013) New Revision: 2446 Added: branches/2.0/R/tabasco.R Modified: branches/2.0/NAMESPACE branches/2.0/R/vegemite.R branches/2.0/inst/ChangeLog branches/2.0/man/vegemite.Rd Log: merge 2431,3, 2435:2442: add tabasco Modified: branches/2.0/NAMESPACE =================================================================== --- branches/2.0/NAMESPACE 2013-02-17 14:05:43 UTC (rev 2445) +++ branches/2.0/NAMESPACE 2013-02-17 14:30:49 UTC (rev 2446) @@ -25,7 +25,7 @@ rankindex, rarecurve, rarefy, raupcrick, rda, renyiaccum, renyi, rrarefy, scores, showvarparts, simper, spandepth, spantree, specaccum, specnumber, specpool2vect, specpool, spenvcor, stepacross, stressplot, -swan, taxa2dist, taxondive, tolerance, treedist, treedive, treeheight, +swan, tabasco, taxa2dist, taxondive, tolerance, treedist, treedive, treeheight, tsallisaccum, tsallis, varpart, vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores, wcmdscale, wisconsin) Copied: branches/2.0/R/tabasco.R (from rev 2431, pkg/vegan/R/tabasco.R) =================================================================== --- branches/2.0/R/tabasco.R (rev 0) +++ branches/2.0/R/tabasco.R 2013-02-17 14:30:49 UTC (rev 2446) @@ -0,0 +1,129 @@ +### The function displays (ordered) heatmaps of community data. It +### copies vegemite() for handling 'use', 'sp.ind', 'site.ind' and +### 'select', but then switches to heatmap() to display the +### data. Unlike heatmap(), it does not insist on showing dendrograms, +### but only uses these for sites, and only if given as 'use'. + +`tabasco` <- + function (x, use, sp.ind = NULL, site.ind = NULL, + select, Rowv = TRUE, Colv = TRUE, ...) +{ + pltree <- sptree <- NA + if (!missing(use)) { + if (!is.list(use) && is.vector(use)) { + if (is.null(site.ind)) + site.ind <- order(use) + if (is.null(sp.ind)) + sp.ind <- order(wascores(use, x)) + } + else if (inherits(use, c("dendrogram", "hclust", "twins"))) { + if (inherits(use, "twins")) { + require(cluster) || stop("package cluster needed to handle 'use'") + } + if (!inherits(use, "dendrogram")) + use <- as.dendrogram(use) + if (!is.null(site.ind)) + stop("'site.ind' cannot be used with dendrogram") + ## Reorder tree if Rowv specified + if (isTRUE(Rowv)) { + ## order by first CA axis -- decorana() is fastest + tmp <- decorana(x, ira = 1) + use <- reorder(use, scores(tmp, dis="sites", choices = 1), + agglo.FUN = mean) + } else if (length(Rowv) > 1) { + ## Rowv is a vector + if (length(Rowv) != nrow(x)) + stop(gettextf("Rowv has length %d, but 'x' has %d rows", + length(Rowv), nrow(x))) + use <- reorder(use, Rowv, agglo.FUN = mean) + } + site.ind <- seq_len(nrow(x)) + names(site.ind) <- rownames(x) + site.ind <- site.ind[labels(use)] + if (is.null(sp.ind)) + sp.ind <- order(wascores(order(site.ind), x)) + pltree <- use + } + else if (is.list(use)) { + tmp <- scores(use, choices = 1, display = "sites") + if (is.null(site.ind)) + site.ind <- order(tmp) + if (is.null(sp.ind)) + sp.ind <- try(order(scores(use, choices = 1, + display = "species"))) + if (inherits(sp.ind, "try-error")) + sp.ind <- order(wascores(tmp, x)) + } + else if (is.matrix(use)) { + tmp <- scores(use, choices = 1, display = "sites") + if (is.null(site.ind)) + site.ind <- order(tmp) + if (is.null(sp.ind)) + sp.ind <- order(wascores(tmp, x)) + } + } + ## see if sp.ind is a dendrogram or hclust tree + if (inherits(sp.ind, c("hclust", "dendrogram", "twins"))) { + if (inherits(sp.ind, "twins")) + require("cluster") || stop("package cluster needed to handle 'sp.ind'") + if (!inherits(sp.ind, "dendrogram")) + sp.ind <- as.dendrogram(sp.ind) + sptree <- sp.ind + ## Consider reordering species tree + if (isTRUE(Colv) && !is.null(site.ind)) { + sptree <- reorder(sptree, wascores(order(site.ind), x), + agglo.FUN = mean) + } else if (length(Colv) > 1) { + if (length(Colv) != ncol(x)) + stop(gettextf("Colv has length %d, but 'x' has %d columns", + length(Colv), ncol(x))) + sptree <- reorder(sptree, Colv, agglo.FUN = mean) + } + sp.ind <- seq_len(ncol(x)) + names(sp.ind) <- colnames(x) + sp.ind <- sp.ind[labels(sptree)] + ## reverse: origin in the upper left corner + sptree <- rev(sptree) + } + if (!is.null(sp.ind) && is.logical(sp.ind)) + sp.ind <- (1:ncol(x))[sp.ind] + if (!is.null(site.ind) && is.logical(site.ind)) + site.ind <- (1:nrow(x))[site.ind] + if (is.null(sp.ind)) + sp.ind <- 1:ncol(x) + if (is.null(site.ind)) + site.ind <- 1:nrow(x) + if (!missing(select)) { + if (!is.na(pltree)) + stop("sites cannot be 'select'ed with dendrograms or hclust trees") + if (!is.logical(select)) + select <- sort(site.ind) %in% select + stake <- colSums(x[select, , drop = FALSE]) > 0 + site.ind <- site.ind[select[site.ind]] + site.ind <- site.ind[!is.na(site.ind)] + } + else { + stake <- colSums(x[site.ind, ]) > 0 + } + sp.ind <- sp.ind[stake[sp.ind]] + ## heatmap will reorder items by dendrogram so that we need to + ## give indices in the unsorted order if rows or columns have a + ## dendrogram + if (is.na(pltree[1])) + rind <- site.ind + else + rind <- sort(site.ind) + if (is.na(sptree[1])) + ## reverse: origin in the upper left corner + cind <- rev(sp.ind) + else + cind <- sort(sp.ind) + ## we assume t() changes data.frame to a matrix + x <- t(x[rind, cind]) + sp.nam <- rownames(x) + sp.len <- max(nchar(sp.nam)) + heatmap((max(x) - x), Rowv = sptree, Colv = pltree, + scale = "none", ...) + out <- list(sites = site.ind, species = sp.ind) + invisible(out) +} Modified: branches/2.0/R/vegemite.R =================================================================== --- branches/2.0/R/vegemite.R 2013-02-17 14:05:43 UTC (rev 2445) +++ branches/2.0/R/vegemite.R 2013-02-17 14:30:49 UTC (rev 2446) @@ -1,4 +1,4 @@ -"vegemite" <- +`vegemite` <- function (x, use, scale, sp.ind = NULL, site.ind = NULL, zero = ".", select, ...) { @@ -9,7 +9,11 @@ if (is.null(sp.ind)) sp.ind <- order(wascores(use, x)) } - else if (inherits(use, "hclust")) { + else if (inherits(use, c("hclust", "twins"))) { + if (inherits(use, "twins")) { + require(cluster) || stop("package cluster needed for 'use'") + use <- as.hclust(use) + } if (is.null(site.ind)) site.ind <- use$order if (is.null(sp.ind)) Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-02-17 14:05:43 UTC (rev 2445) +++ branches/2.0/inst/ChangeLog 2013-02-17 14:30:49 UTC (rev 2446) @@ -8,6 +8,7 @@ * merge r2434: return wcmdscale object always with non-default arguments. * merge r2432: edit cca.Rd. + * merge r2431,2433,2435 thru 2442: add tabasco(). Version 2.0-6 (released February 11, 2013) Modified: branches/2.0/man/vegemite.Rd =================================================================== --- branches/2.0/man/vegemite.Rd 2013-02-17 14:05:43 UTC (rev 2445) +++ branches/2.0/man/vegemite.Rd 2013-02-17 14:30:49 UTC (rev 2446) @@ -1,71 +1,108 @@ \name{vegemite} \alias{vegemite} +\alias{tabasco} \alias{coverscale} -\title{Prints a Compact, Ordered Vegetation Table } +\title{Display Compact Ordered Community Tables } \description{ - The function prints a compact vegetation table, where species are - rows, and each site takes only one column without spaces. The - vegetation table can be ordered by explicit indexing, by environmental - variables or results from an ordination or cluster analysis. + Functions \code{vegemite} and \code{tabasco} display compact + community tables. Function \code{vegemite} prints text tables where + species are rows, and each site takes only one column without + spaces. Function \code{tabasco} provides interface for + \code{\link{heatmap}} for a colour \code{\link{image}} of the + data. The community table can be ordered by explicit indexing, by + environmental variables or results from an ordination or cluster + analysis. } \usage{ vegemite(x, use, scale, sp.ind, site.ind, zero=".", select ,...) +tabasco(x, use, sp.ind = NULL, site.ind = NULL, select, + Rowv = TRUE, Colv = TRUE, ...) coverscale(x, scale=c("Braun.Blanquet", "Domin", "Hult", "Hill", "fix","log"), maxabund) } \arguments{ - \item{x}{Vegetation data. } + \item{x}{Community data. } \item{use}{Either a vector, or an object from \code{cca}, \code{decorana} \emph{etc.} or \code{hclust} or a \code{\link{dendrogram}} for ordering sites and species.} - \item{sp.ind}{Species indices. } - \item{site.ind}{Site indices. } + \item{sp.ind, site.ind}{Species and site indices. In \code{tabasco}, + these can also be \code{\link{hclust}} tree, + \code{\link[cluster]{agnes}} clusterings or + \code{\link{dendrogram}}s. } \item{zero}{Character used for zeros. } \item{select}{Select a subset of sites. This can be a logical vector (\code{TRUE} for selected sites), or a vector of indices of selected sites. The order of indices does not influence results, but you must specify \code{use} or \code{site.ind} to reorder sites. - } + } + \item{Rowv, Colv}{Re-order dendrograms for the rows (sites) or + columns (species) of \code{x}. If the \code{Rowv = TRUE}, row + dendrograms are ordered by the first axis of correspondence + analysis, and when \code{Colv = TRUE} column dendrograms by the + weighted average (\code{\link{wascores}}) of the row order. + Alternatively, the arguments can be vectors that are used to + reorder the dendrogram. } \item{scale}{Cover scale used (can be abbreviated).} \item{maxabund}{Maximum abundance used with \code{scale = "log"}. Data maximum in the \code{select}ed subset will be used if this is missing.} - \item{...}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}).} + \item{\dots}{Arguments passed to \code{coverscale} (i.e., \code{maxabund}) in + \code{vegemite} and to \code{\link{heatmap}} in \code{tabasco}.} } \details{ - The function prints a traditional vegetation table. - Unlike in ordinary data matrices, species are used as rows and sites - as columns. The table is printed in compact form: only one character + The function \code{vegemite} prints a traditional community table. + The display is transposed, so that species are in rows and sites in + columns. The table is printed in compact form: only one character can be used for abundance, and there are no spaces between columns. Species with no occurrences are dropped from the table. - The parameter \code{use} can be a vector or an object from - \code{\link{hclust}}, a \code{\link{dendrogram}} or any ordination - result recognized by \code{\link{scores}} (all ordination methods in - \pkg{vegan} and some of those not in \pkg{vegan}). - If \code{use} is a vector, it is used - for ordering sites. If \code{use} is an object from ordination, both - sites and species are arranged by the first axis. - When \code{use} is an - object from \code{\link{hclust}} or a \code{\link{dendrogram}}, the - sites are ordered similarly - as in the cluster dendrogram. - If ordination methods provide species scores, these are used for - ordering species. In all cases where species scores are missing, - species are ordered by their weighted averages (\code{\link{wascores}}) - on site scores. There is no natural, unique ordering in hierarchic - clustering, but in some cases species are still nicely ordered (please - note that you can \code{\link{reorder.dendrogram}} to have such a - natural order). - Alternatively, species and sites can be ordered explicitly giving - their indices or names in parameters \code{sp.ind} and - \code{site.ind}. If these are given, they take precedence over - \code{use}. A subset of sites can be displayed using argument - \code{select}, but this cannot be used to order sites, but you still - must give \code{use} or \code{site.ind}. + Function \code{tabasco} produces a similar table as \code{vegemite} + using \code{\link{heatmap}}, where abundances are coded by + colours. The function can also display dendrograms for sites + (columns) or species if these are given as an argument (\code{use} + for sites, \code{sp.ind} for species). + The parameter \code{use} will be used to re-order output. The + \code{use} can be a vector or an object from \code{\link{hclust}} or + \code{\link[cluster]{agnes}}, a \code{\link{dendrogram}} or any + ordination result recognized by \code{\link{scores}} (all ordination + methods in \pkg{vegan} and some of those not in \pkg{vegan}). The + \code{\link{hclust}}, \code{\link[cluster]{agnes}} and + \code{\link{dendrogram}} must be for sites. The dendrogram is + displayed above the sites in \code{tabasco}, but is not shown in + \code{vegemite}. No dendrogram for species is displayed, except + when given in \code{sp.ind}. + + If \code{use} is a vector, it is used for ordering sites. If + \code{use} is an object from ordination, both sites and species are + arranged by the first axis (provided that results are available both + also for species). When \code{use} is an object from + \code{\link{hclust}}, \code{\link[cluster]{agnes}} or a + \code{\link{dendrogram}}, the sites are ordered similarly as in the + cluster dendrogram. Function \code{tabasco} re-orders the + dendrogram if \code{Rowv = TRUE} or \code{Rowv} is a vector. Such + re-ordering is not available for \code{vegemite}, but it can be done + by hand using \code{\link{reorder.dendrogram}}. In all cases where + species scores are missing, species are ordered by their weighted + averages (\code{\link{wascores}}) on site order. + + Species and sites can be ordered explicitly giving their indices or + names in parameters \code{sp.ind} and \code{site.ind}. If these are + given, they take precedence over \code{use}. A subset of sites can + be displayed using argument \code{select}, but this cannot be used + to order sites, but you still must give \code{use} or + \code{site.ind}. However, \code{tabasco} makes two exceptions: + \code{site.ind} and \code{select} cannot be used when \code{use} is + a dendrogram (clustering result). In addition, the \code{sp.ind} can + be an \code{\link{hclust}} tree, \code{\link[cluster]{agnes}} + clustering or a \code{\link{dendrogram}}, and in that case the + dendrogram is plotted on the left side of the + \code{\link{heatmap}}. Phylogenetic trees cannot be directly used, + \code{\link[ape]{as.hclust.phylo}} (package \pkg{ape}) can transform + these to \code{\link{hclust}} trees. + If \code{scale} is given, \code{vegemite} calls \code{coverscale} to transform percent cover scale or some other scales into traditional class scales used in @@ -88,13 +125,14 @@ 10 with \code{X} and positive values below 1 with \code{+}. } \value{ - The function is used mainly to print a table, but it returns + The functions are used mainly to display a table, but they return (invisibly) a list with items: \item{species}{Ordered species indices} \item{sites}{Ordered site indices} + These items can be used as arguments \code{sp.ind} and \code{site.ind} - to reproduce the table. In addition to the proper table, the function + to reproduce the table. In addition to the proper table, \code{vegemite} prints the numbers of species and sites and the name of the used cover scale at the end. } @@ -106,15 +144,19 @@ } \author{Jari Oksanen} -\seealso{\code{\link{cut}} and \code{\link{approx}} for making your own - `cover scales', \code{\link{wascores}} for weighted averages. - } +\seealso{\code{\link{cut}} and \code{\link{approx}} for making your + own \sQuote{cover scales} for \code{vegemite}. Function + \code{tabasco} is based on \code{\link{heatmap}} which in turn is + based on \code{\link{image}}. Both functions order species with + weighted averages using \code{\link{wascores}}. } -\note{ This function was called \code{vegetab} in older versions of - \code{vegan}. The new name was chosen because the output is so - compact (and to avoid confusion with the \code{vegtab} function in the - \pkg{labdsv} package). - } +\note{ + + The name \code{vegemite} was chosen because the output is so + compact, and the \code{tabasco} because it is just as compact, but + uses heat colours. + +} \examples{ data(varespec) ## Print only more common species @@ -127,9 +169,31 @@ clus <- hclust(vegdist(varespec)) cl <- cutree(clus, 3) sel <- vegemite(varespec, use=dca, select = cl == 3, scale="Br") -# Re-create previous +## Re-create previous vegemite(varespec, sp=sel$sp, site=sel$site, scale="Hult") +## Re-order clusters by ordination +clus <- as.dendrogram(clus) +clus <- reorder(clus, scores(dca, choices=1, display="sites"), agglo.FUN = mean) +vegemite(varespec, clus, scale = "Hult") + +## Abundance values have such a wide range that they must be rescaled +## or all abundances will not be shown in tabasco +tabasco(decostand(varespec, "log"), dca) + +## Classification trees for species +data(dune, dune.taxon) +taxontree <- hclust(taxa2dist(dune.taxon)) +plotree <- hclust(vegdist(dune), "average") +## Automatic reordering of clusters +tabasco(dune, plotree, sp.ind = taxontree) +## No reordering of taxonomy +tabasco(dune, plotree, sp.ind = taxontree, Colv = FALSE) +## Species cluster: most dissimilarity indices do a bad job when +## comparing rare and common species, but Raup-Crick makes sense +sptree <- hclust(vegdist(t(dune), "raup"), "average") +tabasco(dune, plotree, sptree) } -\keyword{ print } -\keyword{ manip } +\keyword{print} +\keyword{manip} +\keyword{hplot} From noreply at r-forge.r-project.org Tue Feb 19 11:11:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 19 Feb 2013 11:11:50 +0100 (CET) Subject: [Vegan-commits] r2447 - in pkg/vegan: R inst man Message-ID: <20130219101150.6656618083B@r-forge.r-project.org> Author: jarioksa Date: 2013-02-19 11:11:50 +0100 (Tue, 19 Feb 2013) New Revision: 2447 Modified: pkg/vegan/R/metaMDSiter.R pkg/vegan/inst/ChangeLog pkg/vegan/man/metaMDS.Rd Log: expose argument 'maxit' so that users can set the no. of iterations in metaMDS Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2013-02-17 14:30:49 UTC (rev 2446) +++ pkg/vegan/R/metaMDSiter.R 2013-02-19 10:11:50 UTC (rev 2447) @@ -1,6 +1,6 @@ `metaMDSiter` <- function (dist, k = 2, trymax = 20, trace = 1, plot = FALSE, - previous.best, engine = "monoMDS", + previous.best, engine = "monoMDS", maxit = 200, parallel = getOption("mc.cores"), ...) { engine <- match.arg(engine, c("monoMDS", "isoMDS")) @@ -50,8 +50,10 @@ } else { ## no previous.best: start with cmdscale s0 <- switch(engine, - "monoMDS" = monoMDS(dist, y = cmdscale(dist, k = k), k = k, ...), - "isoMDS" = isoMDS(dist, k = k, trace = isotrace)) + "monoMDS" = monoMDS(dist, y = cmdscale(dist, k = k), k = k, + maxit = maxit, ...), + "isoMDS" = isoMDS(dist, k = k, trace = isotrace, + maxit = maxit)) } if (trace) cat("Run 0 stress", s0$stress, "\n") @@ -83,25 +85,26 @@ mclapply(1:nclus, function(i) switch(engine, "monoMDS" = monoMDS(dist, init[,,i], k = k, - maxit = 200, ...), + maxit = maxit, ...), "isoMDS" = isoMDS(dist, init[,,i], k = k, - maxit = 200, tol = 1e-07, trace = isotrace)), + maxit = maxit, tol = 1e-07, + trace = isotrace)), mc.cores = parallel) } else { stry <- parLapply(parallel, 1:nclus, function(i) switch(engine, "monoMDS" = monoMDS(dist, init[,,i], k = k, - maxit = 200, ...), + maxit = maxit, ...), "isoMDS" = isoMDS(dist, init[,,i], k = k, - maxit = 200, tol = 1e-07, trace = isotrace))) + maxit = maxit, tol = 1e-07, trace = isotrace))) } } else { stry <- list(switch(engine, "monoMDS" = monoMDS(dist, init[,,1], k = k, - maxit = 200, ...), + maxit = maxit, ...), "isoMDS" = isoMDS(dist, init[,,1], k = k, - maxit = 200, tol = 1e-07, trace = isotrace))) + maxit = maxit, tol = 1e-07, trace = isotrace))) } ## analyse results of 'nclus' tries for (i in 1:nclus) { Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-17 14:30:49 UTC (rev 2446) +++ pkg/vegan/inst/ChangeLog 2013-02-19 10:11:50 UTC (rev 2447) @@ -7,6 +7,10 @@ * New version opened with the release of vegan_2.0-6 on February 11, 2013. + * metaMDS: exposed argument 'maxit' in metaMDSiter() so that users + can set the number of iterations in monoMDS() or isoMDS(). After a + wish by Jon Bakker, Univ Washington (U.S.A.). + * tabasco: a sister function of vegemite() to display a compact community table using heatmap(). Both vegemite() and tabasco() can handle cluster::agnes() trees. Modified: pkg/vegan/man/metaMDS.Rd =================================================================== --- pkg/vegan/man/metaMDS.Rd 2013-02-17 14:30:49 UTC (rev 2446) +++ pkg/vegan/man/metaMDS.Rd 2013-02-19 10:11:50 UTC (rev 2447) @@ -41,7 +41,8 @@ noshare = TRUE, trace = 1, commname, zerodist = "ignore", distfun = vegdist, ...) metaMDSiter(dist, k = 2, trymax = 20, trace = 1, plot = FALSE, - previous.best, engine = "monoMDS", parallel = getOption("mc.cores"), ...) + previous.best, engine = "monoMDS", maxit = 200, + parallel = getOption("mc.cores"), ...) initMDS(x, k=2) postMDS(X, dist, pc=TRUE, center=TRUE, halfchange, threshold=0.8, nthreshold=10, plot=FALSE, ...) @@ -120,6 +121,10 @@ \code{dist} object and accepting argument \code{method} can be used (but some extra arguments may cause name conflicts).} + \item{maxit}{Maximum number of iterations in the single NMDS run; + passed to the \code{engine} function \code{\link{monoMDS}} or + \code{\link[MASS]{isoMDS}}.} + \item{parallel}{Number of parallel processes or a predefined socket cluster. If you use pre-defined socket clusters (say, \code{clus}), you must issue \code{clusterEvalQ(clus, From noreply at r-forge.r-project.org Wed Feb 20 08:44:08 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 08:44:08 +0100 (CET) Subject: [Vegan-commits] r2448 - in pkg/vegan: R inst Message-ID: <20130220074408.1F31C181269@r-forge.r-project.org> Author: jarioksa Date: 2013-02-20 08:44:07 +0100 (Wed, 20 Feb 2013) New Revision: 2448 Modified: pkg/vegan/R/metaMDSiter.R pkg/vegan/R/print.monoMDS.R pkg/vegan/inst/ChangeLog Log: metaMDS(..., trace = 2) prints convergence info with engine = 'monoMDS' Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2013-02-19 10:11:50 UTC (rev 2447) +++ pkg/vegan/R/metaMDSiter.R 2013-02-20 07:44:07 UTC (rev 2448) @@ -13,7 +13,17 @@ RMSELIM <- 0.005 SOL <- FALSE converged <- FALSE + ## set tracing for engines isotrace <- max(0, trace - 1) + monotrace <- engine == "monoMDS" && trace > 1 + monostop <- function(mod) { + lab <- switch(mod$icause, + "no. of iterations >= maxit", + "stress < smin", + "change of stress < sratmax", + "scale factor of the gradient < sfgrmin") + cat(" ", mod$iters, "iterations: ", lab, "\n") + } ## Previous best or initial configuration if (!missing(previous.best) && !is.null(previous.best)) { ## check if previous.best is from metaMDS or isoMDS @@ -57,6 +67,8 @@ } if (trace) cat("Run 0 stress", s0$stress, "\n") + if (monotrace) + monostop(s0) tries <- 0 ## Prepare for parallel processing if (is.null(parallel) && getRversion() >= "2.15.0") @@ -109,9 +121,10 @@ ## analyse results of 'nclus' tries for (i in 1:nclus) { tries <- tries + 1 - if (trace) { + if (trace) cat("Run", tries, "stress", stry[[i]]$stress, "\n") - } + if (monotrace) + monostop(stry[[i]]) if ((s0$stress - stry[[i]]$stress) > -EPS) { pro <- procrustes(s0, stry[[i]], symmetric = TRUE) if (plot && k > 1) Modified: pkg/vegan/R/print.monoMDS.R =================================================================== --- pkg/vegan/R/print.monoMDS.R 2013-02-19 10:11:50 UTC (rev 2447) +++ pkg/vegan/R/print.monoMDS.R 2013-02-20 07:44:07 UTC (rev 2448) @@ -31,10 +31,10 @@ cat(", rotated to principal components") cat("\n") stoplab <- switch(x$icause, - "Maximum number of iteration reached", - "Stress nearly zero", - "Stress nearly unchanged", - "Scale factor of gradient nearly zero") + "Maximum number of iterations (maxit) reached", + "Stress nearly zero (< smin)", + "Stress nearly unchanged (change < sratmax)", + "Scale factor of gradient nearly zero (< sfgrmin)") cat("Stopped after ", x$iters, " iterations: ", stoplab, "\n", sep="") invisible(x) } Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-19 10:11:50 UTC (rev 2447) +++ pkg/vegan/inst/ChangeLog 2013-02-20 07:44:07 UTC (rev 2448) @@ -8,8 +8,10 @@ 11, 2013. * metaMDS: exposed argument 'maxit' in metaMDSiter() so that users - can set the number of iterations in monoMDS() or isoMDS(). After a - wish by Jon Bakker, Univ Washington (U.S.A.). + can set the number of iterations in monoMDS() or isoMDS(). + metaMDS(..., trace = 2) show the stopping criterion used in with + engine = "monoMDS". After wishes by Jon Bakker, Univ Washington + (U.S.A.). * tabasco: a sister function of vegemite() to display a compact community table using heatmap(). Both vegemite() and tabasco() can From noreply at r-forge.r-project.org Wed Feb 20 08:51:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 08:51:23 +0100 (CET) Subject: [Vegan-commits] r2449 - in pkg/vegan: R man Message-ID: <20130220075123.26509183C62@r-forge.r-project.org> Author: jarioksa Date: 2013-02-20 08:51:22 +0100 (Wed, 20 Feb 2013) New Revision: 2449 Modified: pkg/vegan/R/metaMDSiter.R pkg/vegan/R/print.monoMDS.R pkg/vegan/man/monoMDS.Rd Log: >, not < Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2013-02-20 07:44:07 UTC (rev 2448) +++ pkg/vegan/R/metaMDSiter.R 2013-02-20 07:51:22 UTC (rev 2449) @@ -20,7 +20,7 @@ lab <- switch(mod$icause, "no. of iterations >= maxit", "stress < smin", - "change of stress < sratmax", + "stress ratio > sratmax", "scale factor of the gradient < sfgrmin") cat(" ", mod$iters, "iterations: ", lab, "\n") } Modified: pkg/vegan/R/print.monoMDS.R =================================================================== --- pkg/vegan/R/print.monoMDS.R 2013-02-20 07:44:07 UTC (rev 2448) +++ pkg/vegan/R/print.monoMDS.R 2013-02-20 07:51:22 UTC (rev 2449) @@ -33,7 +33,7 @@ stoplab <- switch(x$icause, "Maximum number of iterations (maxit) reached", "Stress nearly zero (< smin)", - "Stress nearly unchanged (change < sratmax)", + "Stress nearly unchanged (ratio > sratmax)", "Scale factor of gradient nearly zero (< sfgrmin)") cat("Stopped after ", x$iters, " iterations: ", stoplab, "\n", sep="") invisible(x) Modified: pkg/vegan/man/monoMDS.Rd =================================================================== --- pkg/vegan/man/monoMDS.Rd 2013-02-20 07:44:07 UTC (rev 2448) +++ pkg/vegan/man/monoMDS.Rd 2013-02-20 07:51:22 UTC (rev 2449) @@ -56,8 +56,8 @@ \item{smin, sfgrmin, sratmax}{Convergence criteria: iterations stop when stress drops below \code{smin}, scale factor of the gradient - drops below \code{sfgrmin}, or stress ratio goes over - \code{sratmax} (but is still \eqn{< 1}).} + drops below \code{sfgrmin}, or stress ratio between two iterations + goes over \code{sratmax} (but is still \eqn{< 1}).} \item{x}{A \code{monoMDS} result.} From noreply at r-forge.r-project.org Wed Feb 20 17:34:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 17:34:18 +0100 (CET) Subject: [Vegan-commits] r2450 - pkg/vegan/tests/Examples Message-ID: <20130220163418.F139F180597@r-forge.r-project.org> Author: jarioksa Date: 2013-02-20 17:34:18 +0100 (Wed, 20 Feb 2013) New Revision: 2450 Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: Adapt tests to revs 2448, 2449 R-to-be-3.0.0 changes something in random number generation so that all permutation-based tests will change. This update was made on R 2.15.2. Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-20 07:51:22 UTC (rev 2449) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-02-20 16:34:18 UTC (rev 2450) @@ -3783,7 +3783,7 @@ Stress: 0.07596768 Stress type 1, weak ties Scores scaled to unit root mean square, rotated to principal components -Stopped after 72 iterations: Stress nearly unchanged +Stopped after 72 iterations: Stress nearly unchanged (ratio > sratmax) > plot(m) > > @@ -4908,7 +4908,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.45 total = 7.45 @@ -4924,7 +4924,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 6.12 total = 7.12 @@ -5092,7 +5092,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.93 total = 9.93 @@ -5105,7 +5105,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 7.75 total = 8.75 @@ -5118,7 +5118,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 8.9 total = 9.9 @@ -7692,7 +7692,7 @@ Formula: y ~ s(x1, x2, k = knots) - + Estimated degrees of freedom: 2 total = 3 @@ -8244,7 +8244,7 @@ > ### *
                                                > ### > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 83.645 1.621 85.757 0 0 +Time elapsed: 84.383 1.68 86.786 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Fri Feb 22 10:22:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 22 Feb 2013 10:22:06 +0100 (CET) Subject: [Vegan-commits] r2451 - in pkg/vegan: . R inst man Message-ID: <20130222092206.0C131184EEA@r-forge.r-project.org> Author: jarioksa Date: 2013-02-22 10:22:05 +0100 (Fri, 22 Feb 2013) New Revision: 2451 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/specaccum.R pkg/vegan/inst/ChangeLog pkg/vegan/man/specaccum.Rd Log: resurrect weights for specaccum that were removed in r1606 on Thu, 26 May 2011 Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-02-20 16:34:18 UTC (rev 2450) +++ pkg/vegan/DESCRIPTION 2013-02-22 09:22:05 UTC (rev 2451) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-26 -Date: February 11, 2013 +Version: 2.1-27 +Date: February 22, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: pkg/vegan/R/specaccum.R =================================================================== --- pkg/vegan/R/specaccum.R 2013-02-20 16:34:18 UTC (rev 2450) +++ pkg/vegan/R/specaccum.R 2013-02-22 09:22:05 UTC (rev 2451) @@ -1,7 +1,9 @@ `specaccum` <- function (comm, method = "exact", permutations = 100, conditioned=TRUE, - gamma="jack1", ...) + gamma="jack1", w = NULL, ...) { + if (!is.null(w) && !(method %in% c("random", "collector"))) + stop(gettextf("weights 'w' can be only used with methods 'random' and 'collector'")) x <- comm x <- as.matrix(x) x <- x[, colSums(x) > 0, drop=FALSE] @@ -22,11 +24,16 @@ message("No actual accumulation since only 1 site provided") switch(method, collector = { sites <- 1:n + weights <- cumsum(w) specaccum <- accumulator(x, sites) }, random = { perm <- array(dim = c(n, permutations)) + if (!is.null(w)) + weights <- array(dim = c(n, permutations)) for (i in 1:permutations) { - perm[, i] <- accumulator(x, sample(n)) + perm[, i] <- accumulator(x, ord <- sample(n)) + if(!is.null(w)) + weights[,i] <- cumsum(w[ord]) } sites <- 1:n specaccum <- apply(perm, 1, mean) @@ -87,6 +94,8 @@ }) out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm) + if (!is.null(weights)) + out$weights <- weights if (method == "rarefaction") out$individuals <- ind class(out) <- "specaccum" Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-20 16:34:18 UTC (rev 2450) +++ pkg/vegan/inst/ChangeLog 2013-02-22 09:22:05 UTC (rev 2451) @@ -2,6 +2,17 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ +Version 2.1-27 (opened Februray 22, 2013) + + * specaccum: gained argument 'w' for weights to give the sampling + effort. This resurrects a feature that was introduced in r1505 (22 + Feb 2011) and 1507, and removed in r1606 (26 May 2011). It seems + that BiodiversityR::balanced.specaccum() provides the same feature + but we still try it here. The feature was resurrected after a + user query by Bastien M?rigot (Univ Montpellier II). The working + of the new argument is still untested with specaccum() support + functions. + Version 2.1-26 (opened February 11, 2013) * New version opened with the release of vegan_2.0-6 on February Modified: pkg/vegan/man/specaccum.Rd =================================================================== --- pkg/vegan/man/specaccum.Rd 2013-02-20 16:34:18 UTC (rev 2450) +++ pkg/vegan/man/specaccum.Rd 2013-02-22 09:22:05 UTC (rev 2451) @@ -17,7 +17,7 @@ } \usage{ specaccum(comm, method = "exact", permutations = 100, - conditioned =TRUE, gamma = "jack1", ...) + conditioned =TRUE, gamma = "jack1", w = NULL, ...) \method{plot}{specaccum}(x, add = FALSE, ci = 2, ci.type = c("bar", "line", "polygon"), col = par("fg"), ci.col = col, ci.lty = 1, xlab, ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) @@ -43,7 +43,9 @@ \item{conditioned}{ Estimation of standard deviation is conditional on the empirical dataset for the exact SAC} \item{gamma}{Method for estimating the total extrapolated number of species in the - survey area by function \code{\link{specpool}}} + survey area by function \code{\link{specpool}}} + \item{w}{Weights giving the sampling effort (an experimental feature + that may be removed).} \item{x}{A \code{specaccum} result object} \item{add}{Add to an existing graph.} \item{ci}{Multiplier used to get confidence intervals from standard From noreply at r-forge.r-project.org Tue Feb 26 16:58:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Feb 2013 16:58:42 +0100 (CET) Subject: [Vegan-commits] r2452 - in pkg/vegan: R inst man Message-ID: <20130226155842.2AD871845CF@r-forge.r-project.org> Author: jarioksa Date: 2013-02-26 16:58:41 +0100 (Tue, 26 Feb 2013) New Revision: 2452 Modified: pkg/vegan/R/points.cca.R pkg/vegan/R/text.cca.R pkg/vegan/inst/ChangeLog pkg/vegan/man/plot.cca.Rd Log: plot/text.cca gained arg 'axis.bp = TRUE' to suppress drawing axes for biplot arrows Modified: pkg/vegan/R/points.cca.R =================================================================== --- pkg/vegan/R/points.cca.R 2013-02-22 09:22:05 UTC (rev 2451) +++ pkg/vegan/R/points.cca.R 2013-02-26 15:58:41 UTC (rev 2452) @@ -1,6 +1,6 @@ `points.cca` <- function (x, display = "sites", choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, ...) + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) { formals(arrows) <- c(formals(arrows), alist(... = )) if (length(display) > 1) @@ -28,10 +28,12 @@ arrows(0, 0, pts[, 1], pts[, 2], length = head.arrow, ...) pts <- pts * 1.1 - axis(3, at = c(-arrow.mul, 0, arrow.mul), labels = rep("", - 3)) - axis(4, at = c(-arrow.mul, 0, arrow.mul), labels = c(-1, - 0, 1)) + if (axis.bp) { + axis(3, at = c(-arrow.mul, 0, arrow.mul), + labels = rep("", 3)) + axis(4, at = c(-arrow.mul, 0, arrow.mul), + labels = c(-1, 0, 1)) + } return(invisible()) } points(pts, ...) Modified: pkg/vegan/R/text.cca.R =================================================================== --- pkg/vegan/R/text.cca.R 2013-02-22 09:22:05 UTC (rev 2451) +++ pkg/vegan/R/text.cca.R 2013-02-26 15:58:41 UTC (rev 2452) @@ -1,6 +1,6 @@ `text.cca` <- function (x, display = "sites", labels, choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, ...) + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) { formals(arrows) <- c(formals(arrows), alist(... = )) if (length(display) > 1) @@ -30,10 +30,12 @@ arrows(0, 0, pts[, 1], pts[, 2], length = head.arrow, ...) pts <- pts * 1.1 - axis(3, at = c(-arrow.mul, 0, arrow.mul), labels = rep("", - 3)) - axis(4, at = c(-arrow.mul, 0, arrow.mul), labels = c(-1, - 0, 1)) + if (axis.bp) { + axis(side = 3, at = c(-arrow.mul, 0, arrow.mul), + labels = rep("", 3)) + axis(side = 4, at = c(-arrow.mul, 0, arrow.mul), + labels = c(-1, 0, 1)) + } } text(pts, labels = rownames(pts), ...) invisible() Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-22 09:22:05 UTC (rev 2451) +++ pkg/vegan/inst/ChangeLog 2013-02-26 15:58:41 UTC (rev 2452) @@ -12,6 +12,10 @@ user query by Bastien M?rigot (Univ Montpellier II). The working of the new argument is still untested with specaccum() support functions. + + * text.cca, points.cca: gained argument 'axis.bp' (defaults TRUE) + to suppress drawing axes for scaled biplot arrows. Only effective + if 'bp' scores were requested. Version 2.1-26 (opened February 11, 2013) Modified: pkg/vegan/man/plot.cca.Rd =================================================================== --- pkg/vegan/man/plot.cca.Rd 2013-02-22 09:22:05 UTC (rev 2451) +++ pkg/vegan/man/plot.cca.Rd 2013-02-26 15:58:41 UTC (rev 2452) @@ -21,9 +21,9 @@ \method{plot}{cca}(x, choices = c(1, 2), display = c("sp", "wa", "cn"), scaling = 2, type, xlim, ylim, const, ...) \method{text}{cca}(x, display = "sites", labels, choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, ...) + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) \method{points}{cca}(x, display = "sites", choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, ...) + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) \method{scores}{cca}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, ...) \method{scores}{rda}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, const, ...) @@ -74,6 +74,7 @@ \samp{decision-vegan.pdf} with \code{\link{vegandocs}} for details and discussion). If \code{const} is a vector of two items, the first is used for species, and the second item for site scores.} + \item{axis.bp}{Draw \code{\link{axis}} for biplot arrows.} \item{axes}{Number of axes in summaries.} \item{digits}{Number of digits in output.} \item{n, head, tail}{Number of rows printed from the head and tail of From noreply at r-forge.r-project.org Wed Feb 27 14:08:24 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Feb 2013 14:08:24 +0100 (CET) Subject: [Vegan-commits] r2453 - in pkg/vegan: R inst Message-ID: <20130227130824.BAFBB184CEF@r-forge.r-project.org> Author: jarioksa Date: 2013-02-27 14:08:24 +0100 (Wed, 27 Feb 2013) New Revision: 2453 Modified: pkg/vegan/R/nestedtemp.R pkg/vegan/inst/ChangeLog Log: nestedtemp failed with fill < 0.0038 Modified: pkg/vegan/R/nestedtemp.R =================================================================== --- pkg/vegan/R/nestedtemp.R 2013-02-26 15:58:41 UTC (rev 2452) +++ pkg/vegan/R/nestedtemp.R 2013-02-27 13:08:24 UTC (rev 2453) @@ -48,7 +48,23 @@ fillfun <- function(x, p) 1 - (1-(1-x)^p)^(1/p) intfun <- function(p, fill) integrate(fillfun, lower=0, upper=1, p=p)$value - fill - p <- uniroot(intfun, c(0,20), fill=fill)$root + ## 'p' will depend on 'fill', and fill = 0.0038 correspond to p = + ## 20. Sometimes the fill is lower, and therefore we try() to see + ## if we need to move the bracket up. We should need to do this + ## very rarely. + lo <- 0 + hi <- 20 + repeat{ + sol <- try(uniroot(intfun, c(lo,hi), fill=fill), silent = TRUE) + if (inherits(sol, "try-error")) { + if (hi > 640) # bail out + stop(gettextf("matrix is too sparse, fill is %g"), fill) + lo <- hi + hi <- hi + hi + } else + break + } + p <- sol$root ## row coordinates of the fill line for all matrix entries out <- matrix(0, nrow=length(r), ncol=length(c)) for (i in 1:length(r)) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-02-26 15:58:41 UTC (rev 2452) +++ pkg/vegan/inst/ChangeLog 2013-02-27 13:08:24 UTC (rev 2453) @@ -4,6 +4,12 @@ Version 2.1-27 (opened Februray 22, 2013) + * nestedtemp: function failed if the matrix fill was < 0.38%, + because the fill line parameter was outside the original + estimation bracket. Now bracket is moved up if the estimation + fails. The problem was reported by Carsten Dormann (Univ Freiburg) + and Benjamin A. Sikes (Lincoln University, NZ). + * specaccum: gained argument 'w' for weights to give the sampling effort. This resurrects a feature that was introduced in r1505 (22 Feb 2011) and 1507, and removed in r1606 (26 May 2011). It seems From noreply at r-forge.r-project.org Wed Feb 27 20:35:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Feb 2013 20:35:21 +0100 (CET) Subject: [Vegan-commits] r2454 - pkg/vegan/R Message-ID: <20130227193521.6DC1C180173@r-forge.r-project.org> Author: jarioksa Date: 2013-02-27 20:35:21 +0100 (Wed, 27 Feb 2013) New Revision: 2454 Modified: pkg/vegan/R/specaccum.R Log: specaccum was wrongly returning wrong weights when 'w' was not given Modified: pkg/vegan/R/specaccum.R =================================================================== --- pkg/vegan/R/specaccum.R 2013-02-27 13:08:24 UTC (rev 2453) +++ pkg/vegan/R/specaccum.R 2013-02-27 19:35:21 UTC (rev 2454) @@ -94,7 +94,7 @@ }) out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm) - if (!is.null(weights)) + if (!is.null(w)) out$weights <- weights if (method == "rarefaction") out$individuals <- ind From noreply at r-forge.r-project.org Thu Feb 28 22:02:32 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 28 Feb 2013 22:02:32 +0100 (CET) Subject: [Vegan-commits] r2455 - in pkg/vegan: . R man Message-ID: <20130228210232.6CAEC184B6C@r-forge.r-project.org> Author: jarioksa Date: 2013-02-28 22:02:32 +0100 (Thu, 28 Feb 2013) New Revision: 2455 Modified: pkg/vegan/NAMESPACE pkg/vegan/R/boxplot.specaccum.R pkg/vegan/R/plot.specaccum.R pkg/vegan/R/specaccum.R pkg/vegan/man/specaccum.Rd Log: start to make weighted specaccum a first class vegan citizen Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2013-02-27 19:35:21 UTC (rev 2454) +++ pkg/vegan/NAMESPACE 2013-02-28 21:02:32 UTC (rev 2455) @@ -200,6 +200,7 @@ S3method(lines, radline) S3method(lines, radfit) S3method(lines, spantree) +S3method(lines, specaccum) ## logLik: stats S3method(logLik, radfit) S3method(logLik, radfit.frame) Modified: pkg/vegan/R/boxplot.specaccum.R =================================================================== --- pkg/vegan/R/boxplot.specaccum.R 2013-02-27 19:35:21 UTC (rev 2454) +++ pkg/vegan/R/boxplot.specaccum.R 2013-02-28 21:02:32 UTC (rev 2455) @@ -1,11 +1,11 @@ -"boxplot.specaccum" <- +`boxplot.specaccum` <- function(x, add=FALSE, ...) { if (x$method != "random") stop("boxplot available only for method=\"random\"") if (!add) { plot(x$sites, x$richness, type="n", xlab="Sites", ylab="Species", - ylim=c(1, max(x$richness)), ...) + ylim=c(1, max(x$richness, na.rm = TRUE)), ...) } tmp <- boxplot(data.frame(t(x$perm)), add=TRUE, at=x$sites, axes=FALSE, ...) invisible(tmp) Modified: pkg/vegan/R/plot.specaccum.R =================================================================== --- pkg/vegan/R/plot.specaccum.R 2013-02-27 19:35:21 UTC (rev 2454) +++ pkg/vegan/R/plot.specaccum.R 2013-02-28 21:02:32 UTC (rev 2455) @@ -1,17 +1,32 @@ `plot.specaccum` <- - function(x, add = FALSE, ci = 2, ci.type = c("bar","line","polygon"), - col = par("fg"), ci.col = col, ci.lty = 1, xlab, - ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) + function(x, add = FALSE, random = FALSE, ci = 2, + ci.type = c("bar","line","polygon"), col = par("fg"), ci.col = col, + ci.lty = 1, xlab, ylab = x$method, ylim, + xvar = c("sites", "individuals", "effort"), ...) { + if(random && x$method != "random") + stop("random = TRUE can be used only with method='random'") xvar <- match.arg(xvar) + ## adjust weights to number of sites + if (random && !is.null(x$weights) && xvar == "sites") { + n <- length(x$effort) + adj <- n/x$effort[n] + } else { + adj <- 1 + } xaxvar <- x[[xvar]] if (missing(xlab)) xlab <- paste(toupper(substring(xvar, 1, 1)), substring(xvar, 2), sep="") + if (random) + ci <- FALSE ci.type <- match.arg(ci.type) if (!add) { if (missing(ylim)) - ylim <- c(1, max(x$richness, x$richness + ci*x$sd)) + if (random) + ylim <- c(1, max(x$perm, na.rm = TRUE)) + else + ylim <- c(1, max(x$richness, x$richness + ci*x$sd, na.rm = TRUE)) plot(xaxvar, x$richness, xlab=xlab, ylab=ylab, ylim=ylim, type="n", ...) } @@ -25,6 +40,21 @@ c(x$richness - ci*x$sd, rev(x$richness + ci*x$sd)), col=ci.col, lty=ci.lty, ...) ) - lines(xaxvar, x$richness,col=col, ...) + if (random) { + if (is.null(x$weights)) { + for(i in seq_len(NCOL(x$perm))) + lines(xaxvar, x$perm[,i], col=col, ...) + } else { + for(i in seq_len(NCOL(x$perm))) + lines(x$weights[,i]*adj, x$perm[,i], col=col, ...) + } + } else + lines(xaxvar, x$richness,col=col, ...) invisible() } + +`lines.specaccum` <- + function(x, ...) +{ + plot(x, add = TRUE, ...) +} Modified: pkg/vegan/R/specaccum.R =================================================================== --- pkg/vegan/R/specaccum.R 2013-02-27 19:35:21 UTC (rev 2454) +++ pkg/vegan/R/specaccum.R 2013-02-28 21:02:32 UTC (rev 2455) @@ -36,8 +36,17 @@ weights[,i] <- cumsum(w[ord]) } sites <- 1:n - specaccum <- apply(perm, 1, mean) - sdaccum <- apply(perm, 1, sd) + if (is.null(w)) { + specaccum <- apply(perm, 1, mean) + sdaccum <- apply(perm, 1, sd) + } else { + sumw <- sum(w) + xout <- seq(sumw/n, sumw, length.out = n) + intx <- sapply(seq_len(n), function(i) + approx(weights[,i], perm[,i], xout = xout)$y) + specaccum <- apply(intx, 1, mean) + sdaccum <- apply(intx, 1, sd) + } }, exact = { freq <- colSums(x > 0) freq <- freq[freq > 0] @@ -94,8 +103,10 @@ }) out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm) - if (!is.null(w)) + if (!is.null(w)) { out$weights <- weights + out$effort <- xout + } if (method == "rarefaction") out$individuals <- ind class(out) <- "specaccum" Modified: pkg/vegan/man/specaccum.Rd =================================================================== --- pkg/vegan/man/specaccum.Rd 2013-02-27 19:35:21 UTC (rev 2454) +++ pkg/vegan/man/specaccum.Rd 2013-02-28 21:02:32 UTC (rev 2455) @@ -18,9 +18,10 @@ \usage{ specaccum(comm, method = "exact", permutations = 100, conditioned =TRUE, gamma = "jack1", w = NULL, ...) -\method{plot}{specaccum}(x, add = FALSE, ci = 2, ci.type = c("bar", "line", "polygon"), - col = par("fg"), ci.col = col, ci.lty = 1, xlab, - ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) +\method{plot}{specaccum}(x, add = FALSE, random = FALSE, ci = 2, + ci.type = c("bar", "line", "polygon"), col = par("fg"), ci.col = col, + ci.lty = 1, xlab, ylab = x$method, ylim, + xvar = c("sites", "individuals", "effort"), ...) \method{boxplot}{specaccum}(x, add = FALSE, ...) fitspecaccum(object, model, method = "random", ...) \method{plot}{fitspecaccum}(x, col = par("fg"), lty = 1, xlab = "Sites", @@ -48,6 +49,7 @@ that may be removed).} \item{x}{A \code{specaccum} result object} \item{add}{Add to an existing graph.} + \item{random}{\dots} \item{ci}{Multiplier used to get confidence intervals from standard deviation (standard error of the estimate). Value \code{ci = 0} suppresses drawing confidence intervals.}
    [ < ][ > ]
    [ < ][ > ]   [ << ][ Up ][ >> ][ << ][ Up ][ >> ]