From noreply at r-forge.r-project.org Mon Sep 1 08:59:06 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Sep 2014 08:59:06 +0200 (CEST) Subject: [Vegan-commits] r2878 - in pkg/vegan: R inst man Message-ID: <20140901065906.CDE5F186ED6@r-forge.r-project.org> Author: jarioksa Date: 2014-09-01 08:59:06 +0200 (Mon, 01 Sep 2014) New Revision: 2878 Modified: pkg/vegan/R/nestednodf.R pkg/vegan/R/ordiellipse.R pkg/vegan/R/ordihull.R pkg/vegan/R/ordispider.R pkg/vegan/inst/ChangeLog pkg/vegan/man/nestedtemp.Rd Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/R/nestednodf.R =================================================================== --- pkg/vegan/R/nestednodf.R 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/R/nestednodf.R 2014-09-01 06:59:06 UTC (rev 2878) @@ -1,5 +1,5 @@ `nestednodf` <- - function(comm, order = TRUE, weighted = FALSE) + function(comm, order = TRUE, weighted = FALSE, wbinary = FALSE) { bin.comm <- ifelse(comm > 0, 1, 0) rfill <- rowSums(bin.comm) @@ -34,8 +34,12 @@ next if (weighted) { second <- comm[j, ] - N.paired.rows[counter] <- - sum(first - second > 0 & second > 0)/sum(second > 0) + if (!wbinary) + N.paired.rows[counter] <- + sum(first - second > 0 & second > 0)/sum(second > 0) + else + N.paired.rows[counter] <- + sum(first - second >= 0 & second > 0)/sum(second > 0) } else { N.paired.rows[counter] <- @@ -52,8 +56,12 @@ next if (weighted) { second <- comm[, j] - N.paired.cols[counter] <- - sum(first - second > 0 & second > 0)/sum(second > 0) + if (!wbinary) + N.paired.cols[counter] <- + sum(first - second > 0 & second > 0)/sum(second > 0) + else + N.paired.cols[counter] <- + sum(first - second >= 0 & second > 0)/sum(second > 0) } else { N.paired.cols[counter] <- Modified: pkg/vegan/R/ordiellipse.R =================================================================== --- pkg/vegan/R/ordiellipse.R 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/R/ordiellipse.R 2014-09-01 06:59:06 UTC (rev 2878) @@ -34,7 +34,7 @@ if (label) cntrs <- names <- NULL ## Remove NA scores - kk <- complete.cases(pts) + kk <- complete.cases(pts) & !is.na(groups) for (is in inds) { gr <- out[groups == is & kk] if (length(gr) > 1) { Modified: pkg/vegan/R/ordihull.R =================================================================== --- pkg/vegan/R/ordihull.R 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/R/ordihull.R 2014-09-01 06:59:06 UTC (rev 2878) @@ -30,7 +30,7 @@ if (label) cntrs <- names <- NULL ## Remove NA scores - kk <- complete.cases(pts) + kk <- complete.cases(pts) & !is.na(groups) for (is in inds) { gr <- out[groups == is & kk] if (length(gr) > 1) { Modified: pkg/vegan/R/ordispider.R =================================================================== --- pkg/vegan/R/ordispider.R 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/R/ordispider.R 2014-09-01 06:59:06 UTC (rev 2878) @@ -38,8 +38,8 @@ inds <- names(table(groups)) if (label) cntrs <- names <- NULL - ## 'kk' removes NA scores - kk <- complete.cases(pts) + ## 'kk' removes NA scores and NA groups + kk <- complete.cases(pts) & !is.na(groups) for (is in inds) { gr <- out[groups == is & kk] if (length(gr)) { Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/inst/ChangeLog 2014-09-01 06:59:06 UTC (rev 2878) @@ -4,6 +4,11 @@ Version 2.1-41 (opened December 12, 2013) + * ordiellipse, ordihull, ordispider: can now handle (omit) NA + cases in 'groups'. They were able to omit to NA cases in scores, + but having NA in 'groups' triggered really cryptic error + messages. + * adipart, multipart, hiersimu: it is now an error to provide non-nested sampling hierarchy (used to be a warning). @@ -159,6 +164,14 @@ sure. Also fixed handling of tied values in assessing the P-values in vectorfit. + * nestednodf: vegan 2.1-36 (release 2.0-10) changed the function + so that weighted analysis of binary data was equal to unweighted + binary analysis, but this broke consinstency with the original + software and publication by Almeida-Neto & Ulrich. The fix was now + made optional, and the default is to follow published method by + adding argument 'wbinary' (defaults FALSE). Based on the + suggestion by Matt Barbour in GitHub. + * ordispider: can now use spatial medians as centres instead of the default centroids. The kind of centre is defined by new argument 'spiders'. Modified: pkg/vegan/man/nestedtemp.Rd =================================================================== --- pkg/vegan/man/nestedtemp.Rd 2014-08-28 08:50:50 UTC (rev 2877) +++ pkg/vegan/man/nestedtemp.Rd 2014-09-01 06:59:06 UTC (rev 2878) @@ -24,7 +24,7 @@ nestedn0(comm) nesteddisc(comm, niter = 200) nestedtemp(comm, ...) -nestednodf(comm, order = TRUE, weighted = FALSE) +nestednodf(comm, order = TRUE, weighted = FALSE, wbinary = FALSE) nestedbetasor(comm) nestedbetajac(comm) \method{plot}{nestedtemp}(x, kind = c("temperature", "incidence"), @@ -43,6 +43,8 @@ returned accordingly.} \item{order}{Order rows and columns by frequencies.} \item{weighted}{Use species abundances as weights of interactions.} + \item{wbinary}{Modify original method so that binary data give the same + result in weighted and and unweighted analysis. } \item{\dots}{Other arguments to functions.} } @@ -112,7 +114,14 @@ al. 2008). With \code{weighted = TRUE}, the function finds the weighted version of the index (Almeida-Neto & Ulrich, 2011). However, this requires quantitative null models for adequate - testing. + testing. Almeida-Neto & Ulrich (2011) say that you have positive + nestedness if values in the first row/column are higher than in the + second. With this condition, weighted analysis of binary data will + always give zero nestedness. With argument \code{wbinary = TRUE}, + equality of rows/colums also indicates nestedness, and binary data + will give identical results in weighted and unweighted analysis. + However, this can also influence the results of weighted analysis so + that the results may differ from Almeida-Neto & Ulrich (2011). Functions \code{nestedbetasor} and \code{nestedbetajac} find multiple-site dissimilarities and decompose these into components of From noreply at r-forge.r-project.org Wed Sep 3 11:36:53 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Sep 2014 11:36:53 +0200 (CEST) Subject: [Vegan-commits] r2879 - in pkg/vegan: . R man Message-ID: <20140903093654.0418F1876CD@r-forge.r-project.org> Author: jarioksa Date: 2014-09-03 11:36:53 +0200 (Wed, 03 Sep 2014) New Revision: 2879 Added: pkg/vegan/.Rbuildignore pkg/vegan/.travis.yml pkg/vegan/README.md Modified: pkg/vegan/DESCRIPTION pkg/vegan/NAMESPACE pkg/vegan/R/bioenv.default.R pkg/vegan/R/confint.MOStest.R pkg/vegan/R/goodness.metaMDS.R pkg/vegan/R/metaMDSiter.R pkg/vegan/R/ordirgl.R pkg/vegan/R/ordisurf.R pkg/vegan/R/plot.spantree.R pkg/vegan/R/rankindex.R pkg/vegan/R/rgl.isomap.R pkg/vegan/R/rgl.renyiaccum.R pkg/vegan/R/scores.lda.R pkg/vegan/R/simulate.rda.R pkg/vegan/R/stressplot.R pkg/vegan/R/tabasco.R pkg/vegan/R/vegemite.R pkg/vegan/man/ordisurf.Rd Log: Merge branch 'master' into r-forge-svn-local Added: pkg/vegan/.Rbuildignore =================================================================== --- pkg/vegan/.Rbuildignore (rev 0) +++ pkg/vegan/.Rbuildignore 2014-09-03 09:36:53 UTC (rev 2879) @@ -0,0 +1,3 @@ +LICENSE +^\.travis\.yml$ + Added: pkg/vegan/.travis.yml =================================================================== --- pkg/vegan/.travis.yml (rev 0) +++ pkg/vegan/.travis.yml 2014-09-03 09:36:53 UTC (rev 2879) @@ -0,0 +1,24 @@ +# Sample .travis.yml for R projects. +# +# See README.md for instructions, or for more configuration options, +# see the wiki: +# https://github.com/craigcitro/r-travis/wiki + +language: c + +before_install: + - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh + - chmod 755 ./travis-tool.sh + - ./travis-tool.sh bootstrap +install: + - ./travis-tool.sh install_deps +script: ./travis-tool.sh run_tests + +after_failure: + - ./travis-tool.sh dump_logs + +notifications: + email: + on_success: change + on_failure: change + Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/DESCRIPTION 2014-09-03 09:36:53 UTC (rev 2879) @@ -7,7 +7,8 @@ M. Henry H. Stevens, Helene Wagner Maintainer: Jari Oksanen Depends: permute (>= 0.7-8), lattice, R (>= 2.15.0) -Suggests: MASS, mgcv, cluster, parallel, scatterplot3d, rgl, tcltk +Suggests: parallel, scatterplot3d, tcltk +Imports: MASS, rgl, cluster, mgcv Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. License: GPL-2 Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/NAMESPACE 2014-09-03 09:36:53 UTC (rev 2879) @@ -61,17 +61,20 @@ ## ordiParseFormula, ordiTerminfo, pregraphKM, simpleRDA2, varpart2, ## varpart3, varpart4, veganCovEllipse, veganMahatrans) -## Registration of S3 methods +## Imports import(stats) import(graphics) import(permute) importFrom(utils, head, tail, str) importFrom(tools, Rd2txt, startDynamicHelp) import(lattice) -## nobs only exists in R 2.13.0 -- import from permute with older R -if (getRversion() < "2.13.0") { - importFrom(permute, nobs) -} +import(parallel) +import(tcltk) +importFrom(MASS, isoMDS, sammon, Shepard, mvrnorm) +import(rgl) +importFrom(cluster, daisy) +importFrom(mgcv, gam) +## Registration of S3 methods defined in vegan # adipart: vegan S3method(adipart, default) S3method(adipart, formula) Modified: pkg/vegan/R/bioenv.default.R =================================================================== --- pkg/vegan/R/bioenv.default.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/bioenv.default.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -47,8 +47,6 @@ x <- as.matrix(scale(env, scale = FALSE)) distfun <- function(x) dist(veganMahatrans(x)) } else if (metric == "gower") { - require(cluster) || - stop("package 'cluster' needed for factor variables in 'env'") x <- env distfun <- function(x) daisy(x, metric = "gower") } else if (metric == "manhattan") { @@ -142,9 +140,6 @@ ## any non-numeric argument is regarded as "best" if(!is.numeric(which)) which <- x$whichbest - if (x$metric == "gower") - require(cluster) || - stop("requires package 'cluster' for 'gower' metric") x$distfun(x$x[, x$models[[which]]$best, drop = FALSE]) } Modified: pkg/vegan/R/confint.MOStest.R =================================================================== --- pkg/vegan/R/confint.MOStest.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/confint.MOStest.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -1,6 +1,5 @@ `confint.MOStest` <- function (object, parm = 1, level = 0.95, ...) { - require(MASS) || stop("requires packages MASS") confint(profile(object), level = level, ...) } Modified: pkg/vegan/R/goodness.metaMDS.R =================================================================== --- pkg/vegan/R/goodness.metaMDS.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/goodness.metaMDS.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -3,7 +3,6 @@ { if (inherits(object, "monoMDS")) return(NextMethod("goodness", object, ...)) - require(MASS) || stop("Needs MASS package") if (missing(dis)) dis <- metaMDSredist(object) if(attr(dis, "Size") != nrow(object$points)) Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/metaMDSiter.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -4,8 +4,6 @@ parallel = getOption("mc.cores"), ...) { engine <- match.arg(engine, c("monoMDS", "isoMDS")) - if (engine == "isoMDS") - require(MASS) || stop("Needs package MASS (function isoMDS)") EPS <- 0.05 if (engine == "monoMDS") EPS <- EPS/100 # monoMDS stress (0,1), isoMDS (0,100) Modified: pkg/vegan/R/ordirgl.R =================================================================== --- pkg/vegan/R/ordirgl.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/ordirgl.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -2,8 +2,6 @@ function (object, display = "sites", choices = 1:3, type = "p", ax.col = "red", arr.col = "yellow", text, envfit, ...) { - if (!require(rgl)) - stop("Requires package 'rgl'") x <- scores(object, display = display, choices = choices, ...) if (ncol(x) < 3) Modified: pkg/vegan/R/ordisurf.R =================================================================== --- pkg/vegan/R/ordisurf.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/ordisurf.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -33,7 +33,6 @@ w <- eval(w) if (!is.null(w) && length(w) == 1) w <- NULL - require(mgcv) || stop("Requires package 'mgcv'") X <- scores(x, choices = choices, display = display, ...) ## The original name of 'y' may be lost in handling NA: save for ## plots Modified: pkg/vegan/R/plot.spantree.R =================================================================== --- pkg/vegan/R/plot.spantree.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/plot.spantree.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -3,8 +3,6 @@ ...) { FUNname <- deparse(substitute(FUN)) - if (length(FUNname) && FUNname %in% c("sammon", "isoMDS")) - require(MASS) || stop(FUNname, "requires package MASS") FUN <- match.fun(FUN) n <- length(x$kid) + 1 if (missing(ord)) { Modified: pkg/vegan/R/rankindex.R =================================================================== --- pkg/vegan/R/rankindex.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/rankindex.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -4,12 +4,8 @@ metric = c("euclidean", "mahalanobis", "manhattan", "gower"), ...) { metric = match.arg(metric) - if (metric == "gower") - require(cluster) || stop("metric = 'gower' needs package 'cluster'") grad <- as.data.frame(grad) if (any(sapply(grad, is.factor))) { - require(cluster) || stop("factors in 'grad' need package 'cluster'") - message("'grad' included factors: used cluster:::daisy") span <- daisy(grad) } else { span <- switch(metric, Modified: pkg/vegan/R/rgl.isomap.R =================================================================== --- pkg/vegan/R/rgl.isomap.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/rgl.isomap.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -1,7 +1,6 @@ `rgl.isomap` <- function(x, web = "white", ...) { - require(rgl) || stop("requires package 'rgl'") ordirgl(x, ...) z <- scores(x, ...) net <- x$net Modified: pkg/vegan/R/rgl.renyiaccum.R =================================================================== --- pkg/vegan/R/rgl.renyiaccum.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/rgl.renyiaccum.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -1,7 +1,6 @@ `rgl.renyiaccum` <- function(x, rgl.height = 0.2, ...) { - require(rgl) || stop("requires packages 'rgl'") y <- x[,,1] * rgl.height rgl.min = 0 rgl.max = max(y) Modified: pkg/vegan/R/scores.lda.R =================================================================== --- pkg/vegan/R/scores.lda.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/scores.lda.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -1,7 +1,6 @@ `scores.lda` <- function(x, display, ...) { - require(MASS) || stop("'lda' objects created in MASS need MASS for 'scores'") display <- match.arg(display, c("sites", "species", "scores", "predictors", "x", "coef"), several.ok = TRUE) Modified: pkg/vegan/R/simulate.rda.R =================================================================== --- pkg/vegan/R/simulate.rda.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/simulate.rda.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -2,9 +2,6 @@ function(object, nsim = 1, seed = NULL, indx = NULL, rank = "full", correlated = FALSE, ...) { - ## is.null(indx) && correlated requires MASS - if(is.null(indx) && correlated) - require(MASS) || stop("simulate options require MASS package") ## Handle RNG: code directly from stats::simulate.lm if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) @@ -94,8 +91,6 @@ function(object, nsim = 1, seed = NULL, indx = NULL, rank = "full", correlated = FALSE, ...) { - if (is.null(indx) && correlated) - require(MASS) || stop("simulate options require MASS package") ## Handle RNG: code directly from stats::simulate.lm if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) Modified: pkg/vegan/R/stressplot.R =================================================================== --- pkg/vegan/R/stressplot.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/stressplot.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -79,7 +79,6 @@ if (!(inherits(object, "metaMDS") || all(c("points", "stress") %in% names(object)))) stop("can be used only with objects that are compatible with MASS::isoMDS results") - require(MASS) || stop("Needs MASS package") if (missing(dis)) if (inherits(object, "metaMDS")) dis <- metaMDSredist(object) Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/tabasco.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -23,7 +23,6 @@ ## but "hclust" is kept as "hclust": they differ in ## reorder() if (inherits(use, "twins")) { - require(cluster) || stop("package cluster needed to handle 'use'") use <- as.dendrogram(use) } if (!is.null(site.ind)) @@ -88,7 +87,6 @@ ## 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'") sp.ind <- as.dendrogram(sp.ind) } sptree <- sp.ind Modified: pkg/vegan/R/vegemite.R =================================================================== --- pkg/vegan/R/vegemite.R 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/R/vegemite.R 2014-09-03 09:36:53 UTC (rev 2879) @@ -11,7 +11,6 @@ } 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)) Added: pkg/vegan/README.md =================================================================== --- pkg/vegan/README.md (rev 0) +++ pkg/vegan/README.md 2014-09-03 09:36:53 UTC (rev 2879) @@ -0,0 +1,7 @@ +# vegan: an R package for community ecologists + +## Build status + +Linux | Windows +------------|------------ +[![Build Status](https://travis-ci.org/vegandevs/vegan.svg?branch=master)](https://travis-ci.org/vegandevs/vegan) | Modified: pkg/vegan/man/ordisurf.Rd =================================================================== --- pkg/vegan/man/ordisurf.Rd 2014-09-01 06:59:06 UTC (rev 2878) +++ pkg/vegan/man/ordisurf.Rd 2014-09-03 09:36:53 UTC (rev 2879) @@ -299,6 +299,7 @@ ## Plotting the "gam" object plot(fit, what = "gam") ## 'col' and 'cex' not passed on ## or via plot.gam directly +library(mgcv) plot.gam(fit, cex = 2, pch = 1, col = "blue") ## 'col' effects all objects drawn... From noreply at r-forge.r-project.org Thu Sep 4 08:49:31 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 4 Sep 2014 08:49:31 +0200 (CEST) Subject: [Vegan-commits] r2880 - in pkg/vegan: . inst tests/Examples Message-ID: <20140904064931.2B880187131@r-forge.r-project.org> Author: jarioksa Date: 2014-09-04 08:49:30 +0200 (Thu, 04 Sep 2014) New Revision: 2880 Modified: pkg/vegan/DESCRIPTION pkg/vegan/inst/ChangeLog pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2014-09-03 09:36:53 UTC (rev 2879) +++ pkg/vegan/DESCRIPTION 2014-09-04 06:49:30 UTC (rev 2880) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-41 -Date: December 12, 2013 +Version: 2.1-42 +Date: September 4, 2014 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 2014-09-03 09:36:53 UTC (rev 2879) +++ pkg/vegan/inst/ChangeLog 2014-09-04 06:49:30 UTC (rev 2880) @@ -2,8 +2,18 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-41 (opened December 12, 2013) +Version 2.1-42 (opened September 4, 2014) + * Opened a new version to prepare release 2.2-0. + + * Moved main development from R-Forge to GitHub.com. + + * NAMESPACE, DESCRIPTION: adapted to current R CMD check that has + more stringent tests on attaching and importing external packages + and using their functions. + +Version 2.1-41 (closed September 4, 2014) + * ordiellipse, ordihull, ordispider: can now handle (omit) NA cases in 'groups'. They were able to omit to NA cases in scores, but having NA in 'groups' triggered really cryptic error Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-09-03 09:36:53 UTC (rev 2879) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-09-04 06:49:30 UTC (rev 2880) @@ -1,5 +1,5 @@ -R Under development (unstable) (2014-01-12 r64752) -- "Unsuffered Consequences" +R Under development (unstable) (2014-09-03 r66516) -- "Unsuffered Consequences" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -153,26 +153,20 @@ > ef <- envfit(mod ~ pH, varechem, permutations = 0) > plot(ef) > ordisurf(mod ~ pH, varechem, knots = 1, add = TRUE) -Loading required package: mgcv -Loading required package: nlme -This is mgcv 1.7-27. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ poly(x1, 1) + poly(x2, 1) - + Total model degrees of freedom 3 -REML score: -3.185099 +REML score: -3.185099 > > > > cleanEx() - -detaching ?package:mgcv?, ?package:nlme? - > nameEx("MOStest") > ### * MOStest > @@ -236,7 +230,6 @@ 2.5 % 97.5 % 5.255827 6.782979 > confint(mod) -Loading required package: MASS 2.5 % 97.5 % 5.816021 6.574378 > plot(profile(mod)) @@ -245,9 +238,6 @@ > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() - -detaching ?package:MASS? - > nameEx("RsquareAdj") > ### * RsquareAdj > @@ -1240,9 +1230,9 @@ > dis[c(2, 20)] <- NA > mod2 <- betadisper(dis, groups) ## warnings Warning in betadisper(dis, groups) : - Missing observations due to 'group' removed. + missing observations due to 'group' removed Warning in betadisper(dis, groups) : - Missing observations due to 'd' removed. + missing observations due to 'd' removed > mod2 Homogeneity of multivariate dispersions @@ -1297,9 +1287,9 @@ > ## Using group centroids > mod3 <- betadisper(dis, groups, type = "centroid") Warning in betadisper(dis, groups, type = "centroid") : - Missing observations due to 'group' removed. + missing observations due to 'group' removed Warning in betadisper(dis, groups, type = "centroid") : - Missing observations due to 'd' removed. + missing observations due to 'd' removed > mod3 Homogeneity of multivariate dispersions @@ -5037,21 +5027,18 @@ > vare.dist <- vegdist(varespec) > vare.mds <- monoMDS(vare.dist) > with(varechem, ordisurf(vare.mds, Baresoil, bubble = 5)) -Loading required package: mgcv -Loading required package: nlme -This is mgcv 1.7-27. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 -REML score: 92.96761 +REML score: 92.96761 > > ## as above but without the extra penalties on smooth terms, > ## and using GCV smoothness selection (old behaviour of `ordisurf()`): @@ -5063,23 +5050,23 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 6.45 total = 7.45 -GCV score: 144.0039 +GCV score: 144.0039 > > ## Cover of Cladina arbuscula > fit <- with(varespec, ordisurf(vare.mds, Cladarbu, family=quasipoisson)) > ## Get fitted values > calibrate(fit) 1 2 3 4 5 6 7 8 -21.253963 5.675210 3.679486 3.898355 9.643787 7.698255 7.729282 9.758092 +21.254026 5.675259 3.679616 3.898510 9.643821 7.698310 7.729203 9.758046 9 10 11 12 13 14 15 16 - 2.743203 29.700504 11.971986 8.310916 5.390556 24.906203 11.006871 25.330570 + 2.743212 29.700556 11.971747 8.310960 5.390564 24.905994 11.007652 25.330656 17 18 19 20 21 22 23 24 - 6.520735 9.410672 4.519645 4.090901 11.558075 4.314814 11.693769 14.244150 + 6.520708 9.410616 4.519672 4.090948 11.557930 4.314850 11.693692 14.243453 > > ## Variable selection via additional shrinkage penalties > ## This allows non-significant smooths to be selected out @@ -5094,12 +5081,12 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 -REML score: 92.96761 +REML score: 92.96761 > ## - option 2: use a basis with shrinkage > with(varechem, + ordisurf(vare.mds, Baresoil, method = "REML", bs = "ts")) @@ -5109,12 +5096,12 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE) - + Estimated degrees of freedom: 4.43 total = 5.43 -REML score: 96.2345 +REML score: 96.2345 > ## or bs = "cs" with `isotropic = FALSE` > > ## Plot method @@ -5123,6 +5110,9 @@ > ## Plotting the "gam" object > plot(fit, what = "gam") ## 'col' and 'cex' not passed on > ## or via plot.gam directly +> library(mgcv) +Loading required package: nlme +This is mgcv 1.8-2. For overview type 'help("mgcv-package")'. > plot.gam(fit, cex = 2, pch = 1, col = "blue") > ## 'col' effects all objects drawn... > @@ -5135,12 +5125,12 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 -REML score: 93.17149 +REML score: 93.17149 > > ## A fixed degrees of freedom smooth, must use 'select = FALSE' > with(varechem, ordisurf(vare.mds, Baresoil, knots = 4, @@ -5151,12 +5141,12 @@ Formula: y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE) - + Estimated degrees of freedom: 3 total = 4 -REML score: 81.86011 +REML score: 81.86011 > > ## An anisotropic smoother with cubic regression spline bases > with(varechem, ordisurf(vare.mds, Baresoil, isotropic = FALSE, @@ -5168,12 +5158,12 @@ Formula: y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE, FALSE)) - + Estimated degrees of freedom: 2.99 total = 3.99 -REML score: 90.861 +REML score: 90.86099 > > ## An anisotropic smoother with cubic regression spline with > ## shrinkage bases & different degrees of freedom in each dimension @@ -5187,12 +5177,12 @@ Formula: y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE, TRUE)) - + Estimated degrees of freedom: 11 total = 12 -REML score: 39.58245 +REML score: 39.58245 > > > @@ -5322,21 +5312,18 @@ > op <- par(mfrow=c(1,3)) > ## Map of PCNMs in the sample plot > ordisurf(mite.xy, scores(pcnm1, choi=1), bubble = 4, main = "PCNM 1") -Loading required package: mgcv -Loading required package: nlme -This is mgcv 1.7-27. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.71 total = 9.71 -REML score: -120.7705 +REML score: -120.7705 > ordisurf(mite.xy, scores(pcnm1, choi=2), bubble = 4, main = "PCNM 2") Family: gaussian @@ -5344,12 +5331,12 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 7.18 total = 8.18 -REML score: -103.4662 +REML score: -103.4662 > ordisurf(mite.xy, scores(pcnm1, choi=3), bubble = 4, main = "PCNM 3") Family: gaussian @@ -5357,12 +5344,12 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.32 total = 9.32 -REML score: -94.19053 +REML score: -94.19053 > par(op) > ## Plot first PCNMs against each other > ordisplom(pcnm1, choices=1:4) @@ -5379,9 +5366,6 @@ > > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() - -detaching ?package:mgcv?, ?package:nlme? - > nameEx("permatfull") > ### * permatfull > @@ -6340,6 +6324,32 @@ > > > cleanEx() +> nameEx("reorder.hclust") +> ### * reorder.hclust +> +> flush(stderr()); flush(stdout()) +> +> ### Name: reorder.hclust +> ### Title: Reorder a Hierarchical Clustering Tree +> ### Aliases: reorder.hclust rev.hclust +> ### Keywords: multivariate +> +> ### ** Examples +> +> data(mite, mite.env) +> hc <- hclust(vegdist(wisconsin(sqrt(mite)))) +> ohc <- with(mite.env, reorder(hc, WatrCont)) +> plot(hc) +> plot(ohc) +> ## Slightly different from reordered 'dendrogram' which ignores group +> ## sizes in assessing means. +> den <- as.dendrogram(hc) +> den <- with(mite.env, reorder(den, WatrCont, agglo.FUN = mean)) +> plot(den) +> +> +> +> cleanEx() > nameEx("scores") > ### * scores > @@ -6384,6 +6394,28 @@ > > > cleanEx() +> nameEx("scores.hclust") +> ### * scores.hclust +> +> flush(stderr()); flush(stdout()) +> +> ### Name: scores.hclust +> ### Title: Coordinates of Leaves and Internal Nodes in a hclust Tree +> ### Aliases: scores.hclust +> ### Keywords: multivariate +> +> ### ** Examples +> +> ## Show values that were used in reordering a tree +> data(mite, mite.env) +> hc <- hclust(vegdist(mite)) +> hc <- with(mite.env, reorder(hc, WatrCont)) +> with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7)) +> ordilabel(scores(hc), label=round(hc$value), cex=0.7) +> +> +> +> cleanEx() > nameEx("screeplot.cca") > ### * screeplot.cca > @@ -6750,8 +6782,8 @@ > > ### Name: spantree > ### Title: Minimum Spanning Tree -> ### Aliases: spantree cophenetic.spantree plot.spantree lines.spantree -> ### spandepth +> ### Aliases: spantree cophenetic.spantree as.hclust.spantree plot.spantree +> ### lines.spantree spandepth > ### Keywords: multivariate > > ### ** Examples @@ -6761,7 +6793,6 @@ > tr <- spantree(dis) > ## Add tree to a metric scaling > plot(tr, cmdscale(dis), type = "t") -Loading required package: MASS > ## Find a configuration to display the tree neatly > plot(tr, type = "t") Initial stress : 0.03111 @@ -6777,13 +6808,12 @@ stress after 20 iters: 0.01139, magic = 0.500 stress after 30 iters: 0.01118, magic = 0.500 stress after 40 iters: 0.01114, magic = 0.500 +> ## Plot as a dendrogram +> plot(as.hclust(tr)) > > > > cleanEx() - -detaching ?package:MASS? - > nameEx("specaccum") > ### * specaccum > @@ -7146,50 +7176,50 @@ > mod <- taxondive(dune, taxdis) > mod Species Delta Delta* Lambda+ Delta+ S Delta+ -1 5.000 25.201 32.401 1583.249 51.705 258.53 -2 10.000 60.573 66.438 1415.833 66.779 667.79 -3 10.000 46.754 51.874 1385.449 70.835 708.35 -4 13.000 58.307 63.293 1249.469 73.461 954.99 -5 14.000 72.023 76.967 1013.850 77.581 1086.14 -6 11.000 76.352 83.052 856.565 80.779 888.57 -7 13.000 71.005 76.286 896.552 79.375 1031.87 -8 12.000 62.880 67.464 906.057 77.412 928.95 -9 13.000 60.341 64.619 1081.914 73.544 956.07 -10 12.000 68.919 74.532 1023.714 77.748 932.97 -11 9.000 76.140 85.057 553.804 82.412 741.71 -12 9.000 71.195 79.626 669.623 83.756 753.80 -13 10.000 57.210 65.101 848.964 77.901 779.01 -14 7.000 78.441 90.207 279.757 88.808 621.66 -15 8.000 77.813 87.496 330.572 88.150 705.20 -16 8.000 62.725 72.154 875.566 77.140 617.12 -17 7.000 64.823 72.409 1204.103 70.968 496.77 -18 9.000 76.626 85.656 599.550 81.260 731.34 -19 9.000 73.340 81.198 480.065 83.218 748.96 -20 8.000 79.807 88.993 390.726 89.385 715.08 -Expected 74.594 71.431 79.644 +1 5.000 25.009 32.154 1592.777 51.545 257.73 +2 10.000 60.493 66.350 1426.590 66.687 666.87 +3 10.000 46.599 51.702 1395.603 70.748 707.47 +4 13.000 58.199 63.176 1258.772 73.403 954.24 +5 14.000 72.045 76.990 1018.677 77.602 1086.43 +6 11.000 76.415 83.121 858.170 80.843 889.27 +7 13.000 70.250 75.475 970.358 78.397 1019.17 +8 12.000 59.126 63.436 1079.722 74.787 897.44 +9 13.000 56.948 60.985 1220.760 71.160 925.08 +10 12.000 68.902 74.513 1028.527 77.762 933.14 +11 9.000 76.201 85.126 552.357 82.538 742.84 +12 9.000 69.555 77.792 760.886 82.614 743.52 +13 10.000 55.296 62.923 935.943 76.657 766.57 +14 7.000 77.609 89.250 341.499 88.182 617.27 +15 8.000 74.924 84.249 473.604 86.558 692.47 +16 8.000 57.843 66.539 1111.251 73.360 586.88 +17 7.000 64.823 72.408 1209.057 70.974 496.82 +18 9.000 76.731 85.773 596.607 81.401 732.61 +19 9.000 73.449 81.318 476.221 83.371 750.34 +20 8.000 78.076 87.063 520.623 87.922 703.38 +Expected 73.289 70.182 78.712 > summary(mod) Delta Delta* Delta+ sd(Delta+) z(Delta+) Pr(>|z|) -1 25.2010 32.4013 51.7051 8.9683 -3.1153 0.001837 ** -2 60.5731 66.4375 66.7793 4.2930 -2.9967 0.002729 ** -3 46.7535 51.8745 70.8346 4.2930 -2.0520 0.040165 * -4 58.3066 63.2933 73.4609 3.2021 -1.9310 0.053486 . -5 72.0231 76.9667 77.5814 2.9323 -0.7034 0.481792 -6 76.3523 83.0524 80.7792 3.8687 0.2934 0.769200 -7 71.0050 76.2863 79.3749 3.2021 -0.0840 0.933019 -8 62.8802 67.4643 77.4124 3.5104 -0.6357 0.524956 -9 60.3414 64.6193 73.5437 3.2021 -1.9051 0.056762 . -10 68.9193 74.5319 77.7475 3.5104 -0.5403 0.589023 -11 76.1400 85.0573 82.4117 4.8067 0.5758 0.564763 -12 71.1954 79.6265 83.7558 4.8067 0.8554 0.392326 -13 57.2101 65.1011 77.9007 4.2930 -0.4061 0.684669 -14 78.4412 90.2074 88.8084 6.2696 1.4617 0.143819 -15 77.8128 87.4962 88.1501 5.4461 1.5619 0.118320 -16 62.7252 72.1545 77.1396 5.4461 -0.4599 0.645611 -17 64.8233 72.4091 70.9677 6.2696 -1.3839 0.166399 -18 76.6264 85.6556 81.2596 4.8067 0.3361 0.736794 -19 73.3403 81.1982 83.2181 4.8067 0.7436 0.457145 -20 79.8067 88.9931 89.3845 5.4461 1.7885 0.073693 . -Expected 74.5941 71.4315 79.6440 +1 25.0089 32.1543 51.5455 9.5637 -2.8405 0.004504 ** +2 60.4931 66.3497 66.6869 4.6664 -2.5769 0.009970 ** +3 46.5985 51.7024 70.7475 4.6664 -1.7067 0.087881 . +4 58.1988 63.1763 73.4033 3.5073 -1.5135 0.130150 +5 72.0452 76.9903 77.6024 3.2187 -0.3446 0.730386 +6 76.4148 83.1205 80.8430 4.2170 0.5054 0.613259 +7 70.2500 75.4752 78.3974 3.5073 -0.0896 0.928626 +8 59.1259 63.4363 74.7865 3.8361 -1.0232 0.306220 +9 56.9481 60.9854 71.1597 3.5073 -2.1532 0.031303 * +10 68.9021 74.5133 77.7617 3.8361 -0.2476 0.804432 +11 76.2014 85.1259 82.5379 5.2089 0.7346 0.462605 +12 69.5554 77.7922 82.6136 5.2089 0.7491 0.453792 +13 55.2961 62.9232 76.6566 4.6664 -0.4404 0.659657 +14 77.6087 89.2500 88.1818 6.7459 1.4039 0.160362 +15 74.9245 84.2485 86.5584 5.8818 1.3341 0.182178 +16 57.8435 66.5389 73.3604 5.8818 -0.9098 0.362936 +17 64.8225 72.4081 70.9740 6.7459 -1.1470 0.251377 +18 76.7314 85.7730 81.4015 5.2089 0.5164 0.605570 +19 73.4487 81.3182 83.3712 5.2089 0.8945 0.371029 +20 78.0762 87.0634 87.9221 5.8818 1.5659 0.117368 +Expected 73.2888 70.1816 78.7116 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > plot(mod) @@ -7933,21 +7963,18 @@ > with(dune.env, ordiellipse(mod, Management, label = TRUE)) > ## add fitted surface of diversity to the model > ordisurf(mod, diversity(dune), add = TRUE) -Loading required package: mgcv -Loading required package: nlme -This is mgcv 1.7-27. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 1.28 total = 2.28 -REML score: 3.006229 +REML score: 3.00623 > ### Example 3: analysis of dissimilarites a.k.a. non-parametric > ### permutational anova > adonis(dune ~ ., dune.env) @@ -7985,9 +8012,6 @@ > > > cleanEx() - -detaching ?package:mgcv?, ?package:nlme? - > nameEx("vegandocs") > ### * vegandocs > @@ -8495,7 +8519,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 27.424 0.147 27.577 0 0 +Time elapsed: 35.834 7.734 41.19 0 0.001 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Fri Sep 5 13:55:04 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 5 Sep 2014 13:55:04 +0200 (CEST) Subject: [Vegan-commits] r2881 - in pkg/vegan: . R man Message-ID: <20140905115504.6BB1B1874ED@r-forge.r-project.org> Author: jarioksa Date: 2014-09-05 13:55:04 +0200 (Fri, 05 Sep 2014) New Revision: 2881 Removed: pkg/vegan/R/commsimulator.R Modified: pkg/vegan/NAMESPACE pkg/vegan/R/vegan-defunct.R pkg/vegan/R/vegan-deprecated.R pkg/vegan/man/vegan-defunct.Rd pkg/vegan/man/vegan-deprecated.Rd Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/NAMESPACE 2014-09-05 11:55:04 UTC (rev 2881) @@ -6,7 +6,7 @@ export(CCorA, MOStest, RsquareAdj, SSarrhenius, SSgitay, SSgleason, SSlomolino, adipart, adonis, anosim, beals, betadisper, betadiver, bgdispersal, bioenv, bioenvdist, bstick, cIndexKM, calibrate, capscale, -cascadeKM, cca, commsimulator, contribdiv, clamtest, commsim, decorana, +cascadeKM, cca, contribdiv, clamtest, commsim, decorana, decostand, designdist, coverscale, dispweight, dispindmorisita, distconnected, diversity, downweight, drarefy, eigengrad, eigenvals, envfit, estaccumR, estimateR, eventstar, factorfit, fisherfit, fitspecaccum, @@ -38,7 +38,7 @@ ## Export as.mcmc for coda export(as.mcmc.oecosimu, as.mcmc.permat) ## DEFUNCT: export names defined in vegan-defunct -export(permuted.index2, getNumObs) +export(metaMDSrotate) ## export regular functions with dot names @@ -52,7 +52,7 @@ export(panel.ordi, panel.ordiarrows, panel.ordi3d, prepanel.ordi3d) ## Export .Depracated functions (to be removed later) -export(metaMDSrotate) +export(commsimulator) ## do NOT export the following internal functions Deleted: pkg/vegan/R/commsimulator.R =================================================================== --- pkg/vegan/R/commsimulator.R 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/R/commsimulator.R 2014-09-05 11:55:04 UTC (rev 2881) @@ -1,14 +0,0 @@ -"commsimulator" <- -function (x, method, thin = 1) -{ - method <- match.arg(method, - c("r0","r1","r2","r00","c0","swap", "tswap", - "backtrack", "quasiswap")) - if (method == "r0") - method <- "r0_old" - x <- as.matrix(x) - out <- simulate(nullmodel(x, method), nsim = 1, thin = thin) - out <- out[,,1] - attributes(out) <- attributes(x) - out -} Modified: pkg/vegan/R/vegan-defunct.R =================================================================== --- pkg/vegan/R/vegan-defunct.R 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/R/vegan-defunct.R 2014-09-05 11:55:04 UTC (rev 2881) @@ -1,8 +1,8 @@ ## "new" permutation code was moved to package 'permute' in R 2.0-0. ## Here we list as defunct those functions that are not in 'permute'. -`permuted.index2` <- function (n, control = permControl()) - .Defunct("permute::shuffle", package="vegan") - -`getNumObs` <- function(object, ...) - .Defunct("nobs", package = "vegan") +`metaMDSrotate` <- + function(object, vec, na.rm = FALSE, ...) +{ + .Defunct(new="MDSrotate", "vegan") +} Modified: pkg/vegan/R/vegan-deprecated.R =================================================================== --- pkg/vegan/R/vegan-deprecated.R 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/R/vegan-deprecated.R 2014-09-05 11:55:04 UTC (rev 2881) @@ -1,6 +1,14 @@ -`metaMDSrotate` <- - function(object, vec, na.rm = FALSE, ...) +"commsimulator" <- +function (x, method, thin = 1) { - .Deprecated(new="MDSrotate", "vegan") - MDSrotate(object = object, vec = vec, na.rm = na.rm, ...) + method <- match.arg(method, + c("r0","r1","r2","r00","c0","swap", "tswap", + "backtrack", "quasiswap")) + if (method == "r0") + method <- "r0_old" + x <- as.matrix(x) + out <- simulate(nullmodel(x, method), nsim = 1, thin = thin) + out <- out[,,1] + attributes(out) <- attributes(x) + out } Modified: pkg/vegan/man/vegan-defunct.Rd =================================================================== --- pkg/vegan/man/vegan-defunct.Rd 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/man/vegan-defunct.Rd 2014-09-05 11:55:04 UTC (rev 2881) @@ -3,24 +3,7 @@ % removed from vegan, but here we document only those that were % renamed and are not documented in 'permute' -%\alias{permCheck} -%\alias{numPerms} -%\alias{print.permCheck} -%\alias{print.summary.permCheck} -%\alias{summary.permCheck} -\alias{getNumObs} -%\alias{getNumObs.default} -%\alias{getNumObs.integer} -%\alias{getNumObs.numeric} -%\alias{allPerms} -%\alias{print.allPerms} -%\alias{summary.allPerms} -%\alias{print.summary.allPerms} -%\alias{permuplot} -\alias{permuted.index2} -%\alias{permControl} -%\alias{print.permControl} -%\alias{permute} +\alias{metaMDSrotate} \alias{vegan-defunct} %------ NOTE: ../R/vegan-deprecated.R must be synchronized with this! @@ -31,20 +14,13 @@ they are no longer needed. } \usage{ -%-- Removed from vegan 2.0-0: now in package permute -getNumObs(object, \dots) -\method{getNumObs}{default}(object, \dots) -\method{getNumObs}{numeric}(object, \dots) -\method{getNumObs}{integer}(object, \dots) - -permuted.index2(n, control = permControl()) +metaMDSrotate(object, vec, na.rm = FALSE, ...) } -\details{ The \dQuote{new} permutation functions were moved to the - \pkg{permute} package, and they are documented there. The - \pkg{permute} package replaces \code{permuted.index2} with - \code{\link[permute]{shuffle}} and \code{getNumObs} with its specific - \code{\link[permute]{nobs-methods}}. +\details{ + Function \code{metaMDSrotate} is replaced with + \code{\link{MDSrotate}} which can handle \code{\link{monoMDS}} + results in addition to \code{\link{metaMDS}}. } \seealso{ Modified: pkg/vegan/man/vegan-deprecated.Rd =================================================================== --- pkg/vegan/man/vegan-deprecated.Rd 2014-09-04 06:49:30 UTC (rev 2880) +++ pkg/vegan/man/vegan-deprecated.Rd 2014-09-05 11:55:04 UTC (rev 2881) @@ -1,6 +1,5 @@ \encoding{UTF-8} \name{vegan-deprecated} -\alias{metaMDSrotate} \alias{commsimulator} \alias{vegan-deprecated} @@ -12,16 +11,10 @@ \pkg{vegan} only, and may be defunct as soon as the next release. } \usage{ -metaMDSrotate(object, vec, na.rm = FALSE, ...) commsimulator(x, method, thin=1) } \arguments{ - ## metaMDSrotate - \item{object}{A result object from \code{metaMDS}.} - \item{vec}{A continuous site variable (vector).} - \item{na.rm}{Remove missing values from continuous variable \code{vec}.} - \item{\dots}{Other parameters passed to functions.} ## commsimulator \item{x}{Community data for \code{commsimulator}} \item{method}{Null model method: either a name (character string) of @@ -39,10 +32,6 @@ %-- Or: %% explain *why* it's deprecated, and \code{\link{..}} to new - Function \code{metaMDSrotate} is replaced with - \code{\link{MDSrotate}} which can handle \code{\link{monoMDS}} - results in addition to \code{\link{metaMDS}}. - Function \code{commsimulator} is replaced with \code{\link{make.commsim}} which defines the Null models, and functions \code{\link{nullmodel}} and From noreply at r-forge.r-project.org Tue Sep 16 09:13:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 09:13:05 +0200 (CEST) Subject: [Vegan-commits] r2882 - in pkg/vegan: . R inst man tests Message-ID: <20140916071305.B8E58183FEF@r-forge.r-project.org> Author: jarioksa Date: 2014-09-16 09:13:05 +0200 (Tue, 16 Sep 2014) New Revision: 2882 Added: pkg/vegan/R/getPermuteMatrix.R Removed: pkg/vegan/R/ordiplot3d.R pkg/vegan/R/ordirgl.R pkg/vegan/R/orglpoints.R pkg/vegan/R/orglsegments.R pkg/vegan/R/orglspider.R pkg/vegan/R/orgltext.R pkg/vegan/R/rgl.isomap.R pkg/vegan/R/rgl.renyiaccum.R pkg/vegan/man/ordiplot3d.Rd Modified: pkg/vegan/DESCRIPTION pkg/vegan/NAMESPACE pkg/vegan/R/CCorA.R pkg/vegan/R/SSarrhenius.R pkg/vegan/R/adonis.R pkg/vegan/R/anosim.R pkg/vegan/R/anova.cca.R pkg/vegan/R/envfit.default.R pkg/vegan/R/factorfit.R pkg/vegan/R/howHead.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R pkg/vegan/R/mrpp.R pkg/vegan/R/mso.R pkg/vegan/R/nesteddisc.R pkg/vegan/R/oecosimu.R pkg/vegan/R/permuted.index.R pkg/vegan/R/permutest.betadisper.R pkg/vegan/R/permutest.cca.R pkg/vegan/R/print.mrpp.R pkg/vegan/R/print.protest.R pkg/vegan/R/protest.R pkg/vegan/R/raupcrick.R pkg/vegan/R/simper.R pkg/vegan/R/vectorfit.R pkg/vegan/inst/ChangeLog pkg/vegan/man/CCorA.Rd pkg/vegan/man/add1.cca.Rd pkg/vegan/man/adonis.Rd pkg/vegan/man/anosim.Rd pkg/vegan/man/anova.cca.Rd pkg/vegan/man/envfit.Rd pkg/vegan/man/isomap.Rd pkg/vegan/man/mantel.Rd pkg/vegan/man/mrpp.Rd pkg/vegan/man/mso.Rd pkg/vegan/man/ordistep.Rd pkg/vegan/man/orditkplot.Rd pkg/vegan/man/permutations.Rd pkg/vegan/man/procrustes.Rd pkg/vegan/man/raupcrick.Rd pkg/vegan/man/renyi.Rd pkg/vegan/man/simper.Rd pkg/vegan/man/tsallis.Rd pkg/vegan/man/vegan-internal.Rd pkg/vegan/tests/vegan-tests.R Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/DESCRIPTION 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,14 +1,14 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-42 -Date: September 4, 2014 +Version: 2.1-43 +Date: 2014-09-12 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 Maintainer: Jari Oksanen Depends: permute (>= 0.7-8), lattice, R (>= 2.15.0) -Suggests: parallel, scatterplot3d, tcltk -Imports: MASS, rgl, cluster, mgcv +Suggests: parallel, tcltk +Imports: MASS, cluster, mgcv Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. License: GPL-2 Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/NAMESPACE 2014-09-16 07:13:05 UTC (rev 2882) @@ -16,10 +16,10 @@ mrpp, msoplot, mso, multipart, make.commsim, nestedbetajac, nestedbetasor, nestedchecker, nesteddisc, nestedn0, nestednodf, nestedtemp, nullmodel, oecosimu, ordiR2step, ordiarrows, ordicloud, ordicluster, ordiellipse, ordigrid, -ordihull, ordilabel, ordiplot3d, ordiplot, ordipointlabel, ordiresids, -ordirgl, ordisegments, ordispider, ordisplom, ordistep, ordisurf, -orditkplot, orditorp, ordixyplot, orglpoints, orglsegments, -orglspider, orgltext, pcnm, permatfull, permatswap, permutest, +ordihull, ordilabel, ordiplot, ordipointlabel, ordiresids, +ordisegments, ordispider, ordisplom, ordistep, ordisurf, +orditkplot, orditorp, ordixyplot, +pcnm, permatfull, permatswap, permutest, poolaccum, postMDS, prc, prestondistr, prestonfit, procrustes, protest, radfit, radlattice, rankindex, rarefy, rarecurve, raupcrick, rda, renyiaccum, renyi, rrarefy, scores, scoverage, @@ -45,8 +45,8 @@ export(as.fisher, as.mlm, as.preston, as.rad, fieller.MOStest, fisher.alpha, kendall.global, kendall.post, make.cepnames, mantel.correlog, mantel.partial, no.shared, rad.lognormal, rad.null, -rad.preempt, rad.zipf, rad.zipfbrot, read.cep, rgl.isomap, -rgl.renyiaccum, vif.cca) +rad.preempt, rad.zipf, rad.zipfbrot, read.cep, +vif.cca) ## Export panel functions export(panel.ordi, panel.ordiarrows, panel.ordi3d, prepanel.ordi3d) @@ -71,9 +71,9 @@ import(parallel) import(tcltk) importFrom(MASS, isoMDS, sammon, Shepard, mvrnorm) -import(rgl) importFrom(cluster, daisy) -importFrom(mgcv, gam) +## 's' must be imported in mgcv < 1.8-0 (not needed later) +importFrom(mgcv, gam, s, te) ## Registration of S3 methods defined in vegan # adipart: vegan S3method(adipart, default) Modified: pkg/vegan/R/CCorA.R =================================================================== --- pkg/vegan/R/CCorA.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/CCorA.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,5 +1,5 @@ `CCorA` <- - function(Y, X, stand.Y = FALSE, stand.X = FALSE, nperm = 0, ...) + function(Y, X, stand.Y = FALSE, stand.X = FALSE, permutations = 0, ...) { epsilon <- sqrt(.Machine$double.eps) ## @@ -156,16 +156,12 @@ df2 <- (n - max(pp,qq) - 1) Fval <- (PillaiTrace*df2)/((s-PillaiTrace)*df1) p.Pillai <- pf(Fval, s*df1, s*df2, lower.tail=FALSE) - if (length(nperm) == 1) { - if (nperm > 0) - permat <- t(replicate(nperm, permuted.index(n, ...))) - } else { - permat <- as.matrix(nperm) - if (ncol(permat) != n) - stop(gettextf("'permutations' have %d columns, but data have %d rows", - ncol(permat), n)) - nperm <- nrow(permat) - } + permat <- getPermuteMatrix(permutations, n, ...) + nperm <- nrow(permat) + if (ncol(permat) != n) + stop(gettextf("'permutations' have %d columns, but data have %d rows", + ncol(permat), n)) + if (nperm > 0) { p.perm <- sapply(1:nperm, function(indx, ...) probPillai(Y[permat[indx,],] , X, n, S11.inv, S22.inv, s, Modified: pkg/vegan/R/SSarrhenius.R =================================================================== --- pkg/vegan/R/SSarrhenius.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/SSarrhenius.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -3,7 +3,7 @@ function(mCall, data, LHS) { xy <- sortedXyData(mCall[["area"]], LHS, data) - value <- as.vector(coef(lm(log(xy[,"y"]) ~ log(xy[,"x"])))) + value <- as.vector(coef(lm(log(pmax(xy[,"y"],1)) ~ log(xy[,"x"])))) value[1] <- exp(value[1]) names(value) <- mCall[c("k","z")] value Modified: pkg/vegan/R/adonis.R =================================================================== --- pkg/vegan/R/adonis.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/adonis.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -90,58 +90,52 @@ ) } ## Permutations - if (length(permutations) == 1) { - if (missing(strata)) - strata <- NULL - p <- replicate(permutations, - permuted.index(n, strata=strata)) - } else { - p <- t(as.matrix(permutations)) - if (nrow(p) != n) - stop(gettextf("'permutations' have %d columns, but data have %d rows", - ncol(p), n)) - permutations <- ncol(p) - } - - tH.s <- lapply(H.s, t) - ## Apply permutations for each term - ## This is the new f.test (2011-06-15) that uses fewer arguments - ## Set first parallel processing for all terms - if (is.null(parallel)) - parallel <- 1 - hasClus <- inherits(parallel, "cluster") - isParal <- (hasClus || parallel > 1) && require(parallel) - isMulticore <- .Platform$OS.type == "unix" && !hasClus - if (isParal && !isMulticore && !hasClus) { - parallel <- makeCluster(parallel) - } - if (isParal) { - if (isMulticore) { - f.perms <- - sapply(1:nterms, function(i) - unlist(mclapply(1:permutations, function(j) - f.test(tH.s[[i]], G[p[,j], p[,j]], - df.Exp[i], df.Res, tIH.snterm), - mc.cores = parallel))) + p <- getPermuteMatrix(permutations, n, strata = strata) + permutations <- nrow(p) + if (permutations) { + tH.s <- lapply(H.s, t) + ## Apply permutations for each term + ## This is the new f.test (2011-06-15) that uses fewer arguments + ## Set first parallel processing for all terms + if (is.null(parallel)) + parallel <- 1 + hasClus <- inherits(parallel, "cluster") + isParal <- (hasClus || parallel > 1) && require(parallel) + isMulticore <- .Platform$OS.type == "unix" && !hasClus + if (isParal && !isMulticore && !hasClus) { + parallel <- makeCluster(parallel) + } + if (isParal) { + if (isMulticore) { + f.perms <- + sapply(1:nterms, function(i) + unlist(mclapply(1:permutations, function(j) + f.test(tH.s[[i]], G[p[j,], p[j,]], + df.Exp[i], df.Res, tIH.snterm), + mc.cores = parallel))) + } else { + f.perms <- + sapply(1:nterms, function(i) + parSapply(parallel, 1:permutations, function(j) + f.test(tH.s[[i]], G[p[j,], p[j,]], + df.Exp[i], df.Res, tIH.snterm))) + } } else { f.perms <- - sapply(1:nterms, function(i) - parSapply(parallel, 1:permutations, function(j) - f.test(tH.s[[i]], G[p[,j], p[,j]], - df.Exp[i], df.Res, tIH.snterm))) + sapply(1:nterms, function(i) + sapply(1:permutations, function(j) + f.test(tH.s[[i]], G[p[j,], p[j,]], + df.Exp[i], df.Res, tIH.snterm))) } - } else { - f.perms <- - sapply(1:nterms, function(i) - sapply(1:permutations, function(j) - f.test(tH.s[[i]], G[p[,j], p[,j]], - df.Exp[i], df.Res, tIH.snterm))) + ## Close socket cluster if created here + if (isParal && !isMulticore && !hasClus) + stopCluster(parallel) + ## Round to avoid arbitrary P-values with tied data + f.perms <- round(f.perms, 12) + P <- (rowSums(t(f.perms) >= F.Mod)+1)/(permutations+1) + } else { # no permutations + f.perms <- P <- rep(NA, nterms) } - ## Close socket cluster if created here - if (isParal && !isMulticore && !hasClus) - stopCluster(parallel) - ## Round to avoid arbitrary P-values with tied data - f.perms <- round(f.perms, 12) F.Mod <- round(F.Mod, 12) SumsOfSqs = c(SS.Exp.each, SS.Res, sum(SS.Exp.each) + SS.Res) tab <- data.frame(Df = c(df.Exp, df.Res, n-1), @@ -149,8 +143,7 @@ MeanSqs = c(SS.Exp.each/df.Exp, SS.Res/df.Res, NA), F.Model = c(F.Mod, NA,NA), R2 = SumsOfSqs/SumsOfSqs[length(SumsOfSqs)], - P = c((rowSums(t(f.perms) >= F.Mod)+1)/(permutations+1), - NA, NA)) + P = c(P, NA, NA)) rownames(tab) <- c(attr(attr(rhs.frame, "terms"), "term.labels")[u.grps], "Residuals", "Total") colnames(tab)[ncol(tab)] <- "Pr(>F)" Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/anosim.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,6 +1,6 @@ `anosim` <- function (dat, grouping, permutations = 999, - distance = "bray", strata, parallel = getOption("mc.cores")) + distance = "bray", strata = NULL, parallel = getOption("mc.cores")) { if (inherits(dat, "dist")) x <- dat @@ -35,39 +35,37 @@ tmp.ave <- tapply(x.rank, tmp.within, mean) -diff(tmp.ave)/div } - if (length(permutations) == 1) { - if (permutations > 0) { - arg <- if (missing(strata)) NULL else strata - permat <- t(replicate(permutations, permuted.index(N, strata = arg))) - } - } else { - permat <- as.matrix(permutations) - if (ncol(permat) != N) - stop(gettextf("'permutations' have %d columns, but data have %d rows", - ncol(permat), N)) - permutations <- nrow(permat) - } - ## Parallel processing - if (is.null(parallel)) - parallel <- 1 - hasClus <- inherits(parallel, "cluster") - if ((hasClus || parallel > 1) && require(parallel)) { - if(.Platform$OS.type == "unix" && !hasClus) { - perm <- unlist(mclapply(1:permutations, function(i, ...) - ptest(permat[i,]), - mc.cores = parallel)) - } else { - if (!hasClus) { - parallel <- makeCluster(parallel) + permat <- getPermuteMatrix(permutations, N, strata = strata) + if (ncol(permat) != N) + stop(gettextf("'permutations' have %d columns, but data have %d rows", + ncol(permat), N)) + permutations <- nrow(permat) + + if (permutations) { + ## Parallel processing + if (is.null(parallel)) + parallel <- 1 + hasClus <- inherits(parallel, "cluster") + if ((hasClus || parallel > 1) && require(parallel)) { + if(.Platform$OS.type == "unix" && !hasClus) { + perm <- unlist(mclapply(1:permutations, function(i, ...) + ptest(permat[i,]), + mc.cores = parallel)) + } else { + if (!hasClus) { + parallel <- makeCluster(parallel) + } + perm <- parRapply(parallel, permat, ptest) + if (!hasClus) + stopCluster(parallel) } - perm <- parRapply(parallel, permat, ptest) - if (!hasClus) - stopCluster(parallel) + } else { + perm <- sapply(1:permutations, function(i) ptest(permat[i,])) } - } else { - perm <- sapply(1:permutations, function(i) ptest(permat[i,])) + p.val <- (1 + sum(perm >= statistic))/(1 + permutations) + } else { # no permutations + p.val <- perm <- NA } - p.val <- (1 + sum(perm >= statistic))/(1 + permutations) sol$signif <- p.val sol$perm <- perm sol$permutations <- permutations Modified: pkg/vegan/R/anova.cca.R =================================================================== --- pkg/vegan/R/anova.cca.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/anova.cca.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -5,31 +5,12 @@ cutoff = 1, scope = NULL) { model <- match.arg(model) - ## permutations is either a single number, a how() structure or a ## permutation matrix - if (length(permutations) == 1) { - nperm <- permutations - permutations <- how(nperm = nperm) - } - if (!is.null(strata)) { - if (!inherits(permutations, "how")) - stop("'strata' can be used only with simple permutation or with 'how()'") - if (!is.null(permutations$block)) - stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") - setBlocks(permutations) <- strata - } - ## now permutations is either a how() structure or a permutation - ## matrix. Make it to a matrix if it is "how" - if (inherits(permutations, "how")) { - permutations <- shuffleSet(nrow(object$CA$u), - control = permutations) - seed <- attr(permutations, "seed") - control <- attr(permutations, "control") - } - else # we got a permutation matrix and seed & control are unknown - seed <- control <- NULL + N <- nrow(object$CA$u) + permutations <- getPermuteMatrix(permutations, N, strata = strata) + seed <- attr(permutations, "seed") + control <- attr(permutations, "control") nperm <- nrow(permutations) - ## stop permutations block ## see if this was a list of ordination objects dotargs <- list(...) ## we do not want to give dotargs to anova.ccalist, but we Modified: pkg/vegan/R/envfit.default.R =================================================================== --- pkg/vegan/R/envfit.default.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/envfit.default.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,5 +1,5 @@ `envfit.default` <- - function (ord, env, permutations = 999, strata, choices = c(1, 2), + function (ord, env, permutations = 999, strata = NULL, choices = c(1, 2), display = "sites", w = weights(ord), na.rm = FALSE, ...) { weights.default <- function(object, ...) NULL @@ -18,18 +18,11 @@ } ## make permutation matrix for all variables handled in the next loop nr <- nrow(X) - if (length(permutations) == 1) { - if (permutations > 0 ) { - arg <- if (missing(strata)) NULL else strata - permutations <- t(replicate(permutations, - permuted.index(nr, strata=arg))) - } - } else { - permat <- as.matrix(permutations) - if (ncol(permat) != nr) - stop(gettextf("'permutations' have %d columns, but data have %d rows", - ncol(permat), nr)) - } + permat <- getPermuteMatrix(permutations, nr, strata = strata) + if (ncol(permat) != nr) + stop(gettextf("'permutations' have %d columns, but data have %d rows", + ncol(permat), nr)) + if (is.data.frame(env)) { vects <- sapply(env, is.numeric) if (any(!vects)) { # have factors Modified: pkg/vegan/R/factorfit.R =================================================================== --- pkg/vegan/R/factorfit.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/factorfit.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,5 +1,5 @@ `factorfit` <- - function (X, P, permutations = 0, strata, w, ...) + function (X, P, permutations = 0, strata = NULL, w, ...) { P <- as.data.frame(P) ## Check that all variables are factors, and coerce if necessary @@ -24,16 +24,9 @@ sol <- centroids.cca(X, P, w) var.id <- rep(names(P), sapply(P, nlevels)) ## make permutation matrix for all variables handled in the next loop - if (length(permutations) == 1) { - if (permutations > 0) { - arg <- if (missing(strata)) NULL else strata - permat <- t(replicate(permutations, - permuted.index(NR, strata=arg))) - } - } else { - permat <- as.matrix(permutations) - permutations <- nrow(permutations) - } + permat <- getPermuteMatrix(permutations, NR, strata = strata) + permutations <- nrow(permat) + for (i in 1:length(P)) { A <- as.integer(P[[i]]) NL <- nlevels(P[[i]]) Added: pkg/vegan/R/getPermuteMatrix.R =================================================================== --- pkg/vegan/R/getPermuteMatrix.R (rev 0) +++ pkg/vegan/R/getPermuteMatrix.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -0,0 +1,36 @@ +### Interface to the permute package + +### input can be (1) a single number giving the number of +### permutations, (2) a how() structure for control parameter in +### permute::shuffleSet, or (3) a permutation matrix which is returned +### as is. In addition, there can be a 'strata' argument which will +### modify case (1). The number of shuffled items must be given in 'N'. + +`getPermuteMatrix` <- + function(perm, N, strata = NULL) +{ + ## 'perm' is either a single number, a how() structure or a + ## permutation matrix + if (length(perm) == 1) { + perm <- how(nperm = perm) + } + ## apply 'strata' + if (!is.null(strata)) { + if (!inherits(perm, "how")) # 'perm' is a matrix + stop("'strata' can be used only with simple permutation or with 'how()'") + if (!is.null(getBlocks(perm))) + stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") + setBlocks(perm) <- strata + } + ## now 'perm' is either a how() or a matrix + if (inherits(perm, "how")) + perm <- shuffleSet(N, control = perm) + ## now 'perm' is a matrix (or always was). If it is a plain + ## matrix, set minimal attributes for printing. This is a dirty + ## kluge: should be handled more cleanly. + if (is.null(attr(perm, "control"))) + attr(perm, "control") <- + structure(list(within=list(type="supplied matrix"), + nperm = nrow(perm)), class = "how") + perm +} Modified: pkg/vegan/R/howHead.R =================================================================== --- pkg/vegan/R/howHead.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/howHead.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -2,9 +2,9 @@ ### permute:::print.how, but only displays non-default choices in how(). `howHead` <- function(x, ...) { - ## this should always work + ## print nothing is this not 'how' if (is.null(x) || !inherits(x, "how")) - stop("not a 'how' object: contact the package maintainer") + return() ## collect header head <- NULL ## blocks Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/mantel.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,6 +1,6 @@ `mantel` <- function (xdis, ydis, method = "pearson", permutations = 999, - strata, na.rm = FALSE, parallel = getOption("mc.cores")) + strata = NULL, na.rm = FALSE, parallel = getOption("mc.cores")) { xdis <- as.dist(xdis) ydis <- as.vector(as.dist(ydis)) @@ -17,19 +17,12 @@ spearman = "Spearman's rank correlation rho", variant) N <- attr(xdis, "Size") - if (length(permutations) == 1) { - if (permutations > 0) { - arg <- if (missing(strata)) NULL else strata - permat <- t(replicate(permutations, - permuted.index(N, strata = arg))) - } - } else { - permat <- as.matrix(permutations) - if (ncol(permat) != N) - stop(gettextf("'permutations' have %d columns, but data have %d observations", - ncol(permat), N)) - permutations <- nrow(permutations) - } + permat <- getPermuteMatrix(permutations, N, strata = strata) + if (ncol(permat) != N) + stop(gettextf("'permutations' have %d columns, but data have %d observations", + ncol(permat), N)) + permutations <- nrow(permat) + if (permutations) { perm <- numeric(permutations) ## asdist as an index selects lower diagonal like as.dist, Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/mantel.partial.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,6 +1,6 @@ `mantel.partial` <- function (xdis, ydis, zdis, method = "pearson", permutations = 999, - strata, na.rm = FALSE, parallel = getOption("mc.cores")) + strata = NULL, na.rm = FALSE, parallel = getOption("mc.cores")) { part.cor <- function(rxy, rxz, ryz) { (rxy - rxz * ryz)/sqrt(1-rxz*rxz)/sqrt(1-ryz*ryz) @@ -24,19 +24,12 @@ variant) statistic <- part.cor(rxy, rxz, ryz) N <- attr(xdis, "Size") - if (length(permutations) == 1) { - if (permutations > 0) { - arg <- if(missing(strata)) NULL else strata - permat <- t(replicate(permutations, - permuted.index(N, strata = arg))) - } - } else { - permat <- as.matrix(permutations) - if (ncol(permat) != N) - stop(gettextf("'permutations' have %d columns, but data have %d observations", - ncol(permat), N)) - permutations <- nrow(permutations) - } + permat <- getPermuteMatrix(permutations, N, strata = strata) + if (ncol(permat) != N) + stop(gettextf("'permutations' have %d columns, but data have %d observations", + ncol(permat), N)) + permutations <- nrow(permat) + if (permutations) { N <- attr(xdis, "Size") perm <- rep(0, permutations) Modified: pkg/vegan/R/mrpp.R =================================================================== --- pkg/vegan/R/mrpp.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/mrpp.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,6 +1,7 @@ -"mrpp" <- -function (dat, grouping, permutations = 999, distance = "euclidean", - weight.type = 1, strata, parallel = getOption("mc.cores")) +`mrpp` <- + function (dat, grouping, permutations = 999, distance = "euclidean", + weight.type = 1, strata = NULL, + parallel = getOption("mc.cores")) { classmean <- function(ind, dmat, indls) { sapply(indls, function(x) @@ -37,41 +38,43 @@ ## significance test for it. Keep the item in reserve for ## possible later re-inclusion. CS <- NA - if (length(permutations) == 1) { - if (missing(strata)) - strata <- NULL - perms <- sapply(1:permutations, - function(x) grouping[permuted.index(N, strata = strata)]) - } else { + permutations <- getPermuteMatrix(permutations, N, strata = strata) + if (ncol(permutations) != N) + stop(gettextf("'permutations' have %d columns, but data have %d rows", + ncol(permutations), N)) + + + if(nrow(permutations)) { perms <- apply(permutations, 1, function(indx) grouping[indx]) permutations <- ncol(perms) - if (nrow(perms) != N) - stop(gettextf("'permutations' have %d columns, but data have %d rows", - ncol(perms), N)) - } - ## Parallel processing - if (is.null(parallel)) - parallel <- 1 - hasClus <- inherits(parallel, "cluster") - if ((hasClus || parallel > 1) && require(parallel)) { - if(.Platform$OS.type == "unix" && !hasClus) { - m.ds <- unlist(mclapply(1:permutations, function(i, ...) - mrpp.perms(perms[,i], dmat, indls, w), - mc.cores = parallel)) + + ## Parallel processing + if (is.null(parallel)) + parallel <- 1 + hasClus <- inherits(parallel, "cluster") + if ((hasClus || parallel > 1) && require(parallel)) { + if(.Platform$OS.type == "unix" && !hasClus) { + m.ds <- unlist(mclapply(1:permutations, function(i, ...) + mrpp.perms(perms[,i], dmat, indls, w), + mc.cores = parallel)) + } else { + if (!hasClus) { + parallel <- makeCluster(parallel) + } + m.ds <- parCapply(parallel, perms, function(x) + mrpp.perms(x, dmat, indls, w)) + if (!hasClus) + stopCluster(parallel) + } } else { - if (!hasClus) { - parallel <- makeCluster(parallel) - } - m.ds <- parCapply(parallel, perms, function(x) - mrpp.perms(x, dmat, indls, w)) - if (!hasClus) - stopCluster(parallel) + m.ds <- apply(perms, 2, function(x) mrpp.perms(x, dmat, indls, w)) } - } else { - m.ds <- apply(perms, 2, function(x) mrpp.perms(x, dmat, indls, w)) + p <- (1 + sum(del >= m.ds))/(permutations + 1) + r2 <- 1 - del/E.del + } else { # no permutations + m.ds <- p <- r2 <- NA + permutations <- 0 } - p <- (1 + sum(del >= m.ds))/(permutations + 1) - r2 <- 1 - del/E.del out <- list(call = match.call(), delta = del, E.delta = E.del, CS = CS, n = ncl, classdelta = classdel, Pvalue = p, A = r2, distance = distance, weight.type = weight.type, Modified: pkg/vegan/R/mso.R =================================================================== --- pkg/vegan/R/mso.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/mso.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,6 +1,6 @@ `mso` <- function (object.cca, object.xy, grain = 1, round.up = FALSE, - permutations = FALSE) + permutations = 0) { if (inherits(object.cca, "mso")) { rm <- which(class(object.cca) == "mso") @@ -58,27 +58,27 @@ H), mean) object$vario <- cbind(object$vario, All = test$ca, CA = test$ca) } - if (permutations) { - ##require(base) + permat <- getPermuteMatrix(permutations, nrow(object$CA$Xbar)) + nperm <- nrow(permat) + if (nperm) { object$H.test <- matrix(0, length(object$H), nrow(object$vario)) for (i in 1:nrow(object$vario)) { object$H.test[, i] <- as.numeric(object$H == object$vario$H[i]) } - xdis <- dist(object$CA$Xbar)^2 - N <- attr(xdis, "Size") - statistic <- abs(cor(as.vector(xdis), object$H.test)) - perm <- matrix(0, length(statistic), permutations) - for (i in 1:permutations) { - take <- sample(N, N) - permvec <- as.vector(as.dist(as.matrix(xdis)[take, - take])) - perm[, i] <- abs(cor(permvec, object$H.test)) + xdis <- as.matrix(dist(object$CA$Xbar)^2) + ## taking lower triangle is faster than as.dist() because it + ## does not set attributes + ltri <- lower.tri(xdis) + statistic <- abs(cor(as.vector(xdis[ltri]), object$H.test)) + permfunc <- function(k) { + permvec <- as.vector(xdis[k,k][ltri]) + abs(cor(permvec, object$H.test)) } - object$vario$CA.signif <- apply((perm >= matrix(statistic, - nrow(perm), ncol(perm)))/permutations, 1, sum) + perm <- sapply(1:nperm, function(take) permfunc(permat[take,])) + object$vario$CA.signif <- + (rowSums(sweep(perm, 1, statistic, ">=")) + 1)/(nperm + 1) } object$call <- match.call() class(object) <- c("mso", class(object)) object } - Modified: pkg/vegan/R/nesteddisc.R =================================================================== --- pkg/vegan/R/nesteddisc.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/nesteddisc.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -28,7 +28,8 @@ ## Function to evaluate discrepancy FUN <- function(x) sum(comm[col(comm)[,x] <= rowSums(comm)] == 0) Ad <- FUN(x) - ## Go through all le-items and permute ties + ## Go through all le-items and permute ties. Functions allPerms + ## and shuffleSet are in permute package. for (i in 1:length(le)) { if (le[i] > 1) { take <- x @@ -49,7 +50,7 @@ ## duplicated orders else { ties <- TRUE - perm <- t(replicate(niter, permuted.index(le[i]))) + perm <- shuffleSet(le[i], niter) perm <- perm + cle[i] } vals <- sapply(1:nrow(perm), function(j) { Modified: pkg/vegan/R/oecosimu.R =================================================================== --- pkg/vegan/R/oecosimu.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/oecosimu.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -93,7 +93,9 @@ if ((hasClus || parallel > 1) && require(parallel)) { if(.Platform$OS.type == "unix" && !hasClus) { for (i in seq_len(nbatch)) { - x <- simulate(nm, nsim = batches[i], thin = thin) + ## simulate if no simmat_in + if(!simmat_in) + x <- simulate(nm, nsim = batches[i], thin = thin) tmp <- mclapply(seq_len(batches[i]), function(j) applynestfun(x[,,j], fun=nestfun, @@ -109,7 +111,8 @@ clusterEvalQ(parallel, library(vegan)) } for(i in seq_len(nbatch)) { - x <- simulate(nm, nsim = batches[i], thin = thin) + if (!simmat_in) + x <- simulate(nm, nsim = batches[i], thin = thin) simind <- cbind(simind, parApply(parallel, x, 3, function(z) applynestfun(z, fun = nestfun, @@ -120,7 +123,9 @@ } } else { for(i in seq_len(nbatch)) { - x <- simulate(nm, nsim = batches[i], thin = thin) + ## do not simulate if x was already a simulation + if(!simmat_in) + x <- simulate(nm, nsim = batches[i], thin = thin) simind <- cbind(simind, apply(x, 3, applynestfun, fun = nestfun, statistic = statistic, ...)) } Deleted: pkg/vegan/R/ordiplot3d.R =================================================================== --- pkg/vegan/R/ordiplot3d.R 2014-09-05 11:55:04 UTC (rev 2881) +++ pkg/vegan/R/ordiplot3d.R 2014-09-16 07:13:05 UTC (rev 2882) @@ -1,92 +0,0 @@ -`ordiplot3d` <- - function (object, display = "sites", choices = 1:3, ax.col = 2, - arr.len = 0.1, arr.col = 4, envfit, xlab, ylab, zlab, ...) -{ - require(scatterplot3d) || stop("Requires package 'scatterplot3d'") - x <- scores(object, display = display, choices = choices, ...) - if (missing(xlab)) xlab <- colnames(x)[1] - if (missing(ylab)) ylab <- colnames(x)[2] - if (missing(zlab)) zlab <- colnames(x)[3] - ### scatterplot3d does not allow setting equal aspect ratio. We - ### try to compensate this by setting equal limits for all axes - ### and hoping the graph is more or less square so that the lines - ### come correctly out. - rnge <- apply(x, 2, range) - scl <- c(-0.5, 0.5) * max(apply(rnge, 2, diff)) - pl <- ordiArgAbsorber(x[, 1], x[, 2], x[, 3], - xlab = xlab, ylab = ylab, zlab = zlab, - xlim = mean(rnge[,1]) + scl, - ylim = mean(rnge[,2]) + scl, - zlim = mean(rnge[,3]) + scl, - FUN = "scatterplot3d", ...) - pl$points3d(range(x[, 1]), c(0, 0), c(0, 0), type = "l", - col = ax.col) - pl$points3d(c(0, 0), range(x[, 2]), c(0, 0), type = "l", [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2882 From noreply at r-forge.r-project.org Tue Sep 16 16:13:14 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 16 Sep 2014 16:13:14 +0200 (CEST) Subject: [Vegan-commits] r2883 - in pkg/vegan: R man Message-ID: <20140916141314.8AED618712F@r-forge.r-project.org> Author: jarioksa Date: 2014-09-16 16:13:14 +0200 (Tue, 16 Sep 2014) New Revision: 2883 Modified: pkg/vegan/R/CCorA.R pkg/vegan/R/adonis.R pkg/vegan/R/anosim.R pkg/vegan/R/factorfit.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R pkg/vegan/R/mrpp.R pkg/vegan/R/mso.R pkg/vegan/R/print.CCorA.R pkg/vegan/R/print.anosim.R pkg/vegan/R/print.factorfit.R pkg/vegan/R/print.mantel.R pkg/vegan/R/print.mrpp.R pkg/vegan/R/print.mso.R pkg/vegan/R/print.permutest.betadisper.R pkg/vegan/R/print.protest.R pkg/vegan/R/print.vectorfit.R pkg/vegan/R/simper.R pkg/vegan/R/vectorfit.R pkg/vegan/man/CCorA.Rd pkg/vegan/man/anosim.Rd pkg/vegan/man/envfit.Rd pkg/vegan/man/mantel.Rd pkg/vegan/man/mrpp.Rd pkg/vegan/man/procrustes.Rd Log: Squashed commit of the following: commit 33198cba46810c1265f0ba6061225b038272a24f Merge: 0f86b2b 12aa1f2 Author: Jari Oksanen Date: Tue Sep 16 17:05:15 2014 +0300 Merge pull request #39 from jarioksa/adapt-print-to-permute-pkg Adapt print to permute pkg commit 12aa1f2555126075ab3fa9fe9ca6a98aa684f73d Author: Jari Oksanen Date: Tue Sep 16 16:06:49 2014 +0300 permutest.betadisper also uses howHead() to show permutations commit 9526decb88cc91ef7db565cafc0adca06989512b Author: Jari Oksanen Date: Mon Sep 15 21:37:31 2014 +0300 Document cases when a function returns a "control" item Some functions return "control" *attributes* with some of their items: this is not (yet?) documented. commit 61df5998b0695dee2a5784eee79de083b1eba308 Author: Jari Oksanen Date: Mon Sep 15 21:30:02 2014 +0300 CCorA returns permute "control" and print uses howHead() to show it commit 31c401289c14af2790fa733e72ba05cb695f1179 Author: Jari Oksanen Date: Mon Sep 15 21:18:34 2014 +0300 simper adds "control" attribute for permutations and summary prints it commit ecce8c723d5e1b68e251e8c16d167af27b0b5a3e Author: Jari Oksanen Date: Mon Sep 15 21:08:34 2014 +0300 Add empty line between results and permutation details commit a0333a2640742df2493ae0a75b16b0b17a27b393 Author: Jari Oksanen Date: Mon Sep 15 19:17:20 2014 +0300 mso adds "control" attribute to the "vario" item and howHead() shows it commit 711938bd8836a0cdb6210d8c536a8a831986aece Author: Jari Oksanen Date: Mon Sep 15 18:56:17 2014 +0300 remove dangling '.' from the output commit 5ca3ecc14686f89b23902f28c4910d3279c6b968 Author: Jari Oksanen Date: Mon Sep 15 18:43:45 2014 +0300 adonis adds howHead() to the heading of the anova table The permutation information is printed similarly as in anova.cca. commit 16dc86254cb8d692511bcc71759f03e1bb2f6ec9 Author: Jari Oksanen Date: Sun Sep 14 20:19:00 2014 +0300 mrpp printing to the new permute API: no more strata commit 3728b825dda5303788231414c7f3f1e1735c293e Author: Jari Oksanen Date: Sun Sep 14 19:37:58 2014 +0300 mantel printing to the new permute API: no more strata commit 03f764df31f5528012cd8e55e9bb77d884741e7e Author: Jari Oksanen Date: Sun Sep 14 09:10:23 2014 +0300 adapt envfit printing to the new permute API: no more strata commit 808cb0c1a0ddafcea99e1f04de16ef4e9b25dfad Author: Jari Oksanen Date: Sun Sep 14 08:40:37 2014 +0300 print of anosim adapted to the new permute API No more stores 'strata', but 'control' and uses howHead() to show its result. It seems that getPermuteMatrix(..., strata=) does not save the name of the 'strata', but howHead() just prints "Blocks: strata". Modified: pkg/vegan/R/CCorA.R =================================================================== --- pkg/vegan/R/CCorA.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/CCorA.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -177,7 +177,8 @@ RDA.adj.Rsq=c(Rsquare.adj.Y.X, Rsquare.adj.X.Y), nperm=nperm, p.Pillai=p.Pillai, p.perm=p.perm, Cy=Cy, Cx=Cx, corr.Y.Cy=corr.Y.Cy, corr.X.Cx=corr.X.Cx, corr.Y.Cx=corr.Y.Cx, - corr.X.Cy=corr.X.Cy, call = match.call()) + corr.X.Cy=corr.X.Cy, control = attr(permat, "control"), + call = match.call()) class(out) <- "CCorA" out } Modified: pkg/vegan/R/adonis.R =================================================================== --- pkg/vegan/R/adonis.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/adonis.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -147,7 +147,8 @@ rownames(tab) <- c(attr(attr(rhs.frame, "terms"), "term.labels")[u.grps], "Residuals", "Total") colnames(tab)[ncol(tab)] <- "Pr(>F)" - attr(tab, "heading") <- "Terms added sequentially (first to last)\n" + attr(tab, "heading") <- c(howHead(attr(p, "control")), + "Terms added sequentially (first to last)\n") class(tab) <- c("anova", class(tab)) out <- list(aov.tab = tab, call = match.call(), coefficients = beta.spp, coef.sites = beta.sites, Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/anosim.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -72,11 +72,8 @@ sol$statistic <- as.numeric(statistic) sol$class.vec <- cl.vec sol$dis.rank <- x.rank - sol$dissimilarity <- attr(x, "method") - if (!missing(strata)) { - sol$strata <- deparse(substitute(strata)) - sol$stratum.values <- strata - } + sol$dissimilarity <- attr(x, "method") + sol$control <- attr(permat, "control") class(sol) <- "anosim" sol } Modified: pkg/vegan/R/factorfit.R =================================================================== --- pkg/vegan/R/factorfit.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/factorfit.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -62,10 +62,7 @@ names(pval) <- names(P) out <- list(centroids = sol, r = r, permutations = permutations, pvals = pval, var.id = var.id) - if (!missing(strata)) { - out$strata <- deparse(substitute(strata)) - out$stratum.values <- strata - } + out$control <- attr(permat, "control") class(out) <- "factorfit" out } Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/mantel.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -61,11 +61,8 @@ perm <- NULL } res <- list(call = match.call(), method = variant, statistic = statistic, - signif = signif, perm = perm, permutations = permutations) - if (!missing(strata)) { - res$strata <- deparse(substitute(strata)) - res$stratum.values <- strata - } + signif = signif, perm = perm, permutations = permutations, + control = attr(permat, "control")) class(res) <- "mantel" res } Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/mantel.partial.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -69,7 +69,8 @@ perm <- NULL } res <- list(call = match.call(), method = variant, statistic = statistic, - signif = signif, perm = perm, permutations = permutations) + signif = signif, perm = perm, permutations = permutations, + control = attr(permat, "control")) if (!missing(strata)) { res$strata <- deparse(substitute(strata)) res$stratum.values <- strata Modified: pkg/vegan/R/mrpp.R =================================================================== --- pkg/vegan/R/mrpp.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/mrpp.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -43,7 +43,7 @@ stop(gettextf("'permutations' have %d columns, but data have %d rows", ncol(permutations), N)) - + control <- attr(permutations, "control") if(nrow(permutations)) { perms <- apply(permutations, 1, function(indx) grouping[indx]) permutations <- ncol(perms) @@ -76,13 +76,10 @@ permutations <- 0 } out <- list(call = match.call(), delta = del, E.delta = E.del, CS = CS, - n = ncl, classdelta = classdel, - Pvalue = p, A = r2, distance = distance, weight.type = weight.type, - boot.deltas = m.ds, permutations = permutations) - if (!missing(strata) && !is.null(strata)) { - out$strata <- deparse(substitute(strata)) - out$stratum.values <- strata - } + n = ncl, classdelta = classdel, Pvalue = p, A = r2, + distance = distance, weight.type = weight.type, + boot.deltas = m.ds, permutations = permutations, + control = control) class(out) <- "mrpp" out } Modified: pkg/vegan/R/mso.R =================================================================== --- pkg/vegan/R/mso.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/mso.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -77,6 +77,7 @@ perm <- sapply(1:nperm, function(take) permfunc(permat[take,])) object$vario$CA.signif <- (rowSums(sweep(perm, 1, statistic, ">=")) + 1)/(nperm + 1) + attr(object$vario, "control") <- attr(permat, "control") } object$call <- match.call() class(object) <- c("mso", class(object)) Modified: pkg/vegan/R/print.CCorA.R =================================================================== --- pkg/vegan/R/print.CCorA.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.CCorA.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -10,11 +10,13 @@ cat("Pillai's trace: ", format(x$Pillai, ...), "\n") cat("\n") cat("Significance of Pillai's trace:\n") + + cat("from F-distribution: ", format.pval(x$p.Pillai), "\n") if (x$nperm > 0) { - cat("based on", x$nperm, "permutations: ") + cat("based on permutations: ") cat(x$p.perm,"\n") + cat(howHead(x$control), "\n") } - cat("from F-distribution: ", format.pval(x$p.Pillai), "\n\n") out <- rbind("Eigenvalues" = x$EigenValues, "Canonical Correlations" = x$CanCorr) colnames(out) <- colnames(x$Cy) printCoefmat(out, ...) Modified: pkg/vegan/R/print.anosim.R =================================================================== --- pkg/vegan/R/print.anosim.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.anosim.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -1,4 +1,4 @@ -"print.anosim" <- +`print.anosim` <- function (x, digits = max(3, getOption("digits") - 3), ...) { cat("\nCall:\n") @@ -10,10 +10,8 @@ if (nperm) { cat(" Significance:", format.pval(x$signif), "\n\n") - cat("Based on ", nperm, " permutations") + cat(howHead(x$control)) } - if (!is.null(x$strata)) - cat(", stratified within", x$strata) - cat("\n\n") + cat("\n") invisible(x) } Modified: pkg/vegan/R/print.factorfit.R =================================================================== --- pkg/vegan/R/print.factorfit.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.factorfit.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -1,4 +1,4 @@ -"print.factorfit" <- +`print.factorfit` <- function (x, ...) { cat("Centroids:\n") @@ -7,10 +7,7 @@ out <- cbind(r2 = x$r, "Pr(>r)" = x$pvals) if (x$permutations) { printCoefmat(out, has.Pvalue = TRUE, ...) - cat("P values based on", x$permutations, "permutations") - if (!is.null(x$strata)) - cat(", stratified within", x$strata) - cat(".\n") + cat(howHead(x$control)) } else printCoefmat(out, na.print = "", ...) invisible(x) Modified: pkg/vegan/R/print.mantel.R =================================================================== --- pkg/vegan/R/print.mantel.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.mantel.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -16,11 +16,9 @@ out <- quantile(x$perm, c(0.9, 0.95, 0.975, 0.99)) cat("Upper quantiles of permutations (null model):\n") print(out, digits = 3) - cat("\nBased on", nperm, "permutations") - if (!is.null(x$strata)) - cat(", stratified within", x$strata) + cat(howHead(x$control)) } - cat("\n\n") + cat("\n") invisible(x) } Modified: pkg/vegan/R/print.mrpp.R =================================================================== --- pkg/vegan/R/print.mrpp.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.mrpp.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -28,9 +28,7 @@ cat("Significance of delta:", format.pval(x$Pvalue), "\n") } - cat("Based on ", nperm, " permutations") - if (!is.null(x$strata)) - cat(", stratified within", x$strata) - cat("\n\n") + cat(howHead(x$control)) + cat("\n") invisible(x) } Modified: pkg/vegan/R/print.mso.R =================================================================== --- pkg/vegan/R/print.mso.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.mso.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -4,6 +4,8 @@ NextMethod("print", x, digits = digits, ...) cat("mso variogram:\n\n") print(x$vario, digits = digits, ...) + if(!is.null(attr(x$vario, "control"))) + cat("\n", howHead(attr(x$vario, "control")), "\n", sep="") invisible(x) } Modified: pkg/vegan/R/print.permutest.betadisper.R =================================================================== --- pkg/vegan/R/print.permutest.betadisper.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.permutest.betadisper.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -5,7 +5,7 @@ cat("\n") writeLines(strwrap("Permutation test for homogeneity of multivariate dispersions\n")) ##cat("\n") - print(x$control) + cat(howHead(x$control)) nc <- dim(x$tab)[2] cn <- colnames(x$tab) has.P <- substr(cn[nc], 1, 3) == "Pr(" Modified: pkg/vegan/R/print.protest.R =================================================================== --- pkg/vegan/R/print.protest.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.protest.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -8,7 +8,7 @@ cat("Correlation in a symmetric Procrustes rotation: ") cat(formatC(x$t0, digits = digits), "\n") cat("Significance: ") - cat(format.pval(x$signif),"\n") + cat(format.pval(x$signif),"\n\n") cat(howHead(x$control)) cat("\n") invisible(x) Modified: pkg/vegan/R/print.vectorfit.R =================================================================== --- pkg/vegan/R/print.vectorfit.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/print.vectorfit.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -5,10 +5,7 @@ printCoefmat(out, na.print = "", zap.ind = seq_len(ncol(out)-2), ...) if (x$permutations) { - cat("P values based on", x$permutations, "permutations") - if (!is.null(x$strata)) - cat(", stratified within", x$strata) - cat(".\n") + cat(howHead(x$control)) } invisible(x) } Modified: pkg/vegan/R/simper.R =================================================================== --- pkg/vegan/R/simper.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/simper.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -100,6 +100,7 @@ if (isParal && !isMulticore && !hasClus) stopCluster(parallel) attr(outlist, "permutations") <- nperm + attr(outlist, "control") <- attr(perm, "control") class(outlist) <- "simper" outlist } @@ -141,6 +142,7 @@ } attr(out, "digits") <- digits attr(out, "permutations") <- attr(object, "permutations") + attr(out, "control") <- attr(object, "control") class(out) <- "summary.simper" out } @@ -167,8 +169,8 @@ symbols = c("***", "**", "*", ".", " ")), "legend") cat("---\nSignif. codes: ", leg, "\n") } - if ((np <- attr(x, "permutations")) > 0) - cat("P-values based on", np, "permutations\n") + if (!is.null(attr(x, "control"))) + cat(howHead(attr(x, "control"))) invisible(x) } Modified: pkg/vegan/R/vectorfit.R =================================================================== --- pkg/vegan/R/vectorfit.R 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/R/vectorfit.R 2014-09-16 14:13:14 UTC (rev 2883) @@ -54,10 +54,7 @@ else pvals <- NULL sol <- list(arrows = heads, r = r, permutations = permutations, pvals = pvals) - if (!missing(strata)) { - sol$strata <- deparse(substitute(strata)) - sol$stratum.values <- strata - } + sol$control <- attr(permat, "control") class(sol) <- "vectorfit" sol } Modified: pkg/vegan/man/CCorA.Rd =================================================================== --- pkg/vegan/man/CCorA.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/CCorA.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -105,6 +105,8 @@ \item{ corr.X.Cx }{ Scores of X variables in X biplot, computed as cor(X,Cx). } \item{ corr.Y.Cx }{ cor(Y,Cy) available for plotting variables Y in space of X manually. } \item{ corr.X.Cy }{ cor(X,Cx) available for plotting variables X in space of Y manually. } + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} \item{ call }{ Call to the CCorA function. } } Modified: pkg/vegan/man/anosim.Rd =================================================================== --- pkg/vegan/man/anosim.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/anosim.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -85,6 +85,8 @@ \item{dis.rank}{Rank of dissimilarity entry.} \item{dissimilarity}{The name of the dissimilarity index: the \code{"method"} entry of the \code{dist} object.} + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} } \references{ Clarke, K. R. (1993). Non-parametric multivariate analysis of changes Modified: pkg/vegan/man/envfit.Rd =================================================================== --- pkg/vegan/man/envfit.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/envfit.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -162,6 +162,8 @@ \item{centroids}{Class centroids from \code{factorfit}.} \item{r}{Goodness of fit statistic: Squared correlation coefficient} \item{permutations}{Number of permutations.} + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} \item{pvals}{Empirical P-values for each variable.} Function \code{envfit} returns a list of class \code{envfit} with Modified: pkg/vegan/man/mantel.Rd =================================================================== --- pkg/vegan/man/mantel.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/mantel.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -73,6 +73,8 @@ permuted values can be inspected with \code{\link{density.mantel}} function.} \item{permutations}{Number of permutations.} + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} } \references{ The test is due to Mantel, of course, but the current implementation is based on Legendre and Legendre. Modified: pkg/vegan/man/mrpp.Rd =================================================================== --- pkg/vegan/man/mrpp.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/mrpp.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -148,6 +148,8 @@ calculated from each of the permuted datasets. The distribution of this item can be inspected with \code{\link{density.mrpp}} function.} \item{permutations}{The number of permutations used.} + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} } \references{ B. McCune and J. B. Grace. 2002. \emph{Analysis of Ecological Modified: pkg/vegan/man/procrustes.Rd =================================================================== --- pkg/vegan/man/procrustes.Rd 2014-09-16 07:13:05 UTC (rev 2882) +++ pkg/vegan/man/procrustes.Rd 2014-09-16 14:13:14 UTC (rev 2883) @@ -165,6 +165,8 @@ function.} \item{signif}{`Significance' of \code{t}} \item{permutations}{Number of permutations.} + \item{control}{A list of control values for the permutations + as returned by the function \code{\link[permute]{how}}.} \item{control}{the list passed to argument \code{control} describing the permutation design.} } From noreply at r-forge.r-project.org Wed Sep 17 13:29:20 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 17 Sep 2014 13:29:20 +0200 (CEST) Subject: [Vegan-commits] r2884 - in pkg/vegan: man tests/Examples Message-ID: <20140917112920.3CC7F18758A@r-forge.r-project.org> Author: jarioksa Date: 2014-09-17 13:29:19 +0200 (Wed, 17 Sep 2014) New Revision: 2884 Modified: pkg/vegan/man/goodness.cca.Rd pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/man/goodness.cca.Rd =================================================================== --- pkg/vegan/man/goodness.cca.Rd 2014-09-16 14:13:14 UTC (rev 2883) +++ pkg/vegan/man/goodness.cca.Rd 2014-09-17 11:29:19 UTC (rev 2884) @@ -32,7 +32,7 @@ \arguments{ \item{object}{A result object from \code{\link{cca}}, - \code{\link{rda}}, \code{\link{capscale}} or \code{\link{decorana}}. } + \code{\link{rda}} or \code{\link{capscale}}. } \item{display}{Display \code{"species"} or \code{"sites"}. } \item{choices}{Axes shown. Default is to show all axes of the \code{"model"}. } \item{model}{Show constrained (\code{"CCA"}) or unconstrained @@ -52,7 +52,7 @@ Function \code{goodness} gives the diagnostic statistics for species or sites. The alternative statistics are the cumulative proportion of inertia accounted for by the axes, and the residual distance left - unaccounted for. The conditional (``partialled out'') constraints are + unaccounted for. The conditional (\dQuote{partialled out}) constraints are always regarded as explained and included in the statistics. Function \code{inertcomp} decomposes the inertia into partial, @@ -124,7 +124,7 @@ } \seealso{\code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}}, - \code{\link{decorana}}, \code{\link[car]{vif}}. } + \code{\link[car]{vif}}. } \examples{ data(dune) data(dune.env) Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-09-16 14:13:14 UTC (rev 2883) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2014-09-17 11:29:19 UTC (rev 2884) @@ -1,5 +1,5 @@ -R Under development (unstable) (2014-09-03 r66516) -- "Unsuffered Consequences" +R Under development (unstable) (2014-09-15 r66611) -- "Unsuffered Consequences" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -23,7 +23,7 @@ > library('vegan') Loading required package: permute Loading required package: lattice -This is vegan 2.1-41 +This is vegan 2.1-43 > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > cleanEx() @@ -83,8 +83,7 @@ Pillai's trace: 4.573009 Significance of Pillai's trace: -from F-distribution: 0.0032737 - +from F-distribution: 0.0032737 CanAxis1 CanAxis2 CanAxis3 CanAxis4 CanAxis5 CanAxis6 Canonical Correlations 0.92810 0.82431 0.81209 0.74981 0.70795 0.65950 CanAxis7 CanAxis8 CanAxis9 CanAxis10 CanAxis11 @@ -104,13 +103,13 @@ > # Example using random numbers. No significant relationship is expected > mat1 <- matrix(rnorm(60),20,3) > mat2 <- matrix(rnorm(100),20,5) -> out2 = CCorA(mat1, mat2, nperm=99) +> out2 = CCorA(mat1, mat2, permutations=99) > out2 Canonical Correlation Analysis Call: -CCorA(Y = mat1, X = mat2, nperm = 99) +CCorA(Y = mat1, X = mat2, permutations = 99) Y X Matrix Ranks 3 5 @@ -118,9 +117,11 @@ Pillai's trace: 0.6455578 Significance of Pillai's trace: -based on 99 permutations: 0.69 -from F-distribution: 0.70352 - +from F-distribution: 0.70352 +based on permutations: 0.69 +Permutation: free +Number of permutations: 99 + CanAxis1 CanAxis2 CanAxis3 Canonical Correlations 0.69691 0.38140 0.12 @@ -159,7 +160,7 @@ Formula: y ~ poly(x1, 1) + poly(x2, 1) - + Total model degrees of freedom 3 REML score: -3.185099 @@ -624,6 +625,9 @@ Call: adonis(formula = dune ~ Management * A1, data = dune.env, permutations = 99) +Permutation: free +Number of permutations: 99 + Terms added sequentially (first to last) Df SumsOfSqs MeanSqs F.Model R2 Pr(>F) @@ -680,6 +684,10 @@ Call: adonis(formula = Y ~ NO3, data = dat, permutations = 999, strata = dat$field) +Blocks: strata +Permutation: free +Number of permutations: 999 + Terms added sequentially (first to last) Df SumsOfSqs MeanSqs F.Model R2 Pr(>F) @@ -695,6 +703,9 @@ Call: adonis(formula = Y ~ NO3, data = dat, permutations = 999) +Permutation: free +Number of permutations: 999 + Terms added sequentially (first to last) Df SumsOfSqs MeanSqs F.Model R2 Pr(>F) @@ -733,7 +744,8 @@ ANOSIM statistic R: 0.2579 Significance: 0.017 -Based on 999 permutations +Permutation: free +Number of permutations: 999 Upper quantiles of permutations (null model): 90% 95% 97.5% 99% @@ -1081,23 +1093,9 @@ > permutest(mod, pairwise = TRUE) Permutation test for homogeneity of multivariate dispersions +Permutation: free +Number of permutations: 999 -Permutation Design: - -Blocks: - Defined by: none - -Plots: - Defined by: none - -Within Plots: - Permutation type: free - -Permutation details: - Number of permutations requested: 999 - Max. number of permutations allowed: 9999 - Evaluate all permutations?: No. Activation limit: 99 - Response: Distances Df Sum Sq Mean Sq F N.Perm Pr(>F) Groups 1 0.07931 0.079306 4.6156 1000 0.05 * @@ -1252,23 +1250,9 @@ > permutest(mod2, control = how(nperm = 100)) Permutation test for homogeneity of multivariate dispersions +Permutation: free +Number of permutations: 999 -Permutation Design: - -Blocks: - Defined by: none - -Plots: - Defined by: none - -Within Plots: - Permutation type: free - -Permutation details: - Number of permutations requested: 999 - Max. number of permutations allowed: 9999 - Evaluate all permutations?: No. Activation limit: 99 - Response: Distances Df Sum Sq Mean Sq F N.Perm Pr(>F) Groups 1 0.039979 0.039979 2.4237 1000 0.115 @@ -1309,23 +1293,9 @@ > permutest(mod3, control = how(nperm = 100)) Permutation test for homogeneity of multivariate dispersions +Permutation: free +Number of permutations: 999 -Permutation Design: - -Blocks: - Defined by: none - -Plots: - Defined by: none - -Within Plots: - Permutation type: free - -Permutation details: - Number of permutations requested: 999 - Max. number of permutations allowed: 9999 - Evaluate all permutations?: No. Activation limit: 99 - Response: Distances Df Sum Sq Mean Sq F N.Perm Pr(>F) Groups 1 0.033468 0.033468 3.1749 1000 0.084 . @@ -2751,23 +2721,24 @@ ***VECTORS NMDS1 NMDS2 r2 Pr(>r) -N -0.05719 -0.99836 0.2537 0.046 * -P 0.61959 0.78492 0.1938 0.103 -K 0.76629 0.64249 0.1809 0.143 -Ca 0.68506 0.72849 0.4119 0.008 ** -Mg 0.63240 0.77464 0.4271 0.004 ** -S 0.19123 0.98155 0.1752 0.140 +N -0.05719 -0.99836 0.2537 0.039 * +P 0.61959 0.78492 0.1938 0.129 +K 0.76629 0.64249 0.1809 0.138 +Ca 0.68506 0.72849 0.4119 0.005 ** +Mg 0.63240 0.77464 0.4271 0.005 ** +S 0.19123 0.98155 0.1752 0.133 Al -0.87169 0.49006 0.5269 0.001 *** -Fe -0.93613 0.35164 0.4451 0.002 ** -Mn 0.79873 -0.60169 0.5230 0.001 *** -Zn 0.61750 0.78657 0.1879 0.125 -Mo -0.90304 0.42955 0.0609 0.537 -Baresoil 0.92503 -0.37988 0.2508 0.039 * -Humdepth 0.93291 -0.36011 0.5200 0.002 ** -pH -0.64809 0.76156 0.2308 0.060 . +Fe -0.93613 0.35164 0.4451 0.001 *** +Mn 0.79873 -0.60169 0.5230 0.002 ** +Zn 0.61750 0.78657 0.1879 0.122 +Mo -0.90304 0.42955 0.0609 0.524 +Baresoil 0.92503 -0.37988 0.2508 0.043 * +Humdepth 0.93291 -0.36011 0.5200 0.001 *** +pH -0.64809 0.76156 0.2308 0.064 . --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 -P values based on 999 permutations. +Permutation: free +Number of permutations: 999 > scores(fit, "vectors") @@ -3316,7 +3287,7 @@ > > ### Name: isomap > ### Title: Isometric Feature Mapping Ordination -> ### Aliases: isomap isomapdist plot.isomap summary.isomap rgl.isomap +> ### Aliases: isomap isomapdist plot.isomap summary.isomap > ### Keywords: multivariate > > ### ** Examples @@ -3348,10 +3319,6 @@ > pl <- plot(isomap(dis, epsilon=0.45), main="isomap epsilon=0.45") > lines(tr, pl, col="red") > par(op) -> ## The following command requires user interaction -> ## Not run: -> ##D rgl.isomap(ord, size=4, color="hotpink") -> ## End(Not run) > > > @@ -3542,9 +3509,9 @@ Upper quantiles of permutations (null model): 90% 95% 97.5% 99% 0.107 0.145 0.169 0.200 +Permutation: free +Number of permutations: 999 -Based on 999 permutations - > mantel(veg.dist, env.dist, method="spear") Mantel statistic based on Spearman's rank correlation rho @@ -3558,9 +3525,9 @@ Upper quantiles of permutations (null model): 90% 95% 97.5% 99% 0.108 0.141 0.169 0.196 +Permutation: free +Number of permutations: 999 -Based on 999 permutations - > > > @@ -3950,7 +3917,8 @@ Based on observed delta 11.15 and expected delta 12.74 Significance of delta: 0.002 -Based on 999 permutations +Permutation: free +Number of permutations: 999 > > # Save and change plotting parameters @@ -4029,6 +3997,7 @@ > ## Canonical correspondence analysis (cca): > Example.cca <- cca(X, Y) > Example.cca <- mso(Example.cca, tmat) +Set of permutations < 'minperm'. Generating entire set. > msoplot(Example.cca) > Example.cca$vario H Dist n All Sum CA CCA se @@ -4037,6 +4006,7 @@ > > ## Correspondence analysis (ca): > Example.ca <- mso(cca(X), tmat) +Set of permutations < 'minperm'. Generating entire set. > msoplot(Example.ca) > > ## Unconstrained ordination with test for autocorrelation @@ -4046,11 +4016,11 @@ > data(mite.xy) > > mite.cca <- cca(log(mite + 1)) -> mite.cca <- mso(mite.cca, mite.xy, grain = 1, permutations = 100) +> mite.cca <- mso(mite.cca, mite.xy, grain = 1, permutations = 99) > msoplot(mite.cca) > mite.cca Call: mso(object.cca = mite.cca, object.xy = mite.xy, grain = 1, -permutations = 100) +permutations = 99) Inertia Rank Total 1.164 @@ -4065,23 +4035,27 @@ mso variogram: H Dist n All CA CA.signif -0 0 0.3555 63 0.6250 0.6250 0.00 -1 1 1.0659 393 0.7556 0.7556 0.00 -2 2 2.0089 534 0.8931 0.8931 0.00 -3 3 2.9786 417 1.0988 1.0988 0.02 -4 4 3.9817 322 1.3321 1.3321 0.00 -5 5 5.0204 245 1.5109 1.5109 0.00 -10 10 6.8069 441 1.7466 1.7466 0.00 +0 0 0.3555 63 0.6250 0.6250 0.01 +1 1 1.0659 393 0.7556 0.7556 0.01 +2 2 2.0089 534 0.8931 0.8931 0.01 +3 3 2.9786 417 1.0988 1.0988 0.03 +4 4 3.9817 322 1.3321 1.3321 0.01 +5 5 5.0204 245 1.5109 1.5109 0.01 +10 10 6.8069 441 1.7466 1.7466 0.01 + +Permutation: free +Number of permutations: 99 + > > ## Constrained ordination with test for residual autocorrelation > ## and scale-invariance of species-environment relationships > mite.cca <- cca(log(mite + 1) ~ SubsDens + WatrCont + Substrate + Shrub + Topo, mite.env) -> mite.cca <- mso(mite.cca, mite.xy, permutations = 100) +> mite.cca <- mso(mite.cca, mite.xy, permutations = 99) > msoplot(mite.cca) Error variance of regression model underestimated by 0.4 percent > mite.cca Call: mso(object.cca = mite.cca, object.xy = mite.xy, permutations = -100) +99) Inertia Proportion Rank Total 1.1638 1.0000 @@ -4103,13 +4077,17 @@ mso variogram: H Dist n All Sum CA CCA se CA.signif -0 0 0.3555 63 0.6250 0.7479 0.5512 0.1967 0.03506 0.00 -1 1 1.0659 393 0.7556 0.8820 0.6339 0.2482 0.01573 0.16 +0 0 0.3555 63 0.6250 0.7479 0.5512 0.1967 0.03506 0.01 +1 1 1.0659 393 0.7556 0.8820 0.6339 0.2482 0.01573 0.17 2 2 2.0089 534 0.8931 0.9573 0.6473 0.3100 0.01487 0.71 -3 3 2.9786 417 1.0988 1.1010 0.6403 0.4607 0.01858 0.44 +3 3 2.9786 417 1.0988 1.1010 0.6403 0.4607 0.01858 0.46 4 4 3.9817 322 1.3321 1.2548 0.6521 0.6027 0.02439 0.99 5 5 5.0204 245 1.5109 1.4564 0.6636 0.7928 0.02801 0.42 -10 10 6.8069 441 1.7466 1.6266 0.6914 0.9351 0.02052 0.20 +10 10 6.8069 441 1.7466 1.6266 0.6914 0.9351 0.02052 0.21 + +Permutation: free +Number of permutations: 99 + > > > @@ -4643,58 +4621,6 @@ > > > cleanEx() -> nameEx("ordiplot3d") -> ### * ordiplot3d -> -> flush(stderr()); flush(stdout()) -> -> ### Name: ordiplot3d -> ### Title: Three-Dimensional and Dynamic Ordination Graphics -> ### Aliases: ordiplot3d ordirgl orglpoints orgltext orglsegments orglspider -> ### Keywords: hplot dynamic -> -> ### ** Examples -> -> ## Examples are not run, because they need non-standard packages -> ## 'scatterplot3d' and 'rgl' (and the latter needs user interaction). -> ##### -> ### Default 'ordiplot3d' -> ## Not run: -> ##D data(dune) -> ##D data(dune.env) -> ##D ord <- cca(dune ~ A1 + Moisture, dune.env) -> ##D ordiplot3d(ord) -> ##D ### A boxed 'pin' version -> ##D ordiplot3d(ord, type = "h") -> ##D ### More user control -> ##D pl <- ordiplot3d(ord, scaling = 3, angle=15, type="n") -> ##D points(pl, "points", pch=16, col="red", cex = 0.7) -> ##D ### identify(pl, "arrows", col="blue") would put labels in better positions -> ##D text(pl, "arrows", col="blue", pos=3) -> ##D text(pl, "centroids", col="blue", pos=1, cex = 1) -> ##D ### Add species using xyz.convert function returned by ordiplot3d -> ##D sp <- scores(ord, choices=1:3, display="species", scaling=3) -> ##D text(pl$xyz.convert(sp), rownames(sp), cex=0.7, xpd=TRUE) -> ##D ### Two ways of adding fitted variables to ordination plots -> ##D ord <- cca(dune) -> ##D ef <- envfit(ord ~ Moisture + A1, dune.env, choices = 1:3) -> ##D ### 1. use argument 'envfit' -> ##D ordiplot3d(ord, envfit = ef) -> ##D ### 2. use returned envfit.convert function for better user control -> ##D pl3 <- ordiplot3d(ord) -> ##D plot(pl3$envfit.convert(ef), at = pl3$origin) -> ##D ### envfit.convert() also handles different 'choices' of axes -> ##D pl3 <- ordiplot3d(ord, choices = c(1,3,2)) -> ##D plot(pl3$envfit.convert(ef), at = pl3$origin) -> ##D ### ordirgl -> ##D ordirgl(ord, size=2) -> ##D ordirgl(ord, display = "species", type = "t") -> ##D rgl.quit() -> ## End(Not run) -> -> -> -> cleanEx() > nameEx("ordipointlabel") > ### * ordipointlabel > @@ -5033,7 +4959,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5050,7 +4976,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 6.45 total = 7.45 @@ -5081,7 +5007,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5096,7 +5022,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE) - + Estimated degrees of freedom: 4.43 total = 5.43 @@ -5125,7 +5051,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5141,7 +5067,7 @@ Formula: y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE) - + Estimated degrees of freedom: 3 total = 4 @@ -5158,7 +5084,7 @@ Formula: y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE, FALSE)) - + Estimated degrees of freedom: 2.99 total = 3.99 @@ -5177,7 +5103,7 @@ Formula: y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE, TRUE)) - + Estimated degrees of freedom: 11 total = 12 @@ -5318,7 +5244,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.71 total = 9.71 @@ -5331,7 +5257,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 7.18 total = 8.18 @@ -5344,7 +5270,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.32 total = 9.32 @@ -5636,23 +5562,9 @@ > permutest(mod, permutations = 99, pairwise = TRUE) Permutation test for homogeneity of multivariate dispersions +Permutation: free +Number of permutations: 99 -Permutation Design: - -Blocks: - Defined by: none - -Plots: - Defined by: none - -Within Plots: - Permutation type: free - -Permutation details: - Number of permutations requested: 99 - Max. number of permutations allowed: 9999 - Evaluate all permutations?: No. Activation limit: 99 - Response: Distances Df Sum Sq Mean Sq F N.Perm Pr(>F) Groups 1 0.07931 0.079306 4.6156 100 0.04 * @@ -6308,7 +6220,6 @@ > ### Name: renyi > ### Title: Renyi and Hill Diversities and Corresponding Accumulation Curves > ### Aliases: renyi plot.renyi renyiaccum plot.renyiaccum persp.renyiaccum -> ### rgl.renyiaccum > ### Keywords: univar > > ### ** Examples @@ -6702,6 +6613,8 @@ Vicilath 0.002399 0.005461 0.4393 0.0 0.1667 1.00000 Chenalbu 0.000000 0.000000 NaN 0.0 0.0000 1.00000 Cirsarve 0.000000 0.000000 NaN 0.0 0.0000 1.00000 +Permutation: free +Number of permutations: 0 > > > @@ -7803,23 +7716,24 @@ ***VECTORS NMDS1 NMDS2 r2 Pr(>r) -N -0.05719 -0.99836 0.2537 0.046 * -P 0.61959 0.78492 0.1938 0.103 -K 0.76629 0.64249 0.1809 0.143 -Ca 0.68506 0.72849 0.4119 0.008 ** -Mg 0.63240 0.77464 0.4271 0.004 ** -S 0.19123 0.98155 0.1752 0.140 +N -0.05719 -0.99836 0.2537 0.039 * +P 0.61959 0.78492 0.1938 0.129 +K 0.76629 0.64249 0.1809 0.138 +Ca 0.68506 0.72849 0.4119 0.005 ** +Mg 0.63240 0.77464 0.4271 0.005 ** +S 0.19123 0.98155 0.1752 0.133 Al -0.87169 0.49006 0.5269 0.001 *** -Fe -0.93613 0.35164 0.4451 0.002 ** -Mn 0.79873 -0.60169 0.5230 0.001 *** -Zn 0.61750 0.78657 0.1879 0.125 -Mo -0.90304 0.42955 0.0609 0.537 -Baresoil 0.92503 -0.37988 0.2508 0.039 * -Humdepth 0.93291 -0.36011 0.5200 0.002 ** -pH -0.64809 0.76156 0.2308 0.060 . +Fe -0.93613 0.35164 0.4451 0.001 *** +Mn 0.79873 -0.60169 0.5230 0.002 ** +Zn 0.61750 0.78657 0.1879 0.122 +Mo -0.90304 0.42955 0.0609 0.524 +Baresoil 0.92503 -0.37988 0.2508 0.043 * +Humdepth 0.93291 -0.36011 0.5200 0.001 *** +pH -0.64809 0.76156 0.2308 0.064 . --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 -P values based on 999 permutations. +Permutation: free +Number of permutations: 999 > plot(ef, p.max = 0.05) @@ -7875,9 +7789,9 @@ Df AIC F Pr(>F) + Management 3 87.082 2.8400 0.005 ** + Moisture 3 87.707 2.5883 0.005 ** -+ Manure 4 89.232 1.9539 0.005 ** -+ A1 1 89.591 1.9217 0.050 * -+ Use 2 91.032 1.1741 0.265 ++ Manure 4 89.232 1.9539 0.015 * ++ A1 1 89.591 1.9217 0.045 * ++ Use 2 91.032 1.1741 0.295 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 @@ -7889,25 +7803,25 @@ Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Df AIC F Pr(>F) -+ Moisture 3 85.567 1.9764 0.005 ** -+ Manure 3 87.517 1.3902 0.120 -+ A1 1 87.424 1.2965 0.210 -+ Use 2 88.284 1.0510 0.390 ++ Moisture 3 85.567 1.9764 0.010 ** ++ Manure 3 87.517 1.3902 0.045 * ++ A1 1 87.424 1.2965 0.245 ++ Use 2 88.284 1.0510 0.400 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Step: dune ~ Management + Moisture Df AIC F Pr(>F) -- Moisture 3 87.082 1.9764 0.010 ** +- Moisture 3 87.082 1.9764 0.015 * - Management 3 87.707 2.1769 0.005 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Df AIC F Pr(>F) -+ Manure 3 85.762 1.1225 0.345 -+ A1 1 86.220 0.8359 0.640 -+ Use 2 86.842 0.8027 0.700 ++ Manure 3 85.762 1.1225 0.255 ++ A1 1 86.220 0.8359 0.625 ++ Use 2 86.842 0.8027 0.780 > mod Call: rda(formula = dune ~ Management + Moisture, data = dune.env) @@ -7949,8 +7863,8 @@ Model: rda(formula = dune ~ Management + Moisture, data = dune.env) Df Variance F Pr(>F) -Management 3 18.938 2.1769 0.005 ** -Moisture 3 17.194 1.9764 0.006 ** +Management 3 18.938 2.1769 0.003 ** +Moisture 3 17.194 1.9764 0.005 ** Residual 13 37.699 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 @@ -7969,7 +7883,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 1.28 total = 2.28 @@ -7982,14 +7896,17 @@ Call: adonis(formula = dune ~ ., data = dune.env) +Permutation: free +Number of permutations: 999 + Terms added sequentially (first to last) Df SumsOfSqs MeanSqs F.Model R2 Pr(>F) A1 1 0.7230 0.72295 5.2038 0.16817 0.001 *** -Moisture 3 1.1871 0.39569 2.8482 0.27613 0.004 ** -Management 3 0.9036 0.30121 2.1681 0.21019 0.026 * -Use 2 0.0921 0.04606 0.3315 0.02143 0.983 -Manure 3 0.4208 0.14026 1.0096 0.09787 0.441 +Moisture 3 1.1871 0.39569 2.8482 0.27613 0.006 ** +Management 3 0.9036 0.30121 2.1681 0.21019 0.023 * +Use 2 0.0921 0.04606 0.3315 0.02143 0.982 +Manure 3 0.4208 0.14026 1.0096 0.09787 0.481 Residuals 7 0.9725 0.13893 0.22621 Total 19 4.2990 1.00000 --- @@ -7999,11 +7916,14 @@ Call: adonis(formula = dune ~ Management + Moisture, data = dune.env) +Permutation: free +Number of permutations: 999 + Terms added sequentially (first to last) Df SumsOfSqs MeanSqs F.Model R2 Pr(>F) -Management 3 1.4686 0.48953 3.7907 0.34161 0.002 ** -Moisture 3 1.1516 0.38387 2.9726 0.26788 0.001 *** +Management 3 1.4686 0.48953 3.7907 0.34161 0.001 *** +Moisture 3 1.1516 0.38387 2.9726 0.26788 0.002 ** Residuals 13 1.6788 0.12914 0.39051 Total 19 4.2990 1.00000 --- @@ -8519,7 +8439,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 35.834 7.734 41.19 0 0.001 +Time elapsed: 35.902 8.181 41.58 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Thu Sep 18 15:57:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 18 Sep 2014 15:57:33 +0200 (CEST) Subject: [Vegan-commits] r2885 - pkg/vegan/vignettes Message-ID: <20140918135733.CF576187630@r-forge.r-project.org> Author: jarioksa Date: 2014-09-18 15:57:33 +0200 (Thu, 18 Sep 2014) New Revision: 2885 Modified: pkg/vegan/vignettes/FAQ-vegan.texi pkg/vegan/vignettes/decision-vegan.Rnw pkg/vegan/vignettes/diversity-vegan.Rnw pkg/vegan/vignettes/intro-vegan.Rnw Log: Squashed commit of the following: commit e3a3fa09c073ad1a3b9e196a6031b04e4388cf9a Merge: 793a0c7 b330bbd Author: Jari Oksanen Date: Thu Sep 18 16:49:51 2014 +0300 Merge pull request #40 from jarioksa/update-docs Update docs commit b330bbd01c877df5c44d48b49191362cc2bf2b71 Author: Jari Oksanen Date: Wed Sep 17 21:22:22 2014 +0300 edit FAQ-vegan commit 8494bb8c3cf81612c5baa72fdf086253703f9854 Author: Jari Oksanen Date: Tue Sep 16 20:00:09 2014 +0300 remove svn-specific fields $Date$ and $Id$ from documents commit 72009ede68c919e31569830dd51fa5c27fe9ca82 Author: Jari Oksanen Date: Tue Sep 16 19:52:52 2014 +0300 More fixes for permutation routines in intro-vegan commit d0b929423a483b32fc8bfa15bab6ced80b21aa0c Author: Jari Oksanen Date: Tue Sep 16 19:50:02 2014 +0300 FAQ-vegan adapted to GitHub commit ec8fd7e0c27a3f57024fefca3840c19d990c54f5 Author: Jari Oksanen Date: Tue Sep 16 19:34:56 2014 +0300 FAQ-vegan update to the use of permute package commit bfb0f79a7a5cb1658c8509e94d8014b01dd24e09 Author: Jari Oksanen Date: Tue Sep 16 19:20:00 2014 +0300 update intro-vegan to changes in anova.cca Modified: pkg/vegan/vignettes/FAQ-vegan.texi =================================================================== --- pkg/vegan/vignettes/FAQ-vegan.texi 2014-09-17 11:29:19 UTC (rev 2884) +++ pkg/vegan/vignettes/FAQ-vegan.texi 2014-09-18 13:57:33 UTC (rev 2885) @@ -8,7 +8,7 @@ @setfilename FAQ- at pkg{vegan}.info @settitle @pkg{vegan} FAQ @setchapternewpage on - at set FAQ_YEAR 2013 + at set FAQ_YEAR 2014 @afourpaper @c %**end of header @@ -16,7 +16,6 @@ @ifnottex This document contains answers to some of the most frequently asked questions about R package @pkg{vegan}. -This is version of $Date$. @end ifnottex @quotation @@ -40,7 +39,6 @@ @titlepage @title @pkg{vegan} @acronym{FAQ} @subtitle Frequently Asked Questions on R package @pkg{vegan} - at subtitle Version of $Date$ @author Jari Oksanen @vskip 0pt plus 1fill @@ -62,30 +60,29 @@ @menu -* Introduction:: -* Ordination:: -* Other analysis methods :: +* Introduction:: +* Ordination:: +* Other analysis methods :: @end menu @node Introduction, Ordination, Top, Top @chapter Introduction @menu -* What is @pkg{vegan}?:: -* What is R?:: -* How to obtain @pkg{vegan} and R?:: -* What R packages @pkg{vegan} depends on?:: -* What other packages are available for ecologists?:: -* What other documentation is available for @pkg{vegan}?:: -* Is there a Graphical User Interface (GUI) for @pkg{vegan}?:: -* How to cite @pkg{vegan}?:: -* How to build @pkg{vegan} from sources?:: -* Are there binaries for devel versions?:: -* Can I use @pkg{vegan} in Mac?:: -* How to report a bug in @pkg{vegan}?:: -* Is it a bug or a feature?:: -* Can I contribute to @pkg{vegan}?:: -* Can I have write access to @pkg{vegan} repository?:: +* What is @pkg{vegan}?:: +* What is R?:: +* How to obtain @pkg{vegan} and R?:: +* What R packages @pkg{vegan} depends on?:: +* What other packages are available for ecologists?:: +* What other documentation is available for @pkg{vegan}?:: +* Is there a Graphical User Interface (GUI) for @pkg{vegan}?:: +* How to cite @pkg{vegan}?:: +* How to build @pkg{vegan} from sources?:: +* Are there binaries for devel versions?:: +* Can I use @pkg{vegan} in Mac?:: +* How to report a bug in @pkg{vegan}?:: +* Is it a bug or a feature?:: +* Can I contribute to @pkg{vegan}?:: @end menu @node What is @pkg{vegan}?, What is R?, Introduction, Introduction @@ -121,38 +118,31 @@ Both R and latest release version of @pkg{vegan} can be obtained through @uref{http://cran.r-project.org,,CRAN}. Unstable development version of @pkg{vegan} can be obtained through - at uref{http://r-forge.r-project.org/projects/vegan/,,R-Forge}. + at uref{https://github.com/vegandevs/vegan,,GitHub}. Formerly @pkg{vegan} +was developed in + at uref{http://r-forge.r-project.org/projects/vegan/,,R-Forge}, +but after moving to @uref{https://github.com/vegandevs/vegan,,GitHub} +the R-Forge repository may be out of date. - - @node What R packages @pkg{vegan} depends on?, What other packages are available for ecologists?, How to obtain @pkg{vegan} and R?, Introduction @section What R packages @pkg{vegan} depends on? @pkg{Vegan} depends on the @pkg{permute} package which will provide -advanced and flexible permutation routines for vegan (but currently only -a small part of functions use @pkg{permute}). The @pkg{permute} package -is developed together with @pkg{vegan} in - at uref{http://vegan.r-forge.r-project.org/,,R-Forge}. +advanced and flexible permutation routines for @pkg{vegan}. The + at pkg{permute} package is developed together with @pkg{vegan} in + at uref{https://github.com/gavinsimpson/permute,,GitHub}. Some individual @pkg{vegan} functions depend on packages @pkg{MASS}, @pkg{mgcv}, @pkg{cluster}, @pkg{lattice} and @pkg{tcltk}. These all are base or recommended R packages that should be available in every R -installation. In addition, some @pkg{vegan} functions @code{require} -non-standard R packages. @pkg{Vegan} declares these packages only as -suggested ones, and you can install @pkg{vegan} and use most of its -functions without these packages. The non-standard packages needed by -some @pkg{vegan} functions are: - at itemize +installation. @pkg{Vegan} declares these as suggested or imported +packages, and you can install @pkg{vegan} and use most of its functions +without these packages. - at item Package @pkg{scatterplot3d} -is needed by @code{ordiplot3d} + at pkg{Vegan} is accompanied with a supporting package @pkg{vegan3d} for +three-dimensional and dynamic plotting. The @pkg{vegan3d} package needs +non-standard packages @pkg{rgl} and @pkg{scatterplot3d}. - at item Package @pkg{rgl} -is needed by @code{ordirgl} -and @code{rgl.isomap} - - at end itemize - @node What other packages are available for ecologists?, What other documentation is available for @pkg{vegan}?, What R packages @pkg{vegan} depends on?, Introduction @section What other packages are available for ecologists? @@ -195,7 +185,7 @@ @itemize @item - at uref{http://vegan.r-forge.r-project.org/}: @pkg{vegan} homepage. + at uref{https://github.com/vegandevs/vegan}: @pkg{vegan} homepage. @item @uref{http://cc.oulu.fi/~jarioksa/opetus/metodi/vegantutor.pdf}: @pkg{vegan} tutorial. @@ -237,7 +227,9 @@ @uref{http://r-forge.r-project.org/projects/vegan/,,R-Forge} runs daily tests on the devel package, and if passed, it builds source package -together with Windows and MacOS X binaries. You can install those +together with Windows binaries. However, the R-Forge may be out of date, +because @pkg{vegan} is mainly developed in + at uref{https://github.com/vegandevs/vegan,,GitHub}. You can install R-Forge packages within R with command @code{install.packages("vegan", repos="http://r-forge.r-project.org/")}. If you use GUI menu entry, you must select or define the R-Forge @@ -251,16 +243,16 @@ need to install extra tools packages available in @uref{http://cran.r-project.org/bin/macosx/tools/,,MacOS tools} pages: If you use function such as @code{orditkplot} that need @code{Tcl/Tk} -you may need to install @code{tcltk} package. If you use @pkg{vegan} -binaries from other places than from - at uref{http://cran.r-project.org,,CRAN}, you may also need to install - at code{gfortran} package. +you may need to install @code{tcltk} package. No Mac binaries of +development versions are available in any repository we know. @node How to report a bug in @pkg{vegan}?, Is it a bug or a feature?, Can I use @pkg{vegan} in Mac?, Introduction @section How to report a bug in @pkg{vegan}? If you think you have found a bug in @pkg{vegan}, you should report it to - at pkg{vegan} maintainers or developers. The bug report should be so detailed + at pkg{vegan} maintainers or developers. The preferred forum to report +bugs is @uref{https://github.com/vegandevs/vegan/issues,,GitHub}. The +bug report should be so detailed that the bug can be replicated and corrected. Preferably, you should send an example that causes a bug. If it needs a data set that is not available in R, you should send a minimal data set as well. You also @@ -272,10 +264,6 @@ Please note that you shall not send bug reports to R mailing lists, since @pkg{vegan} is not a standard R package. -There also is a bug reporting tool at - at uref{http://r-forge.r-project.org/projects/vegan/,,R-Forge}, but you -need to register as a site user to report bugs (this is site policy). - @node Is it a bug or a feature?, Can I contribute to @pkg{vegan}?, How to report a bug in @pkg{vegan}?, Introduction @section Is it a bug or a feature? @@ -288,66 +276,48 @@ indices (when this is possible). If you expect it to calculate a binary index, you should use argument @code{binary = TRUE}. - at node Can I contribute to @pkg{vegan}?, Can I have write access to @pkg{vegan} repository?, Is it a bug or a feature?, Introduction + at node Can I contribute to @pkg{vegan}?, , Is it a bug or a feature?, Introduction @section Can I contribute to @pkg{vegan}? @pkg{Vegan} is dependent on user contribution. All feedback is welcome. If -you have problem with @pkg{vegan}, it may be as simple as incomplete -documentation, and we'll do our best to improve the documents. +you have problems with @pkg{vegan}, it may be as simple as incomplete +documentation, and we shall do our best to improve the documents. Feature requests also are welcome, but they are not necessarily fulfilled. A new feature will be added if it is easy to do and it looks -useful to me or in general, or if you submit code. +useful, or if you submit code. -Contributed code and functions are welcome and more certain to be -included than mere requests. However, not all functions will be added, -but I they must be suitable for @pkg{vegan}. We also audit the code, and -typically we edit the code in @pkg{vegan} style for easier maintenance. All -included contributions will be credited. +If you can write code yourself, the best forum to contribute to vegan is + at uref{https://github.com/vegandevs/vegan,,GitHub}. - at node Can I have write access to @pkg{vegan} repository?, , Can I contribute to @pkg{vegan}?, Introduction - at section Can I have write access to @pkg{vegan} repository? - -The @pkg{vegan} development happens mainly in - at uref{http://r-forge.r-project.org/,,R-Forge} which uses subversion for -version control. Subversion is a centralized version control system, -and only @pkg{vegan} developers can have write access to the central -repository. However, the @uref{http://r-forge.r-project.org/,,R-Forge} -is mirrored in - at uref{https://github.com/jarioksa/vegan.git,,GitHub}. This is a -distributed version control system and freely accessible for anybody. We -suggest you develop your own ideas in - at uref{https://github.com/jarioksa/vegan.git,,GitHub} and send a pull -request to us for incorporating your changes in @pkg{vegan} releases. - @node Ordination, Other analysis methods , Introduction, Top @chapter Ordination @menu -* 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?:: -* I get zero stress but no convergent solutions in @code{metaMDS}:: -* Zero dissimilarities in isoMDS:: -* I have heard that you cannot fit environmental vectors or surfaces to NMDS results which only have rank-order scores:: -* Where can I find numerical scores of ordination axes?:: -* How the RDA results are scaled?:: -* cca fails with ``data.frame expected'' or ``"site.env" missing'':: -* Ordination fails with ``Error in La.svd'':: -* 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?:: -* I want to use Helmert or sum contrasts:: -* What are aliased variables and how to see them?:: -* Plotting aliased variables:: -* Constrained permutations in @pkg{vegan}:: -* How to use different plotting symbols in ordination graphics?:: -* How to avoid cluttered ordination graphs?:: -* Can I flip an axis in ordination diagram?:: -* Can I zoom into an ordination plot?:: +* 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?:: +* I get zero stress but no convergent solutions in @code{metaMDS}:: +* Zero dissimilarities in isoMDS:: +* I have heard that you cannot fit environmental vectors or surfaces to NMDS results which only have rank-order scores:: +* Where can I find numerical scores of ordination axes?:: +* How the RDA results are scaled?:: +* cca fails with ``data.frame expected'' or ``"site.env" missing'':: +* Ordination fails with ``Error in La.svd'':: +* 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?:: +* I want to use Helmert or sum contrasts:: +* What are aliased variables and how to see them?:: +* Plotting aliased variables:: +* Restricted permutations in @pkg{vegan}:: +* How to use different plotting symbols in ordination graphics?:: +* How to avoid cluttered ordination graphs?:: +* Can I flip an axis in ordination diagram?:: +* Can I zoom into an ordination plot?:: @end menu @node I have only numeric and positive data but @pkg{vegan} still complains, Can I analyse binary or cover class data?, Ordination, Ordination @@ -427,18 +397,17 @@ Function @code{metaMDS} uses function @code{monoMDS} as its default method for @acronym{NMDS}, and this function can handle zero -dissimilarities. The alternative function @code{isoMDS} was the only -choice before @pkg{vegan} 2.0-0, and it cannot handle zero dissimilarities. If -you want to use @code{isoMDS}, you can use argument @code{zerodist = -"add"} in @code{metaMDS} to handle zero dissimilarities. With this -argument, zero dissimilarities are replaced with a small above zero -value, and they can be handled in @code{isoMDS}. This is a kluge, and -some people do not like this. A more principal solution is to remove -duplicate sites using R command @code{unique}. However, after some -standardizations or with some dissimilarity indices, originally -non-unique sites can have zero dissimilarity, and you have to resort to -the kluge (or work harder with your data). Usually it is better to use - at code{monoMDS}. +dissimilarities. Alternative function @code{isoMDS} cannot handle zero +dissimilarities. If you want to use @code{isoMDS}, you can use argument + at code{zerodist = "add"} in @code{metaMDS} to handle zero +dissimilarities. With this argument, zero dissimilarities are replaced +with a small positive value, and they can be handled in @code{isoMDS}. +This is a kluge, and some people do not like this. A more principal +solution is to remove duplicate sites using R command @code{unique}. +However, after some standardizations or with some dissimilarity indices, +originally non-unique sites can have zero dissimilarity, and you have to +resort to the kluge (or work harder with your data). Usually it is +better to use @code{monoMDS}. @node I have heard that you cannot fit environmental vectors or surfaces to NMDS results which only have rank-order scores, Where can I find numerical scores of ordination axes?, Zero dissimilarities in isoMDS, Ordination @section I have heard that you cannot fit environmental vectors or surfaces to NMDS results which only have rank-order scores @@ -596,11 +565,10 @@ 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. +All permutation tests in @pkg{vegan} are based on the @pkg{permute} +package that allows constructing various restricted permutation +schemes. For instance, you can set levels of @code{plots} or + at code{blocks} for a factor regarded as a random term. A major reason why real random effects models are impossible in most @pkg{vegan} functions is that their tests are based on the permutation @@ -701,7 +669,7 @@ variables. If you only want to see the names of aliased variables or levels in solution @code{sol}, use @code{alias(sol, names.only=TRUE)}. - at node Plotting aliased variables, Constrained permutations in @pkg{vegan}, What are aliased variables and how to see them?, Ordination + at node Plotting aliased variables, Restricted permutations in @pkg{vegan}, What are aliased variables and how to see them?, Ordination @section Plotting aliased variables You can fit vectors or class centroids for aliased variables using @@ -709,22 +677,17 @@ fitting, and the fitted vectors are identical to the vectors in correspondence analysis. - at node Constrained permutations in @pkg{vegan}, How to use different plotting symbols in ordination graphics?, Plotting aliased variables, Ordination - at section Constrained permutations in @pkg{vegan} + at node Restricted permutations in @pkg{vegan}, How to use different plotting symbols in ordination graphics?, Plotting aliased variables, Ordination + at section Restricted permutations in @pkg{vegan} -You can constrain your permutations within @code{strata} or levels of -factors. You can use stratified permutations in all @pkg{vegan} -functions that use permutation, such as @code{adonis}, @code{anosim}, - at code{anova.cca}, @code{mantel}, @code{mrpp}, @code{envfit} and - at code{protest}. + at pkg{Vegan} uses @pkg{permute} package in all its permutation tests. +The @pkg{permute} package will allow restricted permutation designs for +time series, line transects, spatial grids and blocking factors. The +construction of restricted permutation schemes is explained in the +manual page @code{permutations} in @pkg{vegan} and in the documentation +of the @pkg{permute} package. - at pkg{Vegan} will move to use @pkg{permute} package in all its -permutation tests, but currently this package is only used in - at code{permutest.betadisper}. The @pkg{permute} package will allow -restricted permutation designs for time series, line transects, spatial -grids and blocking factors. - - at node How to use different plotting symbols in ordination graphics?, How to avoid cluttered ordination graphs?, Constrained permutations in @pkg{vegan}, Ordination + at node How to use different plotting symbols in ordination graphics?, How to avoid cluttered ordination graphs?, Restricted permutations in @pkg{vegan}, Ordination @section How to use different plotting symbols in ordination graphics? The default ordination @code{plot} function is intended for fast @@ -817,12 +780,12 @@ @chapter Other analysis methods @menu -* Is there TWINSPAN?:: -* Why strata do not influence adonis results?:: -* How is deviance calculated?:: +* Is there TWINSPAN?:: +* Why restricted permutation does not influence adonis results?:: +* How is deviance calculated?:: @end menu - at node Is there TWINSPAN?, Why strata do not influence adonis results?, Other analysis methods , Other analysis methods + at node Is there TWINSPAN?, Why restricted permutation does not influence adonis results?, Other analysis methods , Other analysis methods @section Is there TWINSPAN? No. It may be possible to port @acronym{TWINSPAN} to @pkg{vegan}, but it is @@ -830,16 +793,15 @@ will be happy to help. @acronym{TWINSPAN} has a very permissive license, and it would be completely legal to port the function into R. - at node Why strata do not influence adonis results?, How is deviance calculated?, Is there TWINSPAN?, Other analysis methods + at node Why restricted permutation does not influence adonis results?, How is deviance calculated?, Is there TWINSPAN?, Other analysis methods @comment node-name, next, previous, up - at section Why strata do not influence adonis results? -Permutation happens only within @code{strata} and this influences the -permutation distribution of the statistics and probably the significance -levels, but @code{strata} do not influence the calculation of the -statistics. + at section Why restricted permutation does not influence adonis results? +The permutation scheme influences the permutation distribution of the +statistics and probably the significance levels, but does not influence +the calculation of the statistics. - at node How is deviance calculated?, , Why strata do not influence adonis results?, Other analysis methods + at node How is deviance calculated?, , Why restricted permutation does not influence adonis results?, Other analysis methods @section How is deviance calculated? Some @pkg{vegan} functions, such as @code{radfit} use base R facility of Modified: pkg/vegan/vignettes/decision-vegan.Rnw =================================================================== --- pkg/vegan/vignettes/decision-vegan.Rnw 2014-09-17 11:29:19 UTC (rev 2884) +++ pkg/vegan/vignettes/decision-vegan.Rnw 2014-09-18 13:57:33 UTC (rev 2885) @@ -7,7 +7,7 @@ \author{Jari Oksanen} \title{Design decisions and implementation details in vegan} -\date{\footnotesize{$ $Id$ $ +\date{\footnotesize{ processed with vegan \Sexpr{packageDescription("vegan", field="Version")} in \Sexpr{R.version.string} on \today}} Modified: pkg/vegan/vignettes/diversity-vegan.Rnw =================================================================== --- pkg/vegan/vignettes/diversity-vegan.Rnw 2014-09-17 11:29:19 UTC (rev 2884) +++ pkg/vegan/vignettes/diversity-vegan.Rnw 2014-09-18 13:57:33 UTC (rev 2885) @@ -9,7 +9,7 @@ \title{Vegan: ecological diversity} \author{Jari Oksanen} -\date{\footnotesize{$ $Id$ $ +\date{\footnotesize{ processed with vegan \Sexpr{packageDescription("vegan", field="Version")} in \Sexpr{R.version.string} on \today}} Modified: pkg/vegan/vignettes/intro-vegan.Rnw =================================================================== --- pkg/vegan/vignettes/intro-vegan.Rnw 2014-09-17 11:29:19 UTC (rev 2884) +++ pkg/vegan/vignettes/intro-vegan.Rnw 2014-09-18 13:57:33 UTC (rev 2885) @@ -6,7 +6,7 @@ \title{Vegan: an introduction to ordination} \author{Jari Oksanen} -\date{\footnotesize{$ $Id$ $ +\date{\footnotesize{ processed with vegan \Sexpr{packageDescription("vegan", field="Version")} in \Sexpr{R.version.string} on \today}} @@ -246,7 +246,7 @@ interface, and it optionally can assess the ``significance'' of the variables using permutation tests: <<>>= -ord.fit <- envfit(ord ~ A1 + Management, data=dune.env, perm=1000) +ord.fit <- envfit(ord ~ A1 + Management, data=dune.env, perm=999) ord.fit @ The result can be drawn directly or added to an ordination diagram @@ -330,33 +330,21 @@ correct \code{anova} variant for the result of constrained ordination. -The \code{anova.cca} function tries to be clever and lazy: it -automatically stops if the observed permutation significance probably -differs from the targeted critical value ($0.05$ as default), but it -will continue long in uncertain cases. You must set \code{step} and -\code{perm.max} to same values to override this behaviour. - It is also possible to analyse terms separately: <<>>= -anova(ord, by="term", permu=200) +anova(ord, by="term", permutations=199) @ -In this case, the function is unable to automatically select the -number of iterations. This test is sequential: the terms are analysed +This test is sequential: the terms are analysed in the order they happen to be in the model. You can also analyse significances of marginal effects (``Type III effects''): <<>>= -anova(ord, by="mar") +anova(ord, by="mar", permutations=199) @ Moreover, it is possible to analyse significance of each axis: <>= -anova(ord, by="axis", perm=500) +anova(ord, by="axis", permutations=499) @ -Now the automatic selection works, but typically some of your axes -will be very close to the critical value, and it may be useful to set -a lower \code{perm.max} than the default $10000$ (typically you use -higher limits than in these examples: we used lower limits to save -time when this document is automatically generated with this package). \subsection{Conditioned or partial ordination} @@ -370,13 +358,17 @@ effects of \code{A1} and \code{Management}. This also influences the significances of the terms: <<>>= -anova(ord, by="term", perm=500) +anova(ord, by="term", permutations=499) @ If we had a designed experiment, we may wish to restrict the permutations so that the observations only are permuted within levels -of \code{strata}: +of \code{Moisture}. Restricted permutation is based on the powerful +\pkg{permute} package. Function \code{how()} can be used to define +permutation schemes. In the following, we set the levels with +\code{plots} argument: <<>>= -anova(ord, by="term", perm=500, strata=Moisture) +how <- how(nperm=499, plots = Plots(strata=dune.env$Moisture)) +anova(ord, by="term", permutations = how) @ %%%%%%%%%%%%%%%%%%% From noreply at r-forge.r-project.org Mon Sep 22 10:38:01 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 22 Sep 2014 10:38:01 +0200 (CEST) Subject: [Vegan-commits] r2886 - in pkg/vegan: . R man Message-ID: <20140922083801.CE2F6187393@r-forge.r-project.org> Author: jarioksa Date: 2014-09-22 10:38:01 +0200 (Mon, 22 Sep 2014) New Revision: 2886 Removed: pkg/vegan/R/ccanova.R pkg/vegan/R/ccanova.byaxis.R pkg/vegan/R/ccanova.bymargin.R pkg/vegan/R/ccanova.byterm.R pkg/vegan/man/ccanova.Rd Modified: pkg/vegan/NAMESPACE pkg/vegan/man/oecosimu.Rd Log: Squashed commit of the following: commit 0d5ef1f29a292811865ff007aa6611b80e533663 Merge: ad80935 8f56476 Author: Jari Oksanen Date: Mon Sep 22 08:33:05 2014 +0300 Merge remote-tracking branch 'upstream/master' commit ad809359a6ffd9b4497503a02360602a4f8f7874 Author: Gavin Simpson Date: Sun Sep 21 15:39:49 2014 -0600 fix a typo commit f25f30c479d1fec51cccd48b0a2b8941703744da Author: Jari Oksanen Date: Sun Aug 31 20:18:42 2014 +0300 Delete ccanova* in favour of anova.cca* When anova.cca* switched to parallel processing, the old code was backed up as ccanova* functions. Now these functions were removed and only the new anova.cca* functions remain commit 8f56476067432f58a1d8c739f017ddf69c8755e1 Merge: 272e918 413dcb6 Author: Gavin Simpson Date: Sun Sep 21 19:00:36 2014 -0600 Merge pull request #41 from jarioksa/parallel Delete ccanova* in favour of anova.cca* commit 272e918baaa57b35c2bcd5f50e4406e41cde00d9 Author: Gavin Simpson Date: Sun Sep 21 15:39:49 2014 -0600 fix a typo commit e3a3fa09c073ad1a3b9e196a6031b04e4388cf9a Merge: 793a0c7 b330bbd Author: Jari Oksanen Date: Thu Sep 18 16:49:51 2014 +0300 Merge pull request #40 from jarioksa/update-docs Update docs commit b330bbd01c877df5c44d48b49191362cc2bf2b71 Author: Jari Oksanen Date: Wed Sep 17 21:22:22 2014 +0300 edit FAQ-vegan commit 8494bb8c3cf81612c5baa72fdf086253703f9854 Author: Jari Oksanen Date: Tue Sep 16 20:00:09 2014 +0300 remove svn-specific fields $Date$ and $Id$ from documents commit 72009ede68c919e31569830dd51fa5c27fe9ca82 Author: Jari Oksanen Date: Tue Sep 16 19:52:52 2014 +0300 More fixes for permutation routines in intro-vegan commit d0b929423a483b32fc8bfa15bab6ced80b21aa0c Author: Jari Oksanen Date: Tue Sep 16 19:50:02 2014 +0300 FAQ-vegan adapted to GitHub commit ec8fd7e0c27a3f57024fefca3840c19d990c54f5 Author: Jari Oksanen Date: Tue Sep 16 19:34:56 2014 +0300 FAQ-vegan update to the use of permute package commit bfb0f79a7a5cb1658c8509e94d8014b01dd24e09 Author: Jari Oksanen Date: Tue Sep 16 19:20:00 2014 +0300 update intro-vegan to changes in anova.cca commit 413dcb6b5853755c1b8a2c6f90e8c201a31d492d Author: Jari Oksanen Date: Sun Aug 31 20:18:42 2014 +0300 Delete ccanova* in favour of anova.cca* When anova.cca* switched to parallel processing, the old code was backed up as ccanova* functions. Now these functions were removed and only the new anova.cca* functions remain Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/NAMESPACE 2014-09-22 08:38:01 UTC (rev 2886) @@ -29,8 +29,6 @@ treedist, treedive, treeheight, tsallisaccum, tsallis, varpart, vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores, wcmdscale, wisconsin) -## Export temporary function later intended to replace anova.cca() -export(ccanova) ## <-- REMOVE THIS WHEN ccanova IS REMOVED <--!!! ## export pasteCall for 'permute' export(pasteCall) ## export anova.cca for 'BiodiversityR': this should be fixed there Deleted: pkg/vegan/R/ccanova.R =================================================================== --- pkg/vegan/R/ccanova.R 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/R/ccanova.R 2014-09-22 08:38:01 UTC (rev 2886) @@ -1,62 +0,0 @@ -`ccanova` <- - function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999, - by = NULL, ...) -{ - if (is.null(object$CA) || is.null(object$CCA) || - object$CCA$rank == 0 || object$CA$rank == 0) - return(anova.ccanull(object)) - perm.max <- max(step-1, perm.max) - if (perm.max %% step == 0) - perm.max <- perm.max - 1 - if (!is.null(by)) { - by <- match.arg(by, c("axis", "terms", "margin")) - if (by == "axis") - sol <- ccanova.byaxis(object, alpha = alpha, beta = beta, - step = step, perm.max = perm.max, by = NULL, - ...) - else if (by == "margin") { - sol <- ccanova.bymargin(object, alpha = alpha, beta = beta, - step = step, perm.max = perm.max, - by = NULL, ...) - } - else { - mf <- match.call(expand.dots = FALSE) - if (!is.null(mf$...) && any(k <- pmatch(names(mf$...), - "permutations", nomatch = FALSE))) - step <- unlist(mf$...[k == 1]) - sol <- ccanova.byterm(object, step = step, ...) - } - return(sol) - } - seed <- NULL - betaq <- c(beta/2, 1 - beta/2) - nperm <- 0 - unsure <- TRUE - hits <- 0 - while (unsure && nperm < perm.max) { - adj <- as.numeric(nperm == 0) - tst <- permutest.cca(object, step - adj, ...) - if (is.null(seed)) - seed <- tst$Random.seed - nperm <- nperm + step - adj - hits <- hits + sum(tst$F.perm >= tst$F.0) - fork <- qbinom(betaq, nperm, alpha) - if (hits < fork[1] || hits > fork[2]) - unsure <- FALSE - } - Fval <- c(tst$F.0, NA) - Pval <- c((hits+1)/(nperm+1), NA) - nperm <- c(nperm, NA) - table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval) - is.rda <- inherits(object, "rda") - colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"), - "F", "N.Perm", "Pr(>F)") - head <- paste("Permutation test for", tst$method, "under", - tst$model, "model\n") - if (!is.null(tst$strata)) - head <- paste(head, "Permutations stratified within '", - tst$strata, "'\n", sep = "") - mod <- paste("Model:", c(object$call)) - structure(table, heading = c(head, mod), Random.seed = seed, - class = c("anova.cca", "anova", "data.frame")) -} Deleted: pkg/vegan/R/ccanova.byaxis.R =================================================================== --- pkg/vegan/R/ccanova.byaxis.R 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/R/ccanova.byaxis.R 2014-09-22 08:38:01 UTC (rev 2886) @@ -1,89 +0,0 @@ -`ccanova.byaxis` <- - function (object, cutoff = 1, ...) -{ - cutoff <- cutoff + sqrt(.Machine$double.eps) - rnk <- object$CCA$rank - if (!max(rnk, 0)) - stop("Needs a constrained ordination") - if (is.null(object$terms)) - stop("Analysis is only possible for models fitted using formula") - ## Handle missing values in scores, both "omit" and "exclude" to - ## match dims with data. - if (!is.null(object$na.action)) { - u <- napredict(structure(object$na.action, class="exclude"), - object$CCA$u) - } else { - u <- object$CCA$u - } - ## Get conditions - if (!is.null(object$pCCA)) { - CondMat <- qr.X(object$pCCA$QR) - ## deweight if CCA - if (!inherits(object, "rda")) - CondMat <- sweep(CondMat, 1, sqrt(object$rowsum), "/") - } - else - CondMat <- NULL - ## pad with NA rows if there is a subset - if (!is.null(object$subset)) { - lc <- matrix(NA, nrow=length(object$subset), - ncol = NCOL(u)) - lc[object$subset,] <- u - if (!is.null(CondMat)) { - tmp <- matrix(NA, nrow=length(object$subset), - ncol = NCOL(CondMat)) - tmp[object$subset,] <- CondMat - CondMat <- tmp - } - object$call$subset <- object$subset - } else { - lc <- u - } - lc <- as.data.frame(lc) - axnam <- colnames(lc) - df <- c(rep(1, rnk), object$CA$rank) - chi <- c(object$CCA$eig, Residual = object$CA$tot.chi) - Fval <- c(chi[1:rnk]/df[1:rnk]/chi[rnk+1]*df[rnk+1], NA) - nperm <- c(numeric(rnk), NA) - Pval <- rep(NA, rnk+1) - out <- data.frame(df, chi, Fval, nperm, Pval) - environment(object$terms) <- environment() - fla <- paste(". ~ ", axnam[1], "+ Condition(", - paste(axnam[-1], collapse="+"),")") - if (!is.null(CondMat)) { - fla <- paste(fla, " + Condition(CondMat)") - lc$CondMat <- CondMat - } - fla <- update(formula(object), fla) - sol <- ccanova(update(object, fla, data=lc), ...) - out[c(1, rnk + 1), ] <- sol - seed <- attr(sol, "Random.seed") - attr(out, "names") <- attr(sol, "names") - .call <- pasteCall(object$call, "Model:") - attr(out, "heading") <- sub(" \n","", .call) - attr(out, "Random.seed") <- seed - bigseed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) - bigperm <- out$N.Perm[1] - if (rnk > 1) { - for (.ITRM in 2:rnk) { - fla <- paste(".~", axnam[.ITRM], "+Condition(", - paste(axnam[-(.ITRM)], collapse="+"),")") - if (!is.null(CondMat)) - fla <- paste(fla, "+ Condition(CondMat)") - fla <- update(formula(object), fla) - sol <- update(object, fla, data = lc) - assign(".Random.seed", seed, envir = .GlobalEnv) - out[.ITRM, ] <- as.matrix(ccanova(sol, ...))[1,] - if (out[.ITRM, "N.Perm"] > bigperm) { - bigperm <- out[.ITRM, "N.Perm"] - bigseed <- get(".Random.seed", envir = .GlobalEnv, - inherits = FALSE) - } - if (out[.ITRM, "Pr(>F)"] > cutoff) - break - } - } - assign(".Random.seed", bigseed, envir = .GlobalEnv) - class(out) <- c("anova.cca", "anova", "data.frame") - out -} Deleted: pkg/vegan/R/ccanova.bymargin.R =================================================================== --- pkg/vegan/R/ccanova.bymargin.R 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/R/ccanova.bymargin.R 2014-09-22 08:38:01 UTC (rev 2886) @@ -1,52 +0,0 @@ -`ccanova.bymargin` <- - function(object, step=100, scope, ...) -{ - if(inherits(object, "prc")) - stop("ccanova(..., by = 'margin') cannot be used for 'prc' results") - if (!missing(scope) && is.character(scope)) - trms <- scope - else - trms <- drop.scope(object, scope) - alltrms <- labels(terms(object$terminfo)) - keep <- trms %in% alltrms - trms <- trms[keep] - ntrms <- length(trms) - bigperm <- 0 - for (.ITRM in 1:ntrms) { - fla <- formula(object) - ## Put all trms except current into Condition() and update - ## formula - if (length(alltrms) > 1) { - keeptrms <- alltrms[!(alltrms==trms[.ITRM])] - updfla <- paste("Condition(",paste(keeptrms, collapse="+"), ")") - fla <- update(fla, paste(". ~ . + ", updfla)) - } - tmp <- update(object, fla) - tmp <- ccanova(tmp, step=step, ...) - ## Start every permutation from the same seed, but get the - ## seed of the longest simulation and reset the RNG to that - ## state when exiting the function - if (tmp[1,"N.Perm"] > bigperm) { - bigperm <- tmp[1, "N.Perm"] - bigseed <- get(".Random.seed", envir = .GlobalEnv, - inherits = FALSE) - } - if (.ITRM == 1) { - seed <- attr(tmp, "Random.seed") - sol <- tmp - } - else { - sol <- rbind(sol[1:(.ITRM-1),], as.matrix(tmp[1,]), sol[.ITRM,]) - } - assign(".Random.seed", seed, envir = .GlobalEnv) - } - ## Put RNG at the end of the longest simulation - if (bigperm > 0) - assign(".Random.seed", bigseed, envir = .GlobalEnv) - rownames(sol)[1:ntrms] <- trms - head <- attr(sol, "heading") - head[1] <- paste(head[1], "Marginal effects of terms\n", sep="") - head[2] <- paste("Model:", c(object$call)) - attr(sol, "heading") <- head - sol -} Deleted: pkg/vegan/R/ccanova.byterm.R =================================================================== --- pkg/vegan/R/ccanova.byterm.R 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/R/ccanova.byterm.R 2014-09-22 08:38:01 UTC (rev 2886) @@ -1,78 +0,0 @@ -`ccanova.byterm` <- - function (object, step = 100, ...) -{ - ## Data set size may change during iteration if there are missing - ## values: use length(object$residual) to check this like step, - ## drop1.default, add1.default do. - n0 <- length(object$residuals) - trm <- terms(object) - call <- paste("Model:", c(object$call)) - trmlab <- attr(trm, "term.labels") - trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), - "term.labels")] - ntrm <- length(trmlab) - ## 'adj' puts the result together with the permutations and reduces - ## number of simulations by one so that P = (hits+1)/(permutations+1). - ## The first step is reduced by adj. - adj <- (step %% 10) == 0 - step <- step - adj - pchi <- matrix(0, nrow = ntrm + 1, ncol = step) - chi <- numeric(ntrm + 1) - df <- numeric(ntrm + 1) - names(df) <- c(trmlab, "Residual") - sim <- permutest.cca(object, permutations = step, ...) - pchi[ntrm + 1, ] <- sim$den - pchi[ntrm, ] <- sim$num - df[ntrm:(ntrm + 1)] <- sim$df - chi[ntrm:(ntrm + 1)] <- sim$chi - if (!is.null(object$call$data)) - modelframe <- ordiGetData(object$call, globalenv()) - else - modelframe <- model.frame(object) - for (.ITRM in ntrm:2) { - if (ntrm < 2) - break - assign(".Random.seed", sim$Random.seed, envir = .GlobalEnv) - fla <- as.formula(paste(" . ~ . -", trmlab[.ITRM])) - object <- update(object, fla, - if (!is.null(modelframe)) data = modelframe) - ## Change in data set due to missing values? - if (length(object$residuals) != n0) - stop("number of rows has changed: remove missing values?") - if (is.null(object$CCA)) - break - sim <- permutest.cca(object, permutations = step, ...) - pchi[.ITRM, ] <- pchi[.ITRM, ] - sim$num - chi[.ITRM] <- chi[.ITRM] - sim$chi[1] - df[.ITRM] <- df[.ITRM] - sim$df[1] - pchi[.ITRM - 1, ] <- sim$num - chi[.ITRM - 1] <- sim$chi[1] - df[.ITRM - 1] <- sim$df[1] - } - Fval <- chi/df/(chi[ntrm + 1]/df[ntrm + 1]) - Fval[ntrm + 1] <- NA - pchi <- sweep(pchi, 1, df, "/") - pchi[-(ntrm + 1), ] <- sweep(pchi[-(ntrm + 1), , drop = FALSE], - 2, pchi[ntrm + 1, , drop = FALSE], "/") - ## Round to avoid arbitrary P values due to numerical precision - pchi <- round(pchi, 12) - Fval <- round(Fval, 12) - P <- rowSums(sweep(pchi[-(ntrm + 1), , drop = FALSE], 1, - Fval[-(ntrm + 1)], ">=")) - P <- c((P + adj)/(step + adj), NA) - out <- data.frame(df, chi, Fval, c(rep(step, ntrm), NA), - P) - inertname <- if (sim$method == "cca") - "Chisq" - else "Var" - colnames(out) <- c("Df", inertname, "F", "N.Perm", "Pr(>F)") - out <- out[out[, 1] > 0 | out[, 2] > sqrt(.Machine$double.eps), - ] - head <- paste("Permutation test for", sim$method, "under", - sim$model, "model\nTerms added sequentially (first to last)\n") - if (!is.null(sim$strata)) - head <- paste(head, "Permutations stratified within '", - sim$strata, "'\n", sep = "") - structure(out, heading = c(head, call), Random.seed = sim$Random.seed, - class = c("anova.cca", "anova", "data.frame")) -} Deleted: pkg/vegan/man/ccanova.Rd =================================================================== --- pkg/vegan/man/ccanova.Rd 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/man/ccanova.Rd 2014-09-22 08:38:01 UTC (rev 2886) @@ -1,72 +0,0 @@ -\name{ccanova} -\alias{ccanova} -\alias{anova.prc} - -\title{Permutation Test for Constrained Correspondence Analysis, - Redundancy Analysis and Constrained Analysis of Principal Coordinates } -\description{ - This function is deprecated. -} -\usage{ -ccanova(object, alpha=0.05, beta=0.01, step=100, perm.max=9999, - by = NULL, ...) -} - -\arguments{ - \item{object}{A result object from \code{\link{cca}}. } - \item{alpha}{Targeted Type I error rate. } - \item{beta}{Accepted Type II error rate. } - \item{step}{Number of permutations during one step. } - \item{perm.max}{Maximum number of permutations. } - \item{by}{Setting \code{by = "axis"} will assess significance for each - constrained axis, and setting \code{by = "terms"} will assess - significance for each term (sequentially from first to last), and - setting \code{by = "margin"} will assess the marginal effects of the - terms (each marginal term analysed in a model with all other - variables).} - \item{\dots}{Parameters passed to other functions. - \code{anova.cca} passes all arguments to - \code{permutest.cca}. In \code{anova} with \code{by = "axis"} you - can use argument \code{cutoff} (defaults \code{1}) which stops - permutations after exceeding the given level. } -} -\details{ - - Function \code{ccanova} is a deprecated version of \code{anova.cca}. - The new \code{link{anova.cca}} function is completely - rewritten. With the same random number seed and the same number of - permutations, the results are mostly identical. The only difference - is that marginal tests (\code{by = "margin"}) are implemented - differently. The most important difference is that the new code is - based on the \pkg{permute} package and uses the fixed number of - permutations in all tests (cf. below). Both the new and old - functions are based \code{\link{permutest.cca}}, and the function - can pass extra arguments to \code{permutest.cca}. - - In \code{ccanova} the number of permutations is controlled by - targeted \dQuote{critical} \eqn{P} value (\code{alpha}) and accepted - Type II or rejection error (\code{beta}). If the results of - permutations differ from the targeted \code{alpha} at risk level - given by \code{beta}, the permutations are terminated. If the - current estimate of \eqn{P} does not differ significantly from - \code{alpha} of the alternative hypothesis, the permutations are - continued with \code{step} new permutations (at the first step, the - number of permutations is \code{step - 1}). However, with - \code{by="terms"} a fixed number of permutations will be used, and - this is given by argument \code{permutations}, or if this is - missing, by \code{step}. - -} - -\note{ - The function is deprecated and replaced with \code{\link{anova.cca}}. -} -\references{ - Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd - English ed. Elsevier. -} -\author{Jari Oksanen} - -\keyword{ multivariate } -\keyword{ htest } - Modified: pkg/vegan/man/oecosimu.Rd =================================================================== --- pkg/vegan/man/oecosimu.Rd 2014-09-18 13:57:33 UTC (rev 2885) +++ pkg/vegan/man/oecosimu.Rd 2014-09-22 08:38:01 UTC (rev 2886) @@ -84,7 +84,7 @@ processing. The parallel processing is done with \pkg{parallel} package which is available only for \R 2.14.0 and later. If you define a \code{nestfun} in Windows that needs other \R packages - than \pkg{vegan} or \pkg{permute}, you must set up a scoket + than \pkg{vegan} or \pkg{permute}, you must set up a socket cluster before the call. See \code{\link{vegandocs}} \code{decision-vegan} for details. } \item{x}{An \code{oecosimu} result object.} From noreply at r-forge.r-project.org Tue Sep 23 09:20:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 23 Sep 2014 09:20:05 +0200 (CEST) Subject: [Vegan-commits] r2887 - in pkg/vegan: R inst man Message-ID: <20140923072005.76BC71874A0@r-forge.r-project.org> Author: jarioksa Date: 2014-09-23 09:20:05 +0200 (Tue, 23 Sep 2014) New Revision: 2887 Modified: pkg/vegan/R/permutest.betadisper.R pkg/vegan/inst/ChangeLog pkg/vegan/man/betadisper.Rd pkg/vegan/man/permutest.betadisper.Rd Log: Merge branch 'master' into r-forge-svn-local Modified: pkg/vegan/R/permutest.betadisper.R =================================================================== --- pkg/vegan/R/permutest.betadisper.R 2014-09-22 08:38:01 UTC (rev 2886) +++ pkg/vegan/R/permutest.betadisper.R 2014-09-23 07:20:05 UTC (rev 2887) @@ -1,6 +1,6 @@ `permutest.betadisper` <- function(x, pairwise = FALSE, - permutations = how(nperm = 999), - ...) + permutations = 999, + parallel = getOption("mc.cores"), ...) { t.statistic <- function(x, y) { m <- length(x) @@ -13,8 +13,48 @@ (xbar - ybar) / (pooled * sqrt(1/m + 1/n)) } + permFun <- function(idx) { + if (!is.matrix(idx)) { + dim(i) <- c(1, length(idx)) + } + R <- nrow(idx) + Fperm <- matrix(nrow = R, ncol = 1) + if (pairwise) { # set up object to hold t stats + Tperm <- matrix(ncol = n.pairs, nrow = R) + Jseq <- seq_len(n.pairs) + } + rdf <- nobs - p # residual degrees of freedom + ## iterate + for (i in seq_len(R)) { # iterate + take <- idx[i, ] # current permutation from set + p.resid <- resids[take] # permute residuals + f <- qr.fitted(mod.Q, p.resid) # create new data + mss <- sum((f - mean(f))^2) + r <- qr.resid(mod.Q, p.resid) + rss <- sum(r^2) + resvar <- rss / rdf + Fperm[i, ] <- (mss / (p - 1)) / resvar + + ## pairwise tests + if(pairwise) { + for(j in Jseq) { + grp1 <- x$distance[take][group == combin[1, j]] + grp2 <- x$distance[take][group == combin[2, j]] + Tperm[i, j] <- t.statistic(grp1, grp2) + } + } + } + + ## bind on pairwise stats if any + if (pairwise) { + Fperm <- cbind(Fperm, Tperm) + } + Fperm + } + if(!inherits(x, "betadisper")) stop("Only for class \"betadisper\"") + ## will issue error if only a single group mod.aov <- anova(x) nobs <- length(x$distances) ## number of observations @@ -30,52 +70,60 @@ permutations <- getPermuteMatrix(permutations, nobs) nperm <- nrow(permutations) - ## set-up objects to hold permuted results - res <- numeric(length = nperm + 1) - res[1] <- summary(mod)$fstatistic[1] ## pairwise comparisons if(pairwise) { - ## unique pairings - combin <- combn(levels(x$group), 2) + combin <- combn(levels(x$group), 2) # unique pairings n.pairs <- ncol(combin) - t.stats <- matrix(0, ncol = n.pairs, nrow = nperm + 1) - t.stats[1,] <- apply(combn(levels(group), 2), 2, function(z) { - t.statistic(x$distances[group == z[1]], - x$distances[group == z[2]])}) } - ## begin loop over shuffleSet perms - for(i in seq_len(nperm)) { - perm <- permutations[i,] ## take current permutation from set - perm.resid <- resids[perm] ## permute residuals - f <- qr.fitted(mod.Q, perm.resid) ## create new data - mss <- sum((f - mean(f))^2) - r <- qr.resid(mod.Q, perm.resid) - rss <- sum(r^2) - rdf <- nobs - p - resvar <- rss / rdf - res[i+1] <- (mss / (p - 1)) / resvar - - ## pairwise comparisons - if(pairwise) { - for(j in seq_len(n.pairs)) { - grp1 <- x$distance[perm][group == combin[1, j]] - grp2 <- x$distance[perm][group == combin[2, j]] - t.stats[i+1, j] <- t.statistic(grp1, grp2) + ## Parallel processing of permutations + if (is.null(parallel)) { + parallel <- 1 + } + hasClus <- inherits(parallel, "cluster") + if ((hasClus || parallel > 1L) && requireNamespace("parallel")) { + if (.Platform$OS.type == "unix" && !hasClus) { + Pstats <- do.call("rbind", + mclapply(seq_len(nperm), + function(x) permFun(permutations[x, , drop = FALSE]), + mc.cores = parallel)) + } else { + ## if hasClus, don't set up and top a temporary cluster + if (!hasClus) { + parallel <- makeCluster(parallel) } + Pstats <- parRapply(parallel, permutations, function(x) permFun(x)) + if (!hasClus) { + stopCluster(parallel) + } } + } else { + Pstats <- permFun(permutations) } + ## Process results + F0 <- summary(mod)$fstatistic[1] + Fstats <- round(Pstats[, 1], 12) # allow empty dim to be dropped + F0 <- round(F0, 12) + ## pairwise comparisons + if(pairwise) { + T0 <- apply(combn(levels(group), 2), 2, function(z) { + t.statistic(x$distances[group == z[1]], + x$distances[group == z[2]])}) + Tstats <- round(Pstats[, -1, drop = FALSE], 12) + T0 <- round(T0, 12) + } + ## compute permutation p-value - pval <- sum(res >= res[1]) / length(res) + pval <- (sum(Fstats >= F0) + 1) / (length(Fstats) + 1) if(pairwise) { df <- apply(combin, 2, function(z) { length(x$distances[group == z[1]]) + length(x$distance[group == z[2]]) - 2}) - pairwise <- list(observed = 2 * pt(-abs(t.stats[1,]), df), - permuted = apply(t.stats, 2, - function(z) sum(abs(z) >= abs(z[1]))/length(z))) + pairwise <- list(observed = 2 * pt(-abs(T0), df), + permuted = apply(Tstats, 2, + function(z) (sum(abs(z) >= abs(z[1])) + 1) / (length(z) + 1))) names(pairwise$observed) <- names(pairwise$permuted) <- apply(combin, 2, paste, collapse = "-") } else { Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-09-22 08:38:01 UTC (rev 2886) +++ pkg/vegan/inst/ChangeLog 2014-09-23 07:20:05 UTC (rev 2887) @@ -2,6 +2,17 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ +Version 2.1-43 + + * betadisper Permutation tests via the `permutest()` method + are now parallelised. The number of cores to parallelise over + is specified by argument `parallel` in common with the + implementation for `cca()`. + + Fix a couple of bugs in the examples; number of permutations + was specified using `control` which is not an argument to the + `permutest()` method for `betadisper()`. + Version 2.1-42 (opened September 4, 2014) * Opened a new version to prepare release 2.2-0. Modified: pkg/vegan/man/betadisper.Rd =================================================================== --- pkg/vegan/man/betadisper.Rd 2014-09-22 08:38:01 UTC (rev 2886) +++ pkg/vegan/man/betadisper.Rd 2014-09-23 07:20:05 UTC (rev 2887) @@ -240,7 +240,7 @@ anova(mod) ## Permutation test for F -permutest(mod, pairwise = TRUE) +permutest(mod, pairwise = TRUE, permutations = 99) ## Tukey's Honest Significant Differences (mod.HSD <- TukeyHSD(mod)) @@ -279,7 +279,7 @@ dis[c(2, 20)] <- NA mod2 <- betadisper(dis, groups) ## warnings mod2 -permutest(mod2, control = how(nperm = 100)) +permutest(mod2, permutations = 99) anova(mod2) plot(mod2) boxplot(mod2) @@ -288,7 +288,7 @@ ## Using group centroids mod3 <- betadisper(dis, groups, type = "centroid") mod3 -permutest(mod3, control = how(nperm = 100)) +permutest(mod3, permutations = 99) anova(mod3) plot(mod3) boxplot(mod3) Modified: pkg/vegan/man/permutest.betadisper.Rd =================================================================== --- pkg/vegan/man/permutest.betadisper.Rd 2014-09-22 08:38:01 UTC (rev 2886) +++ pkg/vegan/man/permutest.betadisper.Rd 2014-09-23 07:20:05 UTC (rev 2887) @@ -10,7 +10,8 @@ } \usage{ \method{permutest}{betadisper}(x, pairwise = FALSE, - permutations = how(nperm = 999), + permutations = 999, + parallel = getOption("mc.cores"), \dots) } %- maybe also 'usage' for other objects documented here. @@ -22,6 +23,9 @@ as returned by the function \code{\link[permute]{how}}, or the number of permutations required, or a permutation matrix where each row gives the permuted indices.} + \item{parallel}{Number of parallel processes or a predefined socket + cluster. With \code{parallel = 1} uses ordinary, non-parallel + processing.} \item{\dots}{Arguments passed to other methods.} } \details{ From noreply at r-forge.r-project.org Wed Sep 24 10:53:18 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 24 Sep 2014 10:53:18 +0200 (CEST) Subject: [Vegan-commits] r2888 - in pkg/vegan: . R man Message-ID: <20140924085318.45D5A187651@r-forge.r-project.org> Author: jarioksa Date: 2014-09-24 10:53:17 +0200 (Wed, 24 Sep 2014) New Revision: 2888 Added: pkg/vegan/R/gdispweight.R pkg/vegan/R/summary.dispweight.R Modified: pkg/vegan/NAMESPACE pkg/vegan/R/dispweight.R pkg/vegan/man/dispweight.Rd Log: Squashed commit of the following: commit b0dde2c6e4e9d415a56e3fa62740a036a515bd7f Merge: abb5b0b 1391a30 Author: Jari Oksanen Date: Wed Sep 24 11:42:01 2014 +0300 Merge pull request #43 from jarioksa/veganify-dispweight Veganify dispweight commit 1391a306e31808f4a901d3078764aeadc1eb3461 Author: Jari Oksanen Date: Wed Sep 24 10:10:27 2014 +0300 more detailed authors information for [g]dispweight commit d688532098d63fbc1faaed66905a13a1eb1230e6 Author: Jari Oksanen Date: Wed Sep 24 10:09:58 2014 +0300 tweak formatting of dispweight summary commit 3d8b06a476222e8b13ff46a26fad9d5234c6fc8c Author: Jari Oksanen Date: Wed Sep 24 09:57:34 2014 +0300 edit man/dispweight.Rd commit 6ce39e51e152f8d3397eb785a446c56ccbf3aaa5 Author: Jari Oksanen Date: Tue Sep 23 17:11:05 2014 +0300 gdispweight cannot handle missing values and fails informatively dispweight already fails informatively from nullmodel commit 6a9d84eb91ab157fc4d430d9d4d54b4a570d51b6 Author: Jari Oksanen Date: Tue Sep 23 07:23:26 2014 +0300 print.summary.dispweight passes ... to printCoefmat commit 6d5eea1d530fb2131bfb13ea7ff3f1a841e4933a Author: Jari Oksanen Date: Mon Sep 22 21:39:40 2014 +0300 avoid using anonymous functions in sapply() within gdispweight commit 704d4c2f3879fd2ffa77cc8ea70df01d331a68ee Author: Jari Oksanen Date: Mon Sep 22 16:42:05 2014 +0300 add summary.dispweight to extract and print simulation results commit 00a68c93498e53b0a6bfe967744ecbf90f1dd372 Author: Jari Oksanen Date: Mon Sep 22 16:15:44 2014 +0300 dispweight returns the name of the nullmodel commit c9b929181efe901d0483e3ed9b07d0e9830d3d1e Author: Jari Oksanen Date: Mon Sep 22 12:47:54 2014 +0300 dot expansion of terms works in gdispweight(comm ~ ., data=) commit 02f947d8ac0dadcfafb422e42e2747d5eebede70 Author: Jari Oksanen Date: Mon Sep 22 11:07:41 2014 +0300 [g]dispweight returns attribute on degrees of freedom used ("df") gdispweight finds d.f. directly from glm() and this is normally constant for all species, but dispweight discards factor levels where species does not occur, and degrees of freedom is non-constant for species. The d.f. is used to divide the Pearson Chi-square to get the overdispersion, and because d.f. is reduced for some species in dispweight, these will get higher overdispersion and hence lower weight in dispweight than in gdispweight. With this commit, the same original Pearson Chi-square will be found for both dispweight and gdispweight object: attr(object, "D") * attr(object, "df") commit 99f9a6bc2e2849bb7319157839e69866968b3bd6 Author: Jari Oksanen Date: Mon Sep 22 10:53:06 2014 +0300 export gdispweight from the NAMESPACE commit 94a0d4349256b423c2a7e9066a73d4216f44e656 Author: Jari Oksanen Date: Sun Sep 21 20:41:51 2014 +0300 Update author information for dispweight + gdispweight I think that email address of Eduard Sz?\195?\182cs also was out of date. commit 87391813102ed27cadd0986fd8b78ed72d3293fd Author: Jari Oksanen Date: Sun Sep 21 20:32:00 2014 +0300 Introduce generalized (parametric) dispersion weighting This is a new unpublished method. Original method uses Pearson Chi-square for a Poisson model with one factor and assesses the significance using multinomial simulation ("c0_ind" nullmodel). The new method estimates the same Pearson Chi-square for any glm model and evaluates the significance parametrically. Otherwise the models are identical except that the original method ignores completely the factor levels where species in assessing the number of degrees of freedom, but the generalized method defines the degrees of freedom in a standard way (number of observations minus number of model coefficients). As the degrees of freedom is used as divisor for weights, this will influence the strength of downweighting. commit 37f5261e2f2933c90c6521f6c258c1a850a3426b Author: Jari Oksanen Date: Sun Sep 21 08:50:24 2014 +0300 Relax data requirements in dispweight: reject only binary models The test of data properties was moved to checking properties of defined nullmodel, and only binary null models are rejected (these would all have p=1). We now accept also non-integer quantitative data. I don't know if these make sense, but that is none of my business -- users decide. commit f4d1394fd7216effef1b3670974b44627b2fc08c Author: Jari Oksanen Date: Sun Sep 21 08:38:45 2014 +0300 dispweight handles 1-level 'groups': analysis wrt community mean commit 9092774c0f46c177a6ca4ce254478e4a348141fb Author: Jari Oksanen Date: Sun Sep 21 08:28:21 2014 +0300 Expose nullmodel and plimit as user arguments in dispweight commit 21e0362b1f7ee3ae101684466921b59919008b89 Author: Jari Oksanen Date: Sun Sep 21 08:24:11 2014 +0300 adapt docs to 999 simulations of commit 67adb96 commit 67adb967a5d13bc439cfa52844dc4fb9f10cd0c9 Author: Jari Oksanen Date: Sun Sep 21 08:17:05 2014 +0300 default to 999 simulations in dispweight commit 7ba5092c9bbbd6519fdba2c1e590e9f4f5000e64 Author: Jari Oksanen Date: Sun Sep 21 08:08:22 2014 +0300 major rewrite of dispweight: rethink, streamline & use vegan::nullmodel The function was completely rewritten to use vegan::nullmodel "c0_ind" which is equal to the simulation used in the original function. The original function looped over species, but now we perform simulation for all species simultaneously using nullmodel, and loop over levels of 'groups'. All code that could be moved out of this loop was moved, and calculation of 'dhat' statistics was refactored and streamlined -- and done outside the loop. There are not many unchanged lines, but the results are equal provided the 'p' values are on the same side of the fixed critical level. In my laptop, this is also about 3x faster than the original. commit 824de6ca248a29faa0290b4f4fda8b7ef9aa3994 Author: Jari Oksanen Date: Sat Sep 20 08:54:09 2014 +0300 remove empty levels from "groups" or dispweight fails cryptically Error in if (any(means == 0)) { : missing value where TRUE/FALSE needed commit 70277611eacc86153d56cac101f076d547bf3666 Author: Jari Oksanen Date: Sat Sep 20 08:45:20 2014 +0300 dispweight used arg 'group', but other vegan functions use 'groups' commit ae6c6af97b7a033e85931ba9801d5cf8db8c074f Author: Jari Oksanen Date: Fri Sep 19 08:45:15 2014 +0300 dispweight doc says that it is 'nsimul' (not 'nperm') commit cd129e362142ba2b4b08d70a2da1a4710c9e6c85 Author: Jari Oksanen Date: Fri Sep 19 08:40:57 2014 +0300 document that dispweight returns transformed data commit 8087340689d133b6dd5b34aae136452687a99984 Author: Jari Oksanen Date: Tue Aug 6 17:37:36 2013 +0300 check that input are integers, fix docs commit bff23ee508a7338503f9ac2eb7280bf0217e0432 Author: Jari Oksanen Date: Tue Aug 6 16:53:46 2013 +0300 dispweight does simulations, not permutations commit 7d5a6ed8828ead61c81b6b4f9ebe9d651253f8c7 Author: Jari Oksanen Date: Mon Aug 5 08:55:18 2013 +0300 all dispweights return transformed data (with attributes) commit 6b6a47b9dd16bc0421103a0900f659f15d7f8bc8 Author: Jari Oksanen Date: Sun Aug 4 09:04:39 2013 +0300 dispweights work without 'group' argument Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-23 07:20:05 UTC (rev 2887) +++ pkg/vegan/NAMESPACE 2014-09-24 08:53:17 UTC (rev 2888) @@ -10,7 +10,7 @@ decostand, designdist, coverscale, dispweight, dispindmorisita, distconnected, diversity, downweight, drarefy, eigengrad, eigenvals, envfit, estaccumR, estimateR, eventstar, factorfit, fisherfit, fitspecaccum, -goodness, hiersimu, humpfit, indpower, inertcomp, initMDS, +gdispweight,goodness, hiersimu, humpfit, indpower, inertcomp, initMDS, intersetcor, isomapdist, isomap, linestack, mantel, meandist, metaMDSdist, metaMDSiter, metaMDSredist, MDSrotate, metaMDS, monoMDS, mrpp, msoplot, mso, multipart, make.commsim, nestedbetajac, nestedbetasor, nestedchecker, @@ -356,6 +356,7 @@ S3method(print, summary.cca) S3method(print, summary.clamtest) S3method(print, summary.decorana) +S3method(print, summary.dispweight) S3method(print, summary.humpfit) S3method(print, summary.isomap) S3method(print, summary.meandist) @@ -428,6 +429,7 @@ S3method(summary, cca) S3method(summary, clamtest) S3method(summary, decorana) +S3method(summary, dispweight) S3method(summary, eigenvals) S3method(summary, humpfit) S3method(summary, isomap) Modified: pkg/vegan/R/dispweight.R =================================================================== --- pkg/vegan/R/dispweight.R 2014-09-23 07:20:05 UTC (rev 2887) +++ pkg/vegan/R/dispweight.R 2014-09-24 08:53:17 UTC (rev 2888) @@ -1,66 +1,59 @@ `dispweight` <- - function(comm, group, nperm = 1000) + function(comm, groups, nsimul = 999, nullmodel = "c0_ind", + plimit = 0.05) { - # number of replicates per group - nrep <- tabulate(group) - # workhorse - dfun <- function(comm, group, nperm, nrep) { - ## Calc Dispersion - # group means - means <- tapply(comm, group, mean) - # omit groups with mean == 0 - if(any(means == 0)) { - comm <- comm[means[group] != 0] - group <- group[means[group] != 0, drop = TRUE] - nrep <- nrep[means != 0] - means <- means[means != 0] - } - # group variances - vars <- tapply(comm, group, var) - # dispersion - d <- vars / means - # average dispersion - d_hat <- sum(d * (nrep - 1)) / sum(nrep - 1) - - ## Test - # original chisq values - chi_o <- sum((comm - means[group])^2 / means[group]) - - # permutations - # calculate chisq - pfun <- function(comm, group){ - means <- tapply(comm, group, mean) - if(any(means == 0)) { - comm <- comm[means[group] != 0] - group <- group[means[group] != 0, drop = TRUE] - means <- means[means != 0] - } - chi <- sum((comm - means[group])^2 / means[group]) - return(chi) - } - # sum of individuals per group - sums <- tapply(comm, group, sum) - # realocate randomly individuals to replications - perms <- vector('list', length(sums)) - for(i in seq_along(sums)) { - perms[[i]] <- rmultinom(n = nperm, size = sums[i], prob = rep(1, nrep[i]) / nrep[i]) - } - perms <- t(do.call(rbind, perms)) - chi_p <- apply(perms, 1, pfun, sort(group)) - p <- (sum(chi_p >= chi_o) + 1) / (nperm + 1) - out <- list(D = d_hat, p = p, weights = ifelse(p < 0.05, 1/d_hat, 1)) - return(out) + ## no groups? + if (missing(groups)) + groups <- rep(1, nrow(comm)) + ## Remove empty levels of 'groups' or this fails cryptically (and + ## take care 'groups' is a factor) + groups <- factor(groups) + ## Statistic is the sum of squared differences by 'groups' + means <- apply(comm, 2, function(x) tapply(x, groups, mean)) + ## handle 1-level factors: all sites belong to the same 'groups' + if (is.null(dim(means))) + means <- matrix(means, nrow=1, ncol = length(means), + dimnames = list(levels(groups), names(means))) + ## expand to matrix of species means + fitted <- means[groups,] + dhat <- colSums((comm - fitted)^2/fitted, na.rm = TRUE) + ## Get df for non-zero blocks of species. Completely ignoring + ## all-zero blocks for species sounds strange, but was done in the + ## original paper, and we follow here. However, this was not done + ## for significance tests, and only concerns 'D' and 'weights'. + nreps <- table(groups) + div <- colSums(sweep(means > 0, 1, nreps - 1, "*")) + ## "significance" of overdispersion is assessed from Chi-square + ## evaluated separately for each species. This means fixing only + ## marginal totals for species but letting row marginals vary + ## freely, unlike in standard Chi-square where both margins are + ## fixed. In vegan this is achieved by nullmodel 'c0_ind'. Instead + ## of one overall simulation, nullmodel is generated separately + ## for each of 'groups' + chisq <- function(x) { + fitted <- colMeans(x) + colSums(sweep(x, 2, fitted)^2, na.rm = TRUE) / fitted } - # apply workhorse to every species - out <- apply(comm, 2, dfun, group, nperm, nrep) - - # format output - weights <- unlist(sapply(out, '[', 3)) - out <- list(D = unlist(sapply(out, '[', 1)), - p = unlist(sapply(out, '[', 2)), - weights = weights, - transformed = sweep(comm, MARGIN = 2, weights, `*`)) - attr(out, "permutations") <- nperm - class(out) <- "dispweight" - return(out) -} \ No newline at end of file + simulated <- matrix(0, nrow = ncol(comm), ncol = nsimul) + for (lev in levels(groups)) { + nm <- nullmodel(comm[groups == lev,], nullmodel) + if (nm$commsim$binary) + stop("'binary' nullmodel cannot be used") + tmp <- apply(simulate(nm, nsimul), 3, chisq) + ok <- !is.na(tmp) + simulated[ok] <- simulated[ok] + tmp[ok] + } + ## p value based on raw dhat, then we divide + p <- (rowSums(dhat <= simulated) + 1) / (nsimul + 1) + dhat <- dhat/div + weights <- ifelse(p <= plimit, 1/dhat, 1) + comm <- sweep(comm, 2, weights, "*") + attr(comm, "D") <- dhat + attr(comm, "df") <- div + attr(comm, "p") <- p + attr(comm, "weights") <- weights + attr(comm, "nsimul") <- nsimul + attr(comm, "nullmodel") <- nullmodel + class(comm) <- c("dispweight", class(comm)) + comm +} Added: pkg/vegan/R/gdispweight.R =================================================================== --- pkg/vegan/R/gdispweight.R (rev 0) +++ pkg/vegan/R/gdispweight.R 2014-09-24 08:53:17 UTC (rev 2888) @@ -0,0 +1,52 @@ +### Clarke's dispweight is based on the hypothesis that count data +### should follow Poisson distribution, and species overdispersed to +### the Poisson should be downweighted. The basic model assesses the +### expected values of species and their overdispersion wrt to class +### means for a single factor and then estimates the significance of +### the overdispersion using individual-based simulation within these +### same classes. Function gdispweight generalizes this by allowing a +### formula that specifies any fitted model, but estimates the +### significance of the overdispersion analytically from Pearson +### residuals. + +`gdispweight` <- + function(formula, data, plimit = 0.05) +{ + ## We do not handle missing values (yet?) + op <- options(na.action = "na.fail") + on.exit(op) + ## extract response data + comm <- eval(formula[[2]]) + ## extract rhs + if (missing(data)) + data <- environment(formula) + x <- model.matrix(delete.response(terms(formula, data = data)), + data = data) + ## Quasi-Poisson + family <- quasipoisson() + V <- family$variance + ## fit models to all species separately and extract results + mods <- lapply(comm, function(y) glm.fit(x, y, family = family)) + y <- sapply(mods, '[[', "y") + mu <- sapply(mods, fitted) + wts <- sapply(mods, '[[', "prior.weights") + res <- (y-mu) * sqrt(wts) / sqrt(V(mu)) + df <- sapply(mods, df.residual) + ## the same stats as in Clarke's original, but parametrically + stat <- colSums(res^2) + p <- pchisq(stat, df, lower.tail = FALSE) + dhat <- stat/df + w <- ifelse(p < plimit, 1/dhat, 1) + ## do not upweight underdispersed species + w <- ifelse(w > 1, 1, w) + ## done + comm <- sweep(comm, 2, w, "*") + class(comm) <- c("dispweight", class(comm)) + attr(comm, "D") <- dhat + attr(comm, "df") <- df + attr(comm, "p") <- p + attr(comm, "weights") <- w + attr(comm, "nsimul") <- NA + attr(comm, "nullmodel") <- NA + comm +} Added: pkg/vegan/R/summary.dispweight.R =================================================================== --- pkg/vegan/R/summary.dispweight.R (rev 0) +++ pkg/vegan/R/summary.dispweight.R 2014-09-24 08:53:17 UTC (rev 2888) @@ -0,0 +1,22 @@ +### summary methods extracts dispweight attributes, and prints a table +### of dispersion statistics + +`summary.dispweight` <- + function(object, ...) +{ + x <- attributes(object) + class(x) <- "summary.dispweight" + x +} + +`print.summary.dispweight` <- + function(x, ...) +{ + tab <- with(x, cbind(D, weights, df, p)) + colnames(tab) <- c("Dispersion", "Weight", "Df", "Pr(Disp.)") + printCoefmat(tab, cs.ind = NA, ...) + if (!is.na(x$nsimul)) + cat(gettextf("Based on %d simulations on '%s' nullmodel\n", + x$nsimul, x$nullmodel)) + invisible(x) +} Modified: pkg/vegan/man/dispweight.Rd =================================================================== --- pkg/vegan/man/dispweight.Rd 2014-09-23 07:20:05 UTC (rev 2887) +++ pkg/vegan/man/dispweight.Rd 2014-09-24 08:53:17 UTC (rev 2888) @@ -1,57 +1,120 @@ \encoding{UTF-8} \name{dispweight} \alias{dispweight} +\alias{gdispweight} +\alias{summary.dispweight} \title{Dispersion-based weighting of species counts} -\description{Transform abundance data using dispersion-based weighting of species counts} +\description{Transform abundance data downweighting species that are + overdispersed to the Poisson error.} -\usage{dispweight(comm, group, nperm = 1000)} +\usage{ +dispweight(comm, groups, nsimul = 999, nullmodel = "c0_ind", + plimit = 0.05) +gdispweight(formula, data, plimit = 0.05) +\method{summary}{dispweight}(object, ...) +} \arguments{ \item{comm}{Community data matrix.} - \item{group}{Factor describing the group structure.} - \item{nperm}{Number of permutations.} + \item{groups}{Factor describing the group structure. If missing, all + sites are regarded as belonging to one group. \code{NA} values are + not allowed.} + \item{nsimul}{Number of simulations.} + \item{nullmodel}{The \code{\link{nullmodel}} used in + \code{\link{commsim}} within \code{groups}. The default + follows Clarke et al. (2006).} + \item{plimit}{Downweight species if their \eqn{p}-value is at or + below this limit.} + \item{formula, data}{Formula where the left-hand side is the + community data frame and right-hand side gives the explanatory + variables. The explanatory variables are found in the data frame + given in \code{data} or in the parent frame.} + \item{object}{Result object from \code{dispweight} or + \code{gdispweight}.} + \item{\dots}{Other parameters passed to functions.} } \details{ -Dispersion weighting can be used when there are \emph{a priori} defined groups -(eg. lacation of samples). -The dispersion index (\eqn{D}) is calculated as ratio between -variance and mean and averaged across groups. D can then be used as divisor to -downweight species abundances. +The dispersion index (\eqn{D}) is calculated as ratio between variance +and expected value for each species. If the species abundances follow +Poisson distribution, expected dispersion is \eqn{E(D) = 1}, and if +\eqn{D > 1}, the species is overdispersed. The inverse \eqn{1/D} can +be used to downweight species abundances. Species are only +downweighted when overdispersion is judged to be statistically +significant (Clarke et al. 2006). -However species should be only downweighted, when there is evidence for -over-dispersion (\eqn{D > 1}). This is tested using a permutational Chi-squared test. -If this test shows statistically significant over-dispersion then the species is -downweighted by \eqn{1/D}, else the divisor is \eqn{1}. +Function \code{dispweight} implements the original procedure of Clarke +et al. (2006). Only one factor can be used to group the sites and to +find the species means. The significance of overdispersion is assessed +freely distributing individuals of each species within factor +levels. This is achieved by using \code{\link{nullmodel}} +\code{"c0_ind"} (which accords to Clarke et al. 2006), but other +nullmodels can be used, though they may not be meaningful (see +\code{\link{commsim}} for alternatives). If a species is absent in +some factor level, the whole level is ignored in calculation of +overdispersion, and the number of degrees of freedom can vary among +species. The reduced number of degrees of freedom is used as a divisor +for overdispersion \eqn{D}, and such species have higher dispersion +and hence lower weights in transformation. + +Function \code{gdispweight} is a generalized parametric version of +\code{dispweight}. The function is based on \code{\link{glm}} with +\code{\link{quasipoisson}} error \code{\link{family}}. Any +\code{\link{glm}} model can be used, including several factors or +continuous covariates. Function \code{gdispweight} uses the same test +statistic as \code{dispweight} (Pearson Chi-square), but it does not +ignore factor levels where species is absent, and the number of +degrees of freedom is equal for all species. Therefore transformation +weights can be higher than in \code{dispweight}. The +\code{gdispweight} function evaluates the significance of +overdispersion parametrically from Chi-square distribution +(\code{\link{pchisq}}). + +Functions \code{dispweight} and \code{gdispweight} transform data, but +they add information on overdispersion and weights as attributes of +the result. The \code{summary} can be used to extract and print that +information. } \value{ -A list of class \code{dispweight} with the following items: - \item{D}{Average Dispersion index.} - \item{p}{\eqn{p}-value of permutation test that \eqn{D = 1}.} +Function returns transformed data with the following new attributes: + \item{D}{Dispersion statistic.} + \item{df}{Degrees of freedom for each species.} + \item{p}{\eqn{p}-value of the Dispersion statistic \eqn{D}.} \item{weights}{weights applied to community data.} - \item{transformed}{transformed community data.} + \item{nsimul}{Number of simulations used to assess the \eqn{p}-value, + or \code{NA} when simulations were not performed.} + \item{nullmodel}{The name of \code{\link{commsim}} null model, or + \code{NA} when simulations were not performed.} } \references{ -Clarke, K. R., M. G. Chapman, P. J. Somerfield, and H. R. Needham. 2006. Dispersion-based Weighting of Species Counts in Assemblage Analyses. \emph{Marine Ecology Progress Series}, 320, 11?27. +Clarke, K. R., M. G. Chapman, P. J. Somerfield, and +H. R. Needham. 2006. Dispersion-based weighting of species counts in +assemblage analyses. \emph{Marine Ecology Progress Series}, 320, +11?27. } + \author{ - Eduard Sz?cs \email{szoe8822 at uni-landau.de} + Eduard Sz?cs \email{eduardszoesc at gmail.com} wrote the original + \code{dispweight}, Jari Oksanen significantly modified the code, + provided support functions and developed \code{gdispweight}. } \examples{ -data(dune) -data(dune.env) -# calculate weights -dpw <- dispweight(dune, dune.env$Management, nperm = 100) -# transformed community data -dpw$transformed +data(mite, mite.env) +## dispweight and its summary +mite.dw <- with(mite.env, dispweight(mite, Shrub, nsimul = 99)) +summary(mite.dw) +## generalized dispersion weighting +mite.dw <- gdispweight(mite ~ Shrub + WatrCont, data = mite.env) +rda(mite.dw ~ Shrub + WatrCont, data = mite.env) } \keyword{multivariate} +\keyword{manip} From noreply at r-forge.r-project.org Tue Sep 30 09:24:03 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 30 Sep 2014 09:24:03 +0200 (CEST) Subject: [Vegan-commits] r2889 - in pkg/vegan: . R man tests tests/Examples Message-ID: <20140930072403.6F58F186B67@r-forge.r-project.org> Author: jarioksa Date: 2014-09-30 09:24:02 +0200 (Tue, 30 Sep 2014) New Revision: 2889 Added: pkg/vegan/R/permustats.R pkg/vegan/man/permustats.Rd Removed: pkg/vegan/R/density.anosim.R pkg/vegan/R/density.oecosimu.R pkg/vegan/R/densityplot.oecosimu.R pkg/vegan/man/density.adonis.Rd Modified: pkg/vegan/NAMESPACE pkg/vegan/R/print.oecosimu.R pkg/vegan/R/vegan-deprecated.R pkg/vegan/man/adonis.Rd pkg/vegan/man/anosim.Rd pkg/vegan/man/betadisper.Rd pkg/vegan/man/mantel.Rd pkg/vegan/man/mrpp.Rd pkg/vegan/man/oecosimu.Rd pkg/vegan/man/procrustes.Rd pkg/vegan/man/vegan-deprecated.Rd pkg/vegan/tests/Examples/vegan-Ex.Rout.save pkg/vegan/tests/oecosimu-tests.R pkg/vegan/tests/oecosimu-tests.Rout.save pkg/vegan/tests/vegan-tests.Rout.save Log: Merge branch 'master' into r-forge-svn-local Add permustats() function and their support with replace and enhance old density and densityplot methods for permutation and simulation results. Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/NAMESPACE 2014-09-30 07:24:02 UTC (rev 2889) @@ -19,7 +19,7 @@ ordihull, ordilabel, ordiplot, ordipointlabel, ordiresids, ordisegments, ordispider, ordisplom, ordistep, ordisurf, orditkplot, orditorp, ordixyplot, -pcnm, permatfull, permatswap, permutest, +pcnm, permatfull, permatswap, permustats, permutest, poolaccum, postMDS, prc, prestondistr, prestonfit, procrustes, protest, radfit, radlattice, rankindex, rarefy, rarecurve, raupcrick, rda, renyiaccum, renyi, rrarefy, scores, scoverage, @@ -51,6 +51,15 @@ ## Export .Depracated functions (to be removed later) export(commsimulator) +S3method(density, adonis) +S3method(density, anosim) +S3method(density, mantel) +S3method(density, mrpp) +S3method(density, oecosimu) +S3method(density, permutest.cca) +S3method(density, protest) +S3method(densityplot, adonis) +S3method(densityplot, oecosimu) ## do NOT export the following internal functions @@ -140,16 +149,9 @@ # cophenetic: stats S3method(cophenetic, spantree) # density: stats -S3method(density, adonis) -S3method(density, anosim) -S3method(density, mantel) -S3method(density, mrpp) -S3method(density, oecosimu) -S3method(density, permutest.cca) -S3method(density, protest) +S3method(density, permustats) # densityplot: lattice -S3method(densityplot, adonis) -S3method(densityplot, oecosimu) +S3method(densityplot, permustats) # deviance: stats S3method(deviance, cca) S3method(deviance, rda) @@ -237,6 +239,26 @@ # ordisurf: vegan S3method(ordisurf, default) S3method(ordisurf, formula) + +## permustats methods +S3method(permustats, adonis) +S3method(permustats, anosim) +S3method(permustats, mantel) +S3method(permustats, mrpp) +S3method(permustats, oecosimu) +S3method(permustats, permutest.cca) +## these return an error: no permutation data +S3method(permustats, CCorA) +S3method(permustats, envfit) +S3method(permustats, factorfit) +S3method(permustats, vectorfit) +S3method(permustats, mso) +S3method(permustats, permutest.betadisper) + +S3method(print, permustats) +S3method(summary, permustats) +S3method(print, summary.permustats) + # permutest: vegan S3method(permutest, betadisper) S3method(permutest, cca) @@ -375,6 +397,10 @@ # see note on 'confint' S3method(profile, MOStest) S3method(profile, humpfit) +## qqmath: lattice +S3method(qqmath, permustats) +## qqnorm: stats +S3method(qqnorm, permustats) # radfit: vegan S3method(radfit, data.frame) S3method(radfit, default) Deleted: pkg/vegan/R/density.anosim.R =================================================================== --- pkg/vegan/R/density.anosim.R 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/R/density.anosim.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -1,135 +0,0 @@ -### density & densityplot methods for vegan functions returning -### statistics from permuted/simulated data. These are modelled after -### density.oecosimu and densityplot.oecosimu (which are in their -### separate files). - -## anosim - -`density.anosim` <- - function(x, ...) -{ - obs <- x$statistic - ## Put observed statistic among permutations - out <- density(c(obs, x$perm), ...) - out$call <- match.call() - out$observed <- obs - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -## adonis can return a matrix of terms, hence we also have densityplot() - -`density.adonis` <- - function(x, ...) -{ - cols <- ncol(x$f.perms) - if (cols > 1) - warning("'density' is meaningful only with one term, you have ", cols) - obs <- x$aov.tab$F.Model - obs <- obs[!is.na(obs)] - out <- density(c(obs, x$f.perms), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -`densityplot.adonis` <- - function(x, data, xlab = "Null", ...) -{ - obs <- x$aov.tab$F.Model - obs <- obs[!is.na(obs)] - sim <- rbind(obs, x$f.perms) - nm <- rownames(x$aov.tab)[col(sim)] - densityplot( ~ as.vector(sim) | factor(nm, levels = unique(nm)), - xlab = xlab, - panel = function(x, ...) { - panel.densityplot(x, ...) - panel.abline(v = obs[panel.number()], ...) - }, - ...) -} - -## mantel - -`density.mantel` <- - function(x, ...) -{ - obs <- x$statistic - out <- density(c(obs, x$perm), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -## mrpp - -`density.mrpp` <- - function(x, ...) -{ - obs <- x$delta - out <- density(c(obs, x$boot.deltas), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -## anova.cca does not return permutation results, but permutest.cca -## does. However, permutest.cca always finds only one statistic. Full -## tables anova.cca are found by repeated calls to permutest.cca. - -`density.permutest.cca` <- - function(x, ...) -{ - obs <- x$F.0 - out <- density(c(obs, x$F.perm), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -## protest - -`density.protest` <- - function(x, ...) -{ - obs <- x$t0 - out <- density(c(obs, x$t), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} - -#### plot method: the following copies stats::plot.density() code but -#### adds one new argument to draw abline(v=...) for the observed -#### statistic - -`plot.vegandensity` <- - function (x, main = NULL, xlab = NULL, ylab = "Density", type = "l", - zero.line = TRUE, obs.line = TRUE, ...) -{ - if (is.null(xlab)) - xlab <- paste("N =", x$n, " Bandwidth =", formatC(x$bw)) - if (is.null(main)) - main <- deparse(x$call) - ## change obs.line to col=2 (red) if it was logical TRUE - if (isTRUE(obs.line)) - obs.line <- 2 - plot.default(x, main = main, xlab = xlab, ylab = ylab, type = type, - ...) - if (zero.line) - abline(h = 0, lwd = 0.1, col = "gray") - if (is.character(obs.line) || obs.line) - abline(v = x$observed, col = obs.line) - invisible(NULL) -} Deleted: pkg/vegan/R/density.oecosimu.R =================================================================== --- pkg/vegan/R/density.oecosimu.R 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/R/density.oecosimu.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -1,14 +0,0 @@ -`density.oecosimu` <- - function(x, ...) -{ - cols <- nrow(x$oecosimu$simulated) - if (cols > 1) - warning("'density' is meaningful only with one statistic, you have ", cols) - obs <- x$oecosimu$statistic - out <- density(rbind(obs, t(x$oecosimu$simulated)), ...) - out$observed <- obs - out$call <- match.call() - out$call[[1]] <- as.name("density") - class(out) <- c("vegandensity", class(out)) - out -} Deleted: pkg/vegan/R/densityplot.oecosimu.R =================================================================== --- pkg/vegan/R/densityplot.oecosimu.R 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/R/densityplot.oecosimu.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -1,14 +0,0 @@ -`densityplot.oecosimu` <- - function(x, data, xlab = "Simulated", ...) -{ - obs <- x$oecosimu$statistic - sim <- rbind(obs, t(x$oecosimu$simulated)) - nm <- names(obs)[col(sim)] - densityplot( ~ as.vector(sim) | factor(nm, levels = unique(nm)), - xlab = xlab, - panel = function(x, ...) { - panel.densityplot(x, ...) - panel.abline(v = obs[panel.number()], ...) - }, - ...) -} Added: pkg/vegan/R/permustats.R =================================================================== --- pkg/vegan/R/permustats.R (rev 0) +++ pkg/vegan/R/permustats.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -0,0 +1,241 @@ +### Functions to extract permutation statististic or null model +### results from various vegan objects. + +## extract items as 'statistic' and 'permutations'. Specific methods +## towards the end of this file + +`permustats` <- + function(x, ...) +{ + UseMethod("permustats") +} + +## something like str() +`print.permustats` <- + function(x, ...) +{ + print(str(x)) + invisible(x) +} + +### modelled after print.oecosimu (should perhaps have oecosimu() args +### like 'alternative' + +`summary.permustats` <- + function(object, probs, ...) +{ + ## default cut levels for quantiles: these are two-sided + if (missing(probs)) + probs <- switch(object$alternative, + "two.sided" = c(0.025, 0.5, 0.975), + "greater" = c(0.5, 0.95), + "less" = c(0.05, 0.5)) + sim <- t(object$permutations) + object$means <- rowMeans(sim) + sd <- apply(sim, 1, sd) + object$z <- + (object$statistic - object$means)/sd + object$quantile <- + apply(sim, 1, quantile, probs = probs, na.rm = TRUE) + ## not (yet) P-values... + class(object) <- "summary.permustats" + object +} + +`print.summary.permustats` <- + function(x, ...) +{ + m <- cbind("statistic" = x$statistic, + "z" = x$z, + "mean" = x$means, + t(x$quantile)) + printCoefmat(m, cs.ind = 3:ncol(m), ...) + invisible(x) +} + +### densityplot + +`densityplot.permustats` <- + function(x, data, xlab = "Permutations", ...) +{ + obs <- x$statistic + sim <- rbind(x$statistic, as.matrix(x$permutations)) + nm <- names(obs)[col(sim)] + densityplot( ~ as.vector(sim) | factor(nm, levels = unique(nm)), + xlab = xlab, + panel = function(x, ...) { + panel.densityplot(x, ...) + panel.abline(v = obs[panel.number()], ...) + }, + ...) +} + +### simple density: normally densityplot should be used (or I suggest +### so), but we also offer basic density. This can be either with or +### without observed statistic. + +`density.permustats` <- + function(x, observed = TRUE, ...) +{ + ## only works with statistic + if (length(x$statistic) > 1) + stop(gettextf("only works with one statistic: you got %d", + length(x$statistic))) + p <- x$permutations + if (observed) + p <- c(x$statistic, p) + out <- density(p) + out$call <- match.call() + out$call[[1]] <- as.name("density") + out +} + +### QQ-plot against Guaussian distribution + +`qqnorm.permustats` <- + function(y, observed = TRUE, ...) +{ + ## only works with statistic + if (length(y$statistic) > 1) + stop(gettextf("only works with one statistic: you got %d", + length(y$statistic))) + p <- y$permutations + if (observed) + p <- c(y$statistic, p) + q <- qqnorm(p, ...) + if (observed) + abline(h = y$statistic, ...) + invisible(q) +} + +`qqmath.permustats` <- + function(x, data, observed = TRUE, ylab = "Permutations", ...) +{ + obs <- x$statistic + if (observed) + sim <- rbind(x$statistic, as.matrix(x$permutations)) + else + sim <- as.matrix(x$permutations) + nm <- names(obs)[col(sim)] + qqmath( ~ as.vector(sim) | factor(nm, levels = unique(nm)), + ylab = ylab, + panel = function(x, ...) { + panel.qqmath(x, ...) + if (observed) + panel.abline(h = obs[panel.number()], ...) + }, + ...) +} + +### +### specific methods to extract permustats +### + +`permustats.anosim` <- + function(x, ...) +{ + structure(list( + "statistic" = structure(x$statistic, names="R"), + "permutations" = x$perm, + "alternative" = "greater"), + class="permustats") +} + +`permustats.adonis` <- + function(x, ...) +{ + tab <- x$aov.tab + k <- !is.na(tab$F.Model) + structure(list( + "statistic" = structure(tab$F.Model[k], names = rownames(tab)[k]), + "permutations" = x$f.perms, + "alternative" = "greater"), + class="permustats") +} + +`permustats.mantel` <- + function(x, ...) +{ + structure(list( + "statistic" = structure(x$statistic, names="r"), + "permutations" = x$perm, + "alternative" = "greater"), + class="permustats") +} + +`permustats.mrpp` <- + function(x, ...) +{ + structure(list( + "statistic" = structure(x$delta, names="delta"), + "permutations" = x$boot.deltas, + "alternative" = "less"), + class="permustats") +} + +`permustats.oecosimu` <- + function(x, ...) +{ + structure(list( + "statistic" = x$oecosimu$statistic, + "permutations" = t(x$oecosimu$simulated), + "alternative" = x$oecosimu$alternative), + class="permustats") +} + +`permustats.permutest.cca` <- + function(x, ...) +{ + structure(list( + "statistic" = structure(x$F.0, names = "F"), + "permutations" = x$F.perm, + "alternative" = "greater"), + class="permustats") +} + +`permustats.protest` <- + function(x, ...) +{ + structure(list( + "statistic" = structure(x$t0, names = "r"), + "permutations" = x$t, + "alternative" = "greater"), + class="permustats") +} + +### the following do not return permutation data +`permustats.CCorA` <- + function(x, ...) +{ + stop("no permutation data available") +} + +`permustats.envfit` <- + function(x, ...) +{ + stop("no permutation data available") +} + +`permustats.factorfit` <- + function(x, ...) +{ + stop("no permutation data available") +} + +`permustats.vectorfit` <- + function(x, ...) +{ + stop("no permutation data available") +} + +`permustats.mso` <- + function(x, ...) +{ + stop("no permutation data available") +} + +`permustats.permutest.betadisper` <- + function(x, ...) +{ + stop("no permutation data available") +} Modified: pkg/vegan/R/print.oecosimu.R =================================================================== --- pkg/vegan/R/print.oecosimu.R 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/R/print.oecosimu.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -28,13 +28,13 @@ } probs <- switch(x$oecosimu$alternative, two.sided = c(0.025, 0.5, 0.975), - greater = c(0, 0.5, 0.95), - less = c(0.05, 0.5, 1)) + greater = c(0.5, 0.95), + less = c(0.05, 0.5)) qu <- apply(x$oecosimu$simulated, 1, quantile, probs=probs, na.rm = TRUE) m <- cbind("statistic" = x$oecosimu$statistic, "z" = x$oecosimu$z, "mean" = x$oecosimu$means, t(qu), "Pr(sim.)"=x$oecosimu$pval) - printCoefmat(m, cs.ind = 3:6, ...) + printCoefmat(m, cs.ind = 3:(ncol(m)-1), ...) if (any(is.na(x$oecosimu$simulated))) { nacount <- rowSums(is.na(x$oecosimu$simulated)) cat("\nNumber of NA cases removed from simulations:\n", Modified: pkg/vegan/R/vegan-deprecated.R =================================================================== --- pkg/vegan/R/vegan-deprecated.R 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/R/vegan-deprecated.R 2014-09-30 07:24:02 UTC (rev 2889) @@ -1,6 +1,9 @@ +### rewritten commsimulator + "commsimulator" <- function (x, method, thin = 1) { + .Deprecated("nullmodel", package="vegan") method <- match.arg(method, c("r0","r1","r2","r00","c0","swap", "tswap", "backtrack", "quasiswap")) @@ -12,3 +15,189 @@ attributes(out) <- attributes(x) out } + +### density and densityplot + +### density & densityplot methods for vegan functions returning +### statistics from permuted/simulated data. These are modelled after +### density.oecosimu and densityplot.oecosimu (which are in their +### separate files). + +## anosim + +`density.anosim` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$statistic + ## Put observed statistic among permutations + out <- density(c(obs, x$perm), ...) + out$call <- match.call() + out$observed <- obs + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +## adonis can return a matrix of terms, hence we also have densityplot() + +`density.adonis` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + cols <- ncol(x$f.perms) + if (cols > 1) + warning("'density' is meaningful only with one term, you have ", cols) + obs <- x$aov.tab$F.Model + obs <- obs[!is.na(obs)] + out <- density(c(obs, x$f.perms), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +`densityplot.adonis` <- + function(x, data, xlab = "Null", ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$aov.tab$F.Model + obs <- obs[!is.na(obs)] + sim <- rbind(obs, x$f.perms) + nm <- rownames(x$aov.tab)[col(sim)] + densityplot( ~ as.vector(sim) | factor(nm, levels = unique(nm)), + xlab = xlab, + panel = function(x, ...) { + panel.densityplot(x, ...) + panel.abline(v = obs[panel.number()], ...) + }, + ...) +} + +## mantel + +`density.mantel` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$statistic + out <- density(c(obs, x$perm), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +## mrpp + +`density.mrpp` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$delta + out <- density(c(obs, x$boot.deltas), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +## anova.cca does not return permutation results, but permutest.cca +## does. However, permutest.cca always finds only one statistic. Full +## tables anova.cca are found by repeated calls to permutest.cca. + +`density.permutest.cca` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$F.0 + out <- density(c(obs, x$F.perm), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +## protest + +`density.protest` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$t0 + out <- density(c(obs, x$t), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +#### plot method: the following copies stats::plot.density() code but +#### adds one new argument to draw abline(v=...) for the observed +#### statistic + +`plot.vegandensity` <- + function (x, main = NULL, xlab = NULL, ylab = "Density", type = "l", + zero.line = TRUE, obs.line = TRUE, ...) +{ + if (is.null(xlab)) + xlab <- paste("N =", x$n, " Bandwidth =", formatC(x$bw)) + if (is.null(main)) + main <- deparse(x$call) + ## change obs.line to col=2 (red) if it was logical TRUE + if (isTRUE(obs.line)) + obs.line <- 2 + plot.default(x, main = main, xlab = xlab, ylab = ylab, type = type, + ...) + if (zero.line) + abline(h = 0, lwd = 0.1, col = "gray") + if (is.character(obs.line) || obs.line) + abline(v = x$observed, col = obs.line) + invisible(NULL) +} + +`density.oecosimu` <- + function(x, ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + cols <- nrow(x$oecosimu$simulated) + if (cols > 1) + warning("'density' is meaningful only with one statistic, you have ", cols) + obs <- x$oecosimu$statistic + out <- density(rbind(obs, t(x$oecosimu$simulated)), ...) + out$observed <- obs + out$call <- match.call() + out$call[[1]] <- as.name("density") + class(out) <- c("vegandensity", class(out)) + out +} + +`densityplot.oecosimu` <- + function(x, data, xlab = "Simulated", ...) +{ + .Deprecated("densityplot(permustats())", + package="vegan") + obs <- x$oecosimu$statistic + sim <- rbind(obs, t(x$oecosimu$simulated)) + nm <- names(obs)[col(sim)] + densityplot( ~ as.vector(sim) | factor(nm, levels = unique(nm)), + xlab = xlab, + panel = function(x, ...) { + panel.densityplot(x, ...) + panel.abline(v = obs[panel.number()], ...) + }, + ...) +} Modified: pkg/vegan/man/adonis.Rd =================================================================== --- pkg/vegan/man/adonis.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/adonis.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -138,9 +138,8 @@ your predictors. } \item{f.perms}{ an \eqn{N} by \eqn{m} matrix of the null \eqn{F} statistics for each source of variation based on \eqn{N} - permutations of the data. The distribution of a single term can be - inspected with \code{\link{density.adonis}} function, or all terms - simultaneously with \code{densityplot.adonis}.} + permutations of the data. The permutations can be inspected with + \code{\link{permustats}} and its support functions.} \item{model.matrix}{The \code{\link{model.matrix}} for the right hand side of the formula.} \item{terms}{The \code{\link{terms}} component of the model.} Modified: pkg/vegan/man/anosim.Rd =================================================================== --- pkg/vegan/man/anosim.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/anosim.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -61,7 +61,7 @@ permuting the grouping vector to obtain the empirical distribution of \eqn{R} under null-model. See \code{\link{permutations}} for additional details on permutation tests in Vegan. The distribution - of simulated values can be inspected with the \code{density} + of simulated values can be inspected with the \code{\link{permustats}} function. The function has \code{summary} and \code{plot} methods. These both @@ -78,7 +78,7 @@ \item{statistic}{The value of ANOSIM statistic \eqn{R}} \item{signif}{Significance from permutation.} \item{perm}{Permutation values of \eqn{R}. The distribution of - permutation values can be inspected with function \code{\link{density.anosim}}.} + permutation values can be inspected with function \code{\link{permustats}}.} \item{class.vec}{Factor with value \code{Between} for dissimilarities between classes and class name for corresponding dissimilarity within class.} Modified: pkg/vegan/man/betadisper.Rd =================================================================== --- pkg/vegan/man/betadisper.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/betadisper.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -111,7 +111,7 @@ parts respectively. This is equation (3) in Anderson (2006). If the imaginary part is greater in magnitude than the real part, then we would be taking the square root of a negative value, resulting in - NaN. From \pkg{vegan} 1.12-12 \code{betadisper} takes the absolute + NaN. Function takes the absolute value of the real distance minus the imaginary distance, before computing the square root. This is in line with the behaviour of Marti Anderson's PERMDISP2 programme. @@ -140,7 +140,7 @@ (Anderson \emph{et al} 2006). Function \code{\link{betadiver}} provides some popular dissimilarity measures for this purpose. - As noted in passing by Anderson (2001) and in a related + As noted in passing by Anderson (2006) and in a related context by O'Neill (2000), estimates of dispersion around a central location (median or centroid) that is calculated from the same data will be biased downward. This bias matters most when comparing diversity @@ -200,9 +200,6 @@ analysis gives the correct error rates. } \references{ - Anderson, M. J. (2001) A new method for non-parametric multivariate - analysis of variance. \emph{Austral Ecology} \strong{26}, 32--46. - Anderson, M.J. (2006) Distance-based tests for homogeneity of multivariate dispersions. \emph{Biometrics} \strong{62}, 245--253. Deleted: pkg/vegan/man/density.adonis.Rd =================================================================== --- pkg/vegan/man/density.adonis.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/density.adonis.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -1,114 +0,0 @@ -\name{density.adonis} -\alias{density.adonis} -\alias{density.anosim} -\alias{density.mantel} -\alias{density.mrpp} -\alias{density.permutest.cca} -\alias{density.protest} -\alias{plot.vegandensity} -\alias{densityplot.adonis} - -\title{ - Kernel Density Estimation for Permutation Results in Vegan -} - -\description{ - The \code{density} functions can directly access the permutation - results of \pkg{vegan} functions, and \code{plot} can display the - densities. The \code{densityplot} method can access and display the - permutation results of functions that return permutations of several - statistics simultaneously. -} - -\usage{ -\method{density}{adonis}(x, ...) -\method{plot}{vegandensity}(x, main = NULL, xlab = NULL, ylab = "Density", - type = "l", zero.line = TRUE, obs.line = TRUE, ...) -} - -\arguments{ - \item{x}{The object to be handled. For \code{density} and - \code{densityplot} this is an object containing permutations. For - \code{plot} this is a result of \pkg{vegan} \code{density} - function.} - \item{main, xlab, ylab, type, zero.line}{Arguments of - \code{\link{plot.density}} and \code{\link[lattice]{densityplot}} - functions.} - \item{obs.line}{Draw vertical line for the observed - statistic. Logical value \code{TRUE} draws a red line, and - \code{FALSE} draws nothing. Alternatively, \code{obs.line} can be a - definition of the colour used for the line, either as a numerical - value from the \code{\link[grDevices]{palette}} or as the name of - the colour, or other normal definition of the colour.} - \item{\dots}{ Other arguments passed to the function. In - \code{density} these are passed to \code{\link{density.default}}.} -} - -\details{ - - The \code{density} and \code{densityplot} function can directly access - permutation results of most \pkg{vegan} functions. The \code{density} - function is identical to \code{\link{density.default}} and takes all - its arguments, but adds the observed statistic to the result as item - \code{"observed"}. The observed statistic is also put among the - permuted values so that the results are consistent with significance - tests. The \code{plot} method is similar to the default - \code{\link{plot.density}}, but can also add the observed statistic to - the graph as a vertical line. The \code{densityplot} function is - based on the same function in the \pkg{lattice} package (see - \code{\link[lattice]{densityplot}}). - - The density methods are available for \pkg{vegan} functions - \code{\link{adonis}}, \code{\link{anosim}}, \code{\link{mantel}}, - \code{\link{mantel.partial}}, \code{\link{mrpp}}, - \code{\link{permutest.cca}}, and \code{\link{protest}}. The - \code{density} function for \code{\link{oecosimu}} is documented - separately, and it is also used for \code{\link{adipart}}, - \code{\link{hiersimu}} and \code{\link{multipart}}. - - All \pkg{vegan} \code{density} functions return an object of class - \code{"vegandensity"} inheriting from \code{\link{density}}, and can - be plotted with its \code{plot} method. This is identical to the - standard \code{plot} of \code{densiy} objects, but can also add a - vertical line for the observed statistic. - - Functions that can return several permuted statistics simultaneously - also have \code{\link[lattice]{densityplot}} method - (\code{\link{adonis}}, \code{\link{oecosimu}} and diversity - partitioning functions based on \code{oecosimu}). The standard - \code{\link{density}} can only handle univariate data, and a warning - is issued if the function is used for a model with several observed - statistics. The \code{\link[lattice]{densityplot}} method is available - for \code{\link{adonis}} and \code{\link{oecosimu}} (documented - separately). NB, there is no \code{density} method for - \code{\link{anova.cca}}, but only for \code{\link{permutest.cca}}. - -} - -\value{ - The \code{density} function returns the standard \code{\link{density}} - result object with one new item: \code{"observed"} for the observed - value of the statistic. The functions have a specific \code{plot} - method, but otherwise they use methods for - \code{\link{density.default}}, such as \code{print} and \code{lines}. -} - -\author{ - Jari Oksanen -} - -\seealso{ - \code{\link{density.default}}. -} - -\examples{ -data(dune) -data(dune.env) -mod <- adonis(dune ~ Management, data = dune.env) -plot(density(mod)) -mod <- adonis(dune ~ Management * Moisture, dune.env) -densityplot(mod) -} - -\keyword{ distribution } -\keyword{ smooth } Modified: pkg/vegan/man/mantel.Rd =================================================================== --- pkg/vegan/man/mantel.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/mantel.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -70,7 +70,7 @@ \item{statistic}{The Mantel statistic.} \item{signif}{Empirical significance level from permutations.} \item{perm}{A vector of permuted values. The distribution of - permuted values can be inspected with \code{\link{density.mantel}} + permuted values can be inspected with \code{\link{permustats}} function.} \item{permutations}{Number of permutations.} \item{control}{A list of control values for the permutations Modified: pkg/vegan/man/mrpp.Rd =================================================================== --- pkg/vegan/man/mrpp.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/mrpp.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -146,7 +146,7 @@ \item{weight.type}{The choice of group weights used.} \item{boot.deltas}{The vector of "permuted deltas," the deltas calculated from each of the permuted datasets. The distribution of - this item can be inspected with \code{\link{density.mrpp}} function.} + this item can be inspected with \code{\link{permustats}} function.} \item{permutations}{The number of permutations used.} \item{control}{A list of control values for the permutations as returned by the function \code{\link[permute]{how}}.} Modified: pkg/vegan/man/oecosimu.Rd =================================================================== --- pkg/vegan/man/oecosimu.Rd 2014-09-24 08:53:17 UTC (rev 2888) +++ pkg/vegan/man/oecosimu.Rd 2014-09-30 07:24:02 UTC (rev 2889) @@ -3,8 +3,6 @@ \alias{oecosimu} \alias{as.ts.oecosimu} \alias{as.mcmc.oecosimu} -\alias{density.oecosimu} -\alias{densityplot.oecosimu} \title{Evaluate Statistics with Null Models of Biological Communities } @@ -32,8 +30,6 @@ batchsize = NA, parallel = getOption("mc.cores"), ...) \method{as.ts}{oecosimu}(x, ...) \method{as.mcmc}{oecosimu}(x) -\method{density}{oecosimu}(x, ...) -\method{densityplot}{oecosimu}(x, data, xlab = "Simulated", ...) } \arguments{ @@ -88,8 +84,7 @@ cluster before the call. See \code{\link{vegandocs}} \code{decision-vegan} for details. } \item{x}{An \code{oecosimu} result object.} - \item{data}{Ignored argument of the generic function.} - \item{xlab}{Label of the x-axis.} + \item{\dots}{Other arguments to functions.} } @@ -167,18 +162,10 @@ methods, and summary of the results. Please consult the documentation of the \pkg{coda} package. - Function \code{density} provides an interface to the - standard \code{\link{density}} function for the simulated - values. Function \code{densityplot} is an interface to the - \code{\link[lattice]{densityplot}} function of the \pkg{lattice} - package. The \code{density} can be used meaningfully only for single - statistics and must be plotted separately. The \code{densityplot} - function can handle multiple statistics, and it plots the results - directly. In addition to the density, the \code{densityplot} also - shows the observed value of the statistic (provided it is within the - graph limits). The \code{densityplot} function is defined as a - generic function in the \pkg{lattice} package and you must either - load the \pkg{lattice} library before calling \code{densityplot}. + Function \code{\link{permustats}} provides support to the standard [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2889