From noreply at r-forge.r-project.org Sun Dec 1 00:32:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 00:32:45 +0100 (CET) Subject: [Vegan-commits] r2785 - in pkg/permute: R inst man tests/Examples Message-ID: <20131130233245.EF41A184F56@r-forge.r-project.org> Author: gsimpson Date: 2013-12-01 00:32:45 +0100 (Sun, 01 Dec 2013) New Revision: 2785 Modified: pkg/permute/R/numPerms.R pkg/permute/inst/ChangeLog pkg/permute/inst/TODO.md pkg/permute/man/shuffleSet.Rd pkg/permute/tests/Examples/permute-Ex.Rout.save Log: fix a bug in 'numPerms' which was ignoring the 'constant' setting when there were plots and within plot, samples ere freely permuted. Modified: pkg/permute/R/numPerms.R =================================================================== --- pkg/permute/R/numPerms.R 2013-11-30 22:17:01 UTC (rev 2784) +++ pkg/permute/R/numPerms.R 2013-11-30 23:32:45 UTC (rev 2785) @@ -131,7 +131,11 @@ 1 } else if(isTRUE(all.equal(typeW, "free"))) { if(!is.null(PSTRATA)) { - prod(factorial(tab)) + if(constantW) { + factorial(tab[1]) + } else { + prod(factorial(tab)) + } } else { exp(lfactorial(n)) } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-30 22:17:01 UTC (rev 2784) +++ pkg/permute/inst/ChangeLog 2013-11-30 23:32:45 UTC (rev 2785) @@ -17,6 +17,9 @@ * allPerms: fix a bug where the blocks of permutations were being recombined in the wrong way, by rows instead of by columns. + * numPerms: was ignoring the `constant` setting if free permutations + within level of plots. + Version 0.7-8 * how, Plots: enforces that `blocks` and `strata` are factors, or Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-30 22:17:01 UTC (rev 2784) +++ pkg/permute/inst/TODO.md 2013-11-30 23:32:45 UTC (rev 2785) @@ -47,7 +47,7 @@ a `call` component and hence can be `update()`ed, hence the nested calls to `update()`. - * `permControl` - deprecate this in favour of `how` as in "how to + * `permControl` - deprecate this in favour of `how` as in "how to permute"? *DONE Completed in 0.7-4* * `permuplot` - this may be fundamentally bust - it only worked in the @@ -75,6 +75,10 @@ within = Within(type = "free", constant = TRUE)) shuffleSet(20, 10, CTRL) + *DONE in 0.8-0* + * Write an Rd page for the `"permutationMatrix"` S3 class where I can describe the object returned by `shuffleSet()` and the methods available for it. + + *DONE in 0.7-8* \ No newline at end of file Modified: pkg/permute/man/shuffleSet.Rd =================================================================== --- pkg/permute/man/shuffleSet.Rd 2013-11-30 22:17:01 UTC (rev 2784) +++ pkg/permute/man/shuffleSet.Rd 2013-11-30 23:32:45 UTC (rev 2785) @@ -112,10 +112,12 @@ plotStrata <- Plots(strata = gl(4,5)) CTRL <- how(plots = plotStrata, within = Within(type = "free")) +numPerms(20, control = CTRL) shuffleSet(20, 10, control = CTRL) ## as above but same random permutation within Plot-level strata CTRL <- how(plots = plotStrata, within = Within(type = "free", constant = TRUE)) +numPerms(20, control = CTRL) shuffleSet(20, 10, CTRL) ## check this. ## time series within each level of Plot strata Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 22:17:01 UTC (rev 2784) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 23:32:45 UTC (rev 2785) @@ -1086,6 +1086,8 @@ > plotStrata <- Plots(strata = gl(4,5)) > CTRL <- how(plots = plotStrata, + within = Within(type = "free")) +> numPerms(20, control = CTRL) +[1] 207360000 > shuffleSet(20, 10, control = CTRL) No. of Permutations: 10 No. of Samples: 20 (Nested in: plots; Randomised) @@ -1116,6 +1118,8 @@ > ## as above but same random permutation within Plot-level strata > CTRL <- how(plots = plotStrata, + within = Within(type = "free", constant = TRUE)) +> numPerms(20, control = CTRL) +[1] 120 > shuffleSet(20, 10, CTRL) ## check this. No. of Permutations: 10 No. of Samples: 20 (Nested in: plots; Randomised; same permutation in @@ -1203,7 +1207,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 2.227 0.035 2.282 0 0 +Time elapsed: 2.288 0.038 2.347 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sun Dec 1 16:57:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 16:57:50 +0100 (CET) Subject: [Vegan-commits] r2786 - pkg/vegan/R Message-ID: <20131201155750.E283E185C8C@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 16:57:50 +0100 (Sun, 01 Dec 2013) New Revision: 2786 Added: pkg/vegan/R/howHead.R Modified: pkg/vegan/R/anovacca.R Log: anovacca got header from the how object Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-30 23:32:45 UTC (rev 2785) +++ pkg/vegan/R/anovacca.R 2013-12-01 15:57:50 UTC (rev 2786) @@ -79,11 +79,9 @@ 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 = "") + head <- paste0("Permutation test for ", tst$method, " under ", + tst$model, " model\n", howHead(control), + "Number of permutations: ", tst$nperm, "\n") mod <- paste("Model:", c(object$call)) structure(table, heading = c(head, mod), Random.seed = seed, control = control, Added: pkg/vegan/R/howHead.R =================================================================== --- pkg/vegan/R/howHead.R (rev 0) +++ pkg/vegan/R/howHead.R 2013-12-01 15:57:50 UTC (rev 2786) @@ -0,0 +1,51 @@ +### Make a compact summary of permutations. This copies Gav Simpson's +### permute:::print.how, but only displays non-default choices in how(). +`howHead` <- function(x, ...) +{ + ## this should always work + if (is.null(x) || !inherits(x, "how")) + stop("not a 'how' object: contact the package maintainer") + ## collect header + head <- NULL + ## blocks + if (!is.null(getBlocks(x))) + head <- paste0(head, paste("Blocks: ", x$blocks.name, "\n")) + ## plots + plotStr <- getStrata(x, which = "plots") + if (!is.null(plotStr)) { + plots <- getPlots(x) + ptype <- getType(x, which = "plots") + head <- paste0(head, paste0("Plots: ", plots$plots.name, ", ")) + head <- paste0(head, paste("plot permutation:", ptype)) + if(getMirror(x, which = "plots") == "Yes") + head <- paste(head, "mirrored") + if (isTRUE(all.equal(ptype, "grid"))) { + nr <- getRow(x, which = "plots") + nc <- getCol(x, which = "plots") + head <- paste0(head, sprintf(ngettext(nr, " %d row", " %d rows"), + nr)) + head <- paste0(head, sprintf(ngettext(nc, " %d column", + " %d columns"), nc)) + } + head <- paste0(head, "\n") + } + ## the fine level (within plots if any) + type <- getType(x, which = "within") + head <- paste0(head, "Permutation: ", type) + if (isTRUE(type %in% c("series", "grid"))) { + if(getMirror(x, which = "within") == "Yes") + head <- paste(head, "mirrored") + if(getConstant(x) == "Yes") + head <- paste0(head, " constant permutation within each Plot") + } + if (isTRUE(all.equal(type, "grid"))) { + nr <- getRow(x, which = "plots") + nc <- getCol(x, which = "plots") + head <- paste0(head, sprintf(ngettext(nr, " %d row", " %d rows"), + nr)) + head <- paste0(head, sprintf(ngettext(nc, " %d column", + " %d columns"), nc)) + } + head <- paste0(head, "\n") + head +} From noreply at r-forge.r-project.org Sun Dec 1 17:07:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 17:07:19 +0100 (CET) Subject: [Vegan-commits] r2787 - in pkg/permute: . R inst Message-ID: <20131201160719.DD16D185C8C@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 17:07:19 +0100 (Sun, 01 Dec 2013) New Revision: 2787 Modified: pkg/permute/DESCRIPTION pkg/permute/R/setFoo-methods.R pkg/permute/inst/ChangeLog Log: deparse substitute block name before evaluating block and destroying its name Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-12-01 15:57:50 UTC (rev 2786) +++ pkg/permute/DESCRIPTION 2013-12-01 16:07:19 UTC (rev 2787) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.8-0 +Version: 0.8-1 Date: $Date$ Authors at R: c(person(given = "Gavin L.", family = "Simpson", email = "ucfagls at gmail.com", Modified: pkg/permute/R/setFoo-methods.R =================================================================== --- pkg/permute/R/setFoo-methods.R 2013-12-01 15:57:50 UTC (rev 2786) +++ pkg/permute/R/setFoo-methods.R 2013-12-01 16:07:19 UTC (rev 2787) @@ -143,8 +143,8 @@ `setBlocks<-.how` <- function(object, value) { if (!is.null(value)) value <- as.factor(value) + object[["blocks.name"]] <- deparse(substitute(value)) object["blocks"] <- list(value) - object[["blocks.name"]] <- deparse(substitute(value)) object <- fixupCall(object, "blocks", value) object } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-12-01 15:57:50 UTC (rev 2786) +++ pkg/permute/inst/ChangeLog 2013-12-01 16:07:19 UTC (rev 2787) @@ -2,6 +2,12 @@ permute ChangeLog +Version 0.8-1 + + * setBlocks<-: the name of the block must be collected with + deparse(substitute()) before it is evaluated with list() or its + name will be lost. + Version 0.8-0 * Released to CRAN From noreply at r-forge.r-project.org Sun Dec 1 17:26:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 17:26:11 +0100 (CET) Subject: [Vegan-commits] r2788 - pkg/vegan/R Message-ID: <20131201162611.D49AC186B21@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 17:26:11 +0100 (Sun, 01 Dec 2013) New Revision: 2788 Modified: pkg/vegan/R/anovacca.byterm.R Log: anovacca by= methods got headers Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:07:19 UTC (rev 2787) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:26:11 UTC (rev 2788) @@ -33,6 +33,11 @@ c(sol[-1,6], NA)) colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") + head <- paste0("Permutation test for ", object$method, " under ", + model, " model\n", + "Terms added sequentially (first to last)") + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) class(out) <- c("anova","data.frame") out } @@ -83,6 +88,11 @@ c(Fstat, NA), c(Pval, NA)) colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") + head <- paste0("Permutation test for ", object$method, " under ", + mods[[1]]$model, " model\n", + "Marginal effects of terms") + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) class(out) <- c("anova", "data.frame") out } @@ -135,6 +145,11 @@ c(Fstat, NA), c(Pvals,NA)) rownames(out) <- c(names(eig), "Residual") colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + head <- paste0("Permutation test for ", object$method, " under ", + model, " model\n", + "Marginal tests for axes") + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) class(out) <- c("anova", "data.frame") out } From noreply at r-forge.r-project.org Sun Dec 1 17:34:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 17:34:07 +0100 (CET) Subject: [Vegan-commits] r2789 - in pkg/vegan: R man Message-ID: <20131201163407.89F93186B21@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 17:34:07 +0100 (Sun, 01 Dec 2013) New Revision: 2789 Modified: pkg/vegan/R/anovacca.R pkg/vegan/R/anovacca.byterm.R pkg/vegan/man/anovacca.Rd Log: anovacca(..., by='axis') gained 'cutoff' argument Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-12-01 16:26:11 UTC (rev 2788) +++ pkg/vegan/R/anovacca.R 2013-12-01 16:34:07 UTC (rev 2789) @@ -1,7 +1,8 @@ `anovacca` <- function(object, ..., permutations = how(nperm=999), by = NULL, model = c("reduced", "direct", "full"), - parallel = getOption("mc.cores"), strata = NULL) + parallel = getOption("mc.cores"), strata = NULL, + cutoff = 1) { model <- match.arg(model) ## permutations is either a single number, a how() structure or a @@ -64,7 +65,8 @@ model = model, parallel = parallel), "axis" = anovacca.byaxis(object, permutations = permutations, - model = model, parallel = parallel)) + model = model, parallel = parallel, + cutoff = cutoff)) attr(sol, "Random.seed") <- seed attr(sol, "control") <- control return(sol) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:26:11 UTC (rev 2788) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:34:07 UTC (rev 2789) @@ -100,7 +100,7 @@ ### Marginal test for axes `anovacca.byaxis` <- - function(object, permutations, model, parallel) + function(object, permutations, model, parallel, cutoff = 1) { nperm <- nrow(permutations) ## Observed F-values and Df @@ -124,7 +124,7 @@ } LC <- as.data.frame(LC) fla <- reformulate(names(LC)) - Pvals <- numeric(length(eig)) + Pvals <- rep(NA, length(eig)) environment(object$terms) <- environment() for (i in 1:length(eig)) { part <- paste("~ . +Condition(", @@ -140,6 +140,8 @@ permutations, model = model, parallel = parallel) Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) + if (Pvals[i] > cutoff) + break } out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), c(Fstat, NA), c(Pvals,NA)) Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-12-01 16:26:11 UTC (rev 2788) +++ pkg/vegan/man/anovacca.Rd 2013-12-01 16:34:07 UTC (rev 2789) @@ -24,7 +24,8 @@ \usage{ anovacca(object, ..., permutations = how(nperm=999), by = NULL, model = c("reduced", "direct", "full"), - parallel = getOption("mc.cores"), strata = NULL) + parallel = getOption("mc.cores"), strata = NULL, + cutoff = 1) } \arguments{ @@ -59,6 +60,9 @@ deprecated in the future: use \code{permutations = how(\dots, blocks)} instead. } + \item{cutoff}{Only effective with \code{by="axis"} where stops + permutations after an axis exceeds the \code{cutoff}.} + \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 From noreply at r-forge.r-project.org Sun Dec 1 17:44:31 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 17:44:31 +0100 (CET) Subject: [Vegan-commits] r2790 - in pkg/vegan: R man Message-ID: <20131201164431.18449186B21@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 17:44:30 +0100 (Sun, 01 Dec 2013) New Revision: 2790 Modified: pkg/vegan/R/anovacca.R pkg/vegan/R/anovacca.byterm.R pkg/vegan/man/anovacca.Rd Log: anovacca(..., by='margin' gained 'scope' Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-12-01 16:34:07 UTC (rev 2789) +++ pkg/vegan/R/anovacca.R 2013-12-01 16:44:30 UTC (rev 2790) @@ -2,7 +2,7 @@ function(object, ..., permutations = how(nperm=999), by = NULL, model = c("reduced", "direct", "full"), parallel = getOption("mc.cores"), strata = NULL, - cutoff = 1) + cutoff = 1, scope = NULL) { model <- match.arg(model) ## permutations is either a single number, a how() structure or a @@ -62,7 +62,8 @@ model = model, parallel = parallel), "margin" = anovacca.bymargin(object, permutations = permutations, - model = model, parallel = parallel), + model = model, parallel = parallel, + scope = scope), "axis" = anovacca.byaxis(object, permutations = permutations, model = model, parallel = parallel, Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:34:07 UTC (rev 2789) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 16:44:30 UTC (rev 2790) @@ -46,14 +46,17 @@ ## term in turn and compare against the complete model. `anovacca.bymargin` <- - function(object, permutations, ...) + function(object, permutations, scope, ...) { nperm <- nrow(permutations) ## Refuse to handle models with missing data if (!is.null(object$na.action)) stop("by = 'margin' models cannot handle missing data") ## We need term labels but without Condition() terms - trms <- drop.scope(object) + if (!is.null(scope) && is.character(scope)) + trms <- scope + else + trms <- drop.scope(object) trmlab <- trms[trms %in% attr(terms(object$terminfo), "term.labels")] ## baseline: all terms Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-12-01 16:34:07 UTC (rev 2789) +++ pkg/vegan/man/anovacca.Rd 2013-12-01 16:44:30 UTC (rev 2790) @@ -25,7 +25,7 @@ anovacca(object, ..., permutations = how(nperm=999), by = NULL, model = c("reduced", "direct", "full"), parallel = getOption("mc.cores"), strata = NULL, - cutoff = 1) + cutoff = 1, scope = NULL) } \arguments{ @@ -63,6 +63,10 @@ \item{cutoff}{Only effective with \code{by="axis"} where stops permutations after an axis exceeds the \code{cutoff}.} + \item{scope}{Only effective with \code{by="margin"} where it can be + used to select the marginal terms for testing. The default is to + test all marginal terms in \code{\link{drop.scope}}.} + \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 From noreply at r-forge.r-project.org Sun Dec 1 18:07:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 18:07:03 +0100 (CET) Subject: [Vegan-commits] r2791 - pkg/vegan/R Message-ID: <20131201170703.B7FD1186229@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 18:07:03 +0100 (Sun, 01 Dec 2013) New Revision: 2791 Modified: pkg/vegan/R/anovacca.R pkg/vegan/R/howHead.R Log: howHead returns no. of permutations, and we use that in anova display instead of N.perm column Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-12-01 16:44:30 UTC (rev 2790) +++ pkg/vegan/R/anovacca.R 2013-12-01 17:07:03 UTC (rev 2791) @@ -77,14 +77,12 @@ Fval <- c(tst$F.0, NA) Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) Pval <- c(Pval, NA) - nperm <- c(tst$nperm, NA) - table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval) + table <- data.frame(tst$df, tst$chi, Fval, Pval) is.rda <- inherits(object, "rda") colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"), - "F", "N.Perm", "Pr(>F)") + "F", "Pr(>F)") head <- paste0("Permutation test for ", tst$method, " under ", - tst$model, " model\n", howHead(control), - "Number of permutations: ", tst$nperm, "\n") + tst$model, " model\n", howHead(control)) mod <- paste("Model:", c(object$call)) structure(table, heading = c(head, mod), Random.seed = seed, control = control, Modified: pkg/vegan/R/howHead.R =================================================================== --- pkg/vegan/R/howHead.R 2013-12-01 16:44:30 UTC (rev 2790) +++ pkg/vegan/R/howHead.R 2013-12-01 17:07:03 UTC (rev 2791) @@ -46,6 +46,6 @@ head <- paste0(head, sprintf(ngettext(nc, " %d column", " %d columns"), nc)) } - head <- paste0(head, "\n") + head <- paste0(head, "\nNumber of permutations: ", getNperm(x), "\n") head } From noreply at r-forge.r-project.org Sun Dec 1 18:17:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Dec 2013 18:17:05 +0100 (CET) Subject: [Vegan-commits] r2792 - pkg/vegan/R Message-ID: <20131201171705.8F922184475@r-forge.r-project.org> Author: jarioksa Date: 2013-12-01 18:17:05 +0100 (Sun, 01 Dec 2013) New Revision: 2792 Modified: pkg/vegan/R/anovacca.byterm.R Log: anovacca(..., by=...) cases use howHead Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:07:03 UTC (rev 2791) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:17:05 UTC (rev 2792) @@ -35,7 +35,8 @@ rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", - "Terms added sequentially (first to last)") + "Terms added sequentially (first to last)\n", + howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) class(out) <- c("anova","data.frame") @@ -93,7 +94,8 @@ rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", mods[[1]]$model, " model\n", - "Marginal effects of terms") + "Marginal effects of terms\n", + howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) class(out) <- c("anova", "data.frame") @@ -152,7 +154,8 @@ colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", - "Marginal tests for axes") + "Marginal tests for axes\n", + howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) class(out) <- c("anova", "data.frame") From noreply at r-forge.r-project.org Mon Dec 2 14:38:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Dec 2013 14:38:25 +0100 (CET) Subject: [Vegan-commits] r2793 - pkg/vegan/R Message-ID: <20131202133825.ABF5E185979@r-forge.r-project.org> Author: jarioksa Date: 2013-12-02 14:38:24 +0100 (Mon, 02 Dec 2013) New Revision: 2793 Modified: pkg/vegan/R/anovacca.byterm.R Log: anovacca(..., by='axis', scope=) handles empty scopes (like wrong names in scope) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-01 17:17:05 UTC (rev 2792) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-02 13:38:24 UTC (rev 2793) @@ -60,6 +60,8 @@ trms <- drop.scope(object) trmlab <- trms[trms %in% attr(terms(object$terminfo), "term.labels")] + if(length(trmlab) == 0) + stop("the scope was empty: no available marginal terms") ## baseline: all terms big <- permutest(object, permutations, ...) dfbig <- big$df[2] From noreply at r-forge.r-project.org Mon Dec 2 18:47:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 2 Dec 2013 18:47:14 +0100 (CET) Subject: [Vegan-commits] r2794 - in pkg/permute: . R inst Message-ID: <20131202174714.963611852AE@r-forge.r-project.org> Author: jarioksa Date: 2013-12-02 18:47:14 +0100 (Mon, 02 Dec 2013) New Revision: 2794 Modified: pkg/permute/DESCRIPTION pkg/permute/R/setFoo-methods.R pkg/permute/inst/ChangeLog Log: revert r2787: did not work Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-12-02 13:38:24 UTC (rev 2793) +++ pkg/permute/DESCRIPTION 2013-12-02 17:47:14 UTC (rev 2794) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.8-1 +Version: 0.8-0 Date: $Date$ Authors at R: c(person(given = "Gavin L.", family = "Simpson", email = "ucfagls at gmail.com", Modified: pkg/permute/R/setFoo-methods.R =================================================================== --- pkg/permute/R/setFoo-methods.R 2013-12-02 13:38:24 UTC (rev 2793) +++ pkg/permute/R/setFoo-methods.R 2013-12-02 17:47:14 UTC (rev 2794) @@ -143,8 +143,8 @@ `setBlocks<-.how` <- function(object, value) { if (!is.null(value)) value <- as.factor(value) + object["blocks"] <- list(value) object[["blocks.name"]] <- deparse(substitute(value)) - object["blocks"] <- list(value) object <- fixupCall(object, "blocks", value) object } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-12-02 13:38:24 UTC (rev 2793) +++ pkg/permute/inst/ChangeLog 2013-12-02 17:47:14 UTC (rev 2794) @@ -2,12 +2,6 @@ permute ChangeLog -Version 0.8-1 - - * setBlocks<-: the name of the block must be collected with - deparse(substitute()) before it is evaluated with list() or its - name will be lost. - Version 0.8-0 * Released to CRAN From noreply at r-forge.r-project.org Tue Dec 3 16:39:15 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 16:39:15 +0100 (CET) Subject: [Vegan-commits] r2795 - pkg/vegan/R Message-ID: <20131203153915.1A169185F5E@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 16:39:14 +0100 (Tue, 03 Dec 2013) New Revision: 2795 Modified: pkg/vegan/R/print.permutest.cca.R Log: print.permutest.cca uses howHead Modified: pkg/vegan/R/print.permutest.cca.R =================================================================== --- pkg/vegan/R/print.permutest.cca.R 2013-12-02 17:47:14 UTC (rev 2794) +++ pkg/vegan/R/print.permutest.cca.R 2013-12-03 15:39:14 UTC (rev 2795) @@ -1,7 +1,8 @@ -"print.permutest.cca" <- +`print.permutest.cca` <- function (x, ...) { cat("\nPermutation test for", x$method, "\n\n") + cat(howHead(x$control), "\n") writeLines(strwrap(pasteCall(x$testcall))) Pval <- (sum(x$F.perm >= x$F.0) + 1)/(x$nperm + 1) cat("Permutation test for ") @@ -12,10 +13,6 @@ cat("Pseudo-F:\t", x$F.0, "(with", paste(x$df, collapse = ", "), "Degrees of Freedom)\n") cat("Significance:\t", format.pval(Pval), - "\n") - cat("Based on", x$nperm, "permutations under", x$model, "model") - if (!is.null(x$strata)) - cat(",\nstratified within factor", x$strata) - cat(".\n\n") + "\n\n") invisible(x) } From noreply at r-forge.r-project.org Tue Dec 3 17:02:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 17:02:58 +0100 (CET) Subject: [Vegan-commits] r2796 - pkg/vegan/R Message-ID: <20131203160258.6780E185ABA@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 17:02:58 +0100 (Tue, 03 Dec 2013) New Revision: 2796 Modified: pkg/vegan/R/anova.ccalist.R pkg/vegan/R/anovacca.R pkg/vegan/R/anovacca.byterm.R Log: adopt column header Variance/ChiSquare to ordination method Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2013-12-03 15:39:14 UTC (rev 2795) +++ pkg/vegan/R/anova.ccalist.R 2013-12-03 16:02:58 UTC (rev 2796) @@ -72,13 +72,18 @@ ## collect table table <- data.frame(resdf, resdev, c(NA, df), c(NA,changedev), c(NA,fval), c(NA,pval)) - dimnames(table) <- list(1L:nmodels, c("Resid. Df", "Res. Chisq", - "Df", "Chisq", "F", "Pr(>F)")) + isRDA <- method != "cca" + dimnames(table) <- list(1L:nmodels, + c("Res.Df", + ifelse(isRDA,"Res.Variance", "Res.ChiSquare"), + "Df", + ifelse(isRDA,"Variance","ChiSquare"), + "F", "Pr(>F)")) ## Collect header information formulae <- sapply(object, function(z) deparse(formula(z))) head <- paste0("Permutation tests for ", method, " under ", - mods[[big]]$model, " model\nwith ", nperm, - " permutations\n") + mods[[big]]$model, " model\n", + howHead(attr(permutations, "control"))) topnote <- paste("Model ", format(1L:nmodels), ": ", formulae, sep = "", collapse = "\n") structure(table, heading=c(head,topnote), class = c("anova", "data.frame")) Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-12-03 15:39:14 UTC (rev 2795) +++ pkg/vegan/R/anovacca.R 2013-12-03 16:02:58 UTC (rev 2796) @@ -79,7 +79,7 @@ Pval <- c(Pval, NA) table <- data.frame(tst$df, tst$chi, Fval, Pval) is.rda <- inherits(object, "rda") - colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"), + colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"), "F", "Pr(>F)") head <- paste0("Permutation test for ", tst$method, " under ", tst$model, " model\n", howHead(control)) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-03 15:39:14 UTC (rev 2795) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-03 16:02:58 UTC (rev 2796) @@ -31,7 +31,9 @@ c(sol[-1,4], sol[ntrm+1,2]), c(sol[-1,5], NA), c(sol[-1,6], NA)) - colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", @@ -92,7 +94,9 @@ ## Collect results to anova data.frame out <- data.frame(c(Df, dfbig), c(Chisq, chibig), c(Fstat, NA), c(Pval, NA)) - colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") rownames(out) <- c(trmlab, "Residual") head <- paste0("Permutation test for ", object$method, " under ", mods[[1]]$model, " model\n", @@ -153,7 +157,9 @@ out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), c(Fstat, NA), c(Pvals,NA)) rownames(out) <- c(names(eig), "Residual") - colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") head <- paste0("Permutation test for ", object$method, " under ", model, " model\n", "Marginal tests for axes\n", From noreply at r-forge.r-project.org Tue Dec 3 17:12:16 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 17:12:16 +0100 (CET) Subject: [Vegan-commits] r2797 - pkg/vegan/R Message-ID: <20131203161216.E6174185122@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 17:12:16 +0100 (Tue, 03 Dec 2013) New Revision: 2797 Modified: pkg/vegan/R/permutest.cca.R Log: disable 'full' model in permutest.cca: no code removal Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-12-03 16:02:58 UTC (rev 2796) +++ pkg/vegan/R/permutest.cca.R 2013-12-03 16:12:16 UTC (rev 2797) @@ -6,7 +6,7 @@ `permutest.cca` <- function (x, permutations = how(nperm=99), - model = c("reduced", "direct", "full"), first = FALSE, + model = c("reduced", "direct"), first = FALSE, strata = NULL, parallel = getOption("mc.cores") , ...) { ## do something sensible with insensible input (no constraints) From noreply at r-forge.r-project.org Tue Dec 3 17:37:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 17:37:33 +0100 (CET) Subject: [Vegan-commits] r2798 - pkg/vegan/man Message-ID: <20131203163733.58D63185ABA@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 17:37:33 +0100 (Tue, 03 Dec 2013) New Revision: 2798 Modified: pkg/vegan/man/anova.cca.Rd pkg/vegan/man/anovacca.Rd Log: prepare documentation for switching from old to new anova.cca Modified: pkg/vegan/man/anova.cca.Rd =================================================================== --- pkg/vegan/man/anova.cca.Rd 2013-12-03 16:12:16 UTC (rev 2797) +++ pkg/vegan/man/anova.cca.Rd 2013-12-03 16:37:33 UTC (rev 2798) @@ -5,32 +5,19 @@ \alias{anova.ccabyterm} \alias{anova.ccabymargin} \alias{anova.prc} -\alias{permutest} -\alias{permutest.default} -\alias{permutest.cca} \title{Permutation Test for Constrained Correspondence Analysis, Redundancy Analysis and Constrained Analysis of Principal Coordinates } \description{ - The function performs an ANOVA like permutation test for Constrained - Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis - (\code{\link{rda}}) or distance-based Redundancy Analysis - (dbRDA, \code{\link{capscale}}) to assess the significance of constraints. + This function is deprecated. } \usage{ \method{anova}{cca}(object, alpha=0.05, beta=0.01, step=100, perm.max=9999, by = NULL, ...) - -permutest(x, ...) - -\method{permutest}{cca}(x, permutations = how(nperm=99), - model = c("reduced", "direct", "full"), - first = FALSE, strata = NULL, - parallel = getOption("mc.cores") , ...) } \arguments{ - \item{object,x}{A result object from \code{\link{cca}}. } + \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. } @@ -46,124 +33,37 @@ \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. } - - \item{permutations}{Either a \code{\link[permute]{how}} result - defining permutations, or a permutation matrix with each row giving - the permutation indices, or the number of permutations for simple - permutations. See \code{\link{permutations}} for details.} - - \item{model}{Permutation model (partial match).} - \item{first}{Assess only the significance of the first constrained - eigenvalue; will be passed from \code{anova.cca}. } - - \item{strata}{An integer vector or factor specifying the strata for - permutation. If supplied, observations are permuted only within the - specified strata. It is an error to use this when - \code{permutations} is a matrix, or a \code{\link[permute]{how}} - defines \code{blocks}. This is a legacy argument that will be - deprecated in the future: use \code{permutations = how(\dots, blocks)} - instead. } - - \item{parallel}{Number of parallel processes or a predefined socket - cluster. With \code{parallel = 1} uses ordinary, non-parallel - processing. The parallel processing is done with \pkg{parallel} - package which is available only for \R 2.14.0 and later.} - } \details{ - Functions \code{anova.cca} and \code{permutest.cca} implement an ANOVA - like permutation test for the joint effect of constraints in - \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}. - Functions \code{anova.cca} and \code{permutest.cca} differ in printout - style and in interface. - Function \code{permutest.cca} is the proper workhorse, but - \code{anova.cca} passes all parameters to \code{permutest.cca}. - - The default test is for the sum of all constrained eigenvalues. - Setting \code{first = TRUE} will perform a test for the first - constrained eigenvalue. Argument \code{first} can be set either in - \code{anova.cca} or in \code{permutest.cca}. It is also possible to - perform significance tests for each axis or for each term - (constraining variable) using argument \code{by} in - \code{anova.cca}. Setting \code{by = "axis"} will perform separate - significance tests for each constrained axis. All previous - constrained axes will be used as conditions (\dQuote{partialled - out}) and a test for the first constrained eigenvalues is - performed (Legendre et al. 2011). - You can stop permutation tests after exceeding a given - significance level with argument \code{cutoff} to speed up - calculations in large models. Setting \code{by = "terms"} will - perform separate significance test for each term (constraining - variable). The terms are assessed sequentially from first to last, - and the order of the terms will influence their - significances. Setting \code{by = "margin"} will perform separate - significance test for each marginal term in a model with all other - terms. The marginal test also accepts a \code{scope} argument for - the \code{\link{drop.scope}} which can be a character vector of term - labels that are analysed, or a fitted model of lower scope. The - marginal effects are also known as \dQuote{Type III} effects, but - the current function only evaluates marginal terms. It will, for - instance, ignore main effects that are included in interaction - terms. In calculating pseudo-\eqn{F}, all terms are compared to the - same residual of the full model. Permutations for all axes or terms - will start from the same \code{\link{.Random.seed}}, and the seed - will be advanced to the value after the longest permutation at the - exit from the function. + This function contains a deprecated version of \code{anova.cca}. + The new 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{anova.cca} 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}. + 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}. - Community data are permuted with choice \code{model="direct"}, - residuals after partial CCA/ RDA/ dbRDA with choice \code{model="reduced"} - (default), and residuals after CCA/ RDA/ dbRDA under choice - \code{model="full"}. If there is no partial CCA/ RDA/ dbRDA stage, - \code{model="reduced"} simply permutes the data and is equivalent to - \code{model="direct"}. The test statistic is \dQuote{pseudo-\eqn{F}}, - which is the ratio of constrained and unconstrained total Inertia - (Chi-squares, variances or something similar), each divided by their - respective ranks. If there are no conditions (\dQuote{partial} - terms), the sum of all eigenvalues remains constant, so that - pseudo-\eqn{F} and eigenvalues would give equal results. In partial - CCA/ RDA/ dbRDA, the effect of conditioning variables - (\dQuote{covariables}) is removed before permutation, and these - residuals are added to the non-permuted fitted values of partial CCA - (fitted values of \code{X ~ Z}). Consequently, the total Chi-square - is not fixed, and test based on pseudo-\eqn{F} would differ from the - test based on plain eigenvalues. CCA is a weighted method, and - environmental data are re-weighted at each permutation step using - permuted weights. } -\value{ - Function \code{permutest.cca} returns an object of class - \code{"permutest.cca"}, which has its own \code{print} method. The - distribution of permuted \eqn{F} values can be inspected with - \code{\link{density.permutest.cca}} function. The function - \code{anova.cca} calls \code{permutest.cca} and fills an - \code{\link{anova}} table. -} - \note{ - Some cases of \code{anova} need access to the original data on - constraints (at least \code{by = "term"} and \code{by = "margin"}), - and they may fail if data are unavailable. - - The default permutation \code{model} changed from \code{"direct"} to - \code{"reduced"} in \pkg{vegan} version 1.15-0, and you must - explicitly set \code{model = "direct"} for compatibility with the old - version. - - Tests \code{by = "terms"} and \code{by = "margin"} are consistent - only when \code{model = "direct"}. + The function is deprecated and replaced with \code{\link{anova.cca}}. } \references{ Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd @@ -173,29 +73,8 @@ significance of canonical axes in redundancy analysis. \emph{Methods in Ecology and Evolution} 2, 269--277. } -\author{Jari Oksanen} -\seealso{\code{\link{cca}}, \code{\link{rda}}, \code{\link{capscale}} - to get something to analyse. Function \code{\link{drop1.cca}} calls - \code{anova.cca} with \code{by = "margin"}, and - \code{\link{add1.cca}} an analysis for single terms additions, which - can be used in automatic or semiautomatic model building (see - \code{\link{deviance.cca}}). } +\author{Jari Oksanen} -\examples{ -data(varespec) -data(varechem) -vare.cca <- cca(varespec ~ Al + P + K, varechem) -## overall test -anova(vare.cca) -## Test for axes -anova(vare.cca, by="axis", perm.max=500) -## Sequential test for terms -anova(vare.cca, by="terms", permu=200) -## Marginal or Type III effects -anova(vare.cca, by="margin") -## Marginal test knows 'scope' -anova(vare.cca, by = "m", scope="P") -} \keyword{ multivariate } \keyword{ htest } Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-12-03 16:12:16 UTC (rev 2797) +++ pkg/vegan/man/anovacca.Rd 2013-12-03 16:37:33 UTC (rev 2798) @@ -5,9 +5,9 @@ %\alias{anova.ccabyterm} %\alias{anova.ccabymargin} %\alias{anova.prc} -%\alias{permutest} +\alias{permutest} %\alias{permutest.default} -%\alias{permutest.cca} +\alias{permutest.cca} \title{Permutation Test for Constrained Correspondence Analysis, Redundancy Analysis and Constrained Analysis of Principal Coordinates } @@ -17,15 +17,16 @@ Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA, \code{\link{capscale}}) to assess the significance of constraints. +} - This function is still experimental and unstable, but is scheduled - to replace \code{\link{anova.cca}} in the future. } - \usage{ anovacca(object, ..., permutations = how(nperm=999), - by = NULL, model = c("reduced", "direct", "full"), - parallel = getOption("mc.cores"), strata = NULL, - cutoff = 1, scope = NULL) + by = NULL, model = c("reduced", "direct", "full"), + parallel = getOption("mc.cores"), strata = NULL, + cutoff = 1, scope = NULL) +\method{permutest}{cca}(x, permutations = how(nperm = 99), + model = c("reduced", "direct"), first = FALSE, strata = NULL, + parallel = getOption("mc.cores"), ...) } \arguments{ @@ -34,7 +35,9 @@ \code{\link{rda}} or \code{\link{capscale}}. If there are several result objects, they are compared against each other in the ordre they were supplied. For a single object, a test specified in - \code{by} or an overal test is given. } + \code{by} or an overal test is given.} + + \item{x}{A single ordination result object.} \item{permutations}{Either a \code{\link[permute]{how}} result defining permutations, or a permutation matrix with each row giving @@ -46,11 +49,14 @@ 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). Not yet implemented.} + variables)} - \item{model}{Model} + \item{model}{Permutation model: \code{model="direct"} permutes + community data, and \code{model="reduced"} permutes residuals + of the community data after Conditions (partial model).} - \item{parallel}{Parallel processing} + \item{parallel}{Use parallel processing with the given number of + cores.} \item{strata}{An integer vector or factor specifying the strata for permutation. If supplied, observations are permuted only within @@ -76,14 +82,18 @@ \details{ - Functions \code{anova.cca} and \code{permutest.cca} implement an - ANOVA like permutation test for the joint effect of constraints in + Functions \code{anova.cca} and \code{permutest.cca} implement + ANOVA like permutation tests for the joint effect of constraints in \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}. Functions \code{anova.cca} and \code{permutest.cca} differ in printout style and in interface. Function \code{permutest.cca} is the proper workhorse, but \code{anova.cca} passes all parameters to \code{permutest.cca}. + Function \code{anova} can analyse a sequence of constrained + ordination models. The analysis is based on the differences in + residual deviances in permutations of nested models. + The default test is for the sum of all constrained eigenvalues. Setting \code{first = TRUE} will perform a test for the first constrained eigenvalue. Argument \code{first} can be set either in @@ -110,15 +120,11 @@ the current function only evaluates marginal terms. It will, for instance, ignore main effects that are included in interaction terms. In calculating pseudo-\eqn{F}, all terms are compared to the - same residual of the full model. Permutations for all axes or terms - will start from the same \code{\link{.Random.seed}}, and the seed - will be advanced to the value after the longest permutation at the - exit from the function. + same residual of the full model. Community data are permuted with choice \code{model="direct"}, - residuals after partial CCA/ RDA/ dbRDA with choice - \code{model="reduced"} (default), and residuals after CCA/ RDA/ - dbRDA under choice \code{model="full"}. If there is no partial CCA/ + and residuals after partial CCA/ RDA/ dbRDA with choice + \code{model="reduced"} (default). If there is no partial CCA/ RDA/ dbRDA stage, \code{model="reduced"} simply permutes the data and is equivalent to \code{model="direct"}. The test statistic is \dQuote{pseudo-\eqn{F}}, which is the ratio of constrained and @@ -144,14 +150,6 @@ Some cases of \code{anova} need access to the original data on constraints (at least \code{by = "term"} and \code{by = "margin"}), and they may fail if data are unavailable. - - The default permutation \code{model} changed from \code{"direct"} to - \code{"reduced"} in \pkg{vegan} version 1.15-0, and you must - explicitly set \code{model = "direct"} for compatibility with the old - version. - - Tests \code{by = "terms"} and \code{by = "margin"} are consistent - only when \code{model = "direct"}. } \references{ Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd From noreply at r-forge.r-project.org Tue Dec 3 18:03:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 18:03:29 +0100 (CET) Subject: [Vegan-commits] r2799 - in pkg/vegan: . R inst man Message-ID: <20131203170329.AC5D018346D@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 18:03:28 +0100 (Tue, 03 Dec 2013) New Revision: 2799 Added: 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 Removed: pkg/vegan/R/anova.cca.R pkg/vegan/R/anova.ccabyaxis.R pkg/vegan/R/anova.ccabymargin.R pkg/vegan/R/anova.ccabyterm.R pkg/vegan/man/anova.cca.Rd Modified: pkg/vegan/DESCRIPTION pkg/vegan/inst/ChangeLog Log: first stage of replacing old anova.cca: rename old functions to ccanova* Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/DESCRIPTION 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-39 -Date: November 10, 2013 +Version: 2.1-40 +Date: December 3, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Deleted: pkg/vegan/R/anova.cca.R =================================================================== --- pkg/vegan/R/anova.cca.R 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/R/anova.cca.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,62 +0,0 @@ -`anova.cca` <- - 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 <- anova.ccabyaxis(object, alpha = alpha, beta = beta, - step = step, perm.max = perm.max, by = NULL, - ...) - else if (by == "margin") { - sol <- anova.ccabymargin(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 <- anova.ccabyterm(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/anova.ccabyaxis.R =================================================================== --- pkg/vegan/R/anova.ccabyaxis.R 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/R/anova.ccabyaxis.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,89 +0,0 @@ -`anova.ccabyaxis` <- - 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 <- anova(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(anova(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/anova.ccabymargin.R =================================================================== --- pkg/vegan/R/anova.ccabymargin.R 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/R/anova.ccabymargin.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,52 +0,0 @@ -`anova.ccabymargin` <- - function(object, step=100, scope, ...) -{ - if(inherits(object, "prc")) - stop("anova(..., 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 <- anova(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/anova.ccabyterm.R =================================================================== --- pkg/vegan/R/anova.ccabyterm.R 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/R/anova.ccabyterm.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,78 +0,0 @@ -`anova.ccabyterm` <- - 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")) -} Copied: pkg/vegan/R/ccanova.R (from rev 2796, pkg/vegan/R/anova.cca.R) =================================================================== --- pkg/vegan/R/ccanova.R (rev 0) +++ pkg/vegan/R/ccanova.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -0,0 +1,62 @@ +`anova.cca` <- + 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")) +} Copied: pkg/vegan/R/ccanova.byaxis.R (from rev 2796, pkg/vegan/R/anova.ccabyaxis.R) =================================================================== --- pkg/vegan/R/ccanova.byaxis.R (rev 0) +++ pkg/vegan/R/ccanova.byaxis.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -0,0 +1,89 @@ +`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 +} Copied: pkg/vegan/R/ccanova.bymargin.R (from rev 2796, pkg/vegan/R/anova.ccabymargin.R) =================================================================== --- pkg/vegan/R/ccanova.bymargin.R (rev 0) +++ pkg/vegan/R/ccanova.bymargin.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -0,0 +1,52 @@ +`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 +} Copied: pkg/vegan/R/ccanova.byterm.R (from rev 2796, pkg/vegan/R/anova.ccabyterm.R) =================================================================== --- pkg/vegan/R/ccanova.byterm.R (rev 0) +++ pkg/vegan/R/ccanova.byterm.R 2013-12-03 17:03:28 UTC (rev 2799) @@ -0,0 +1,78 @@ +`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")) +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/inst/ChangeLog 2013-12-03 17:03:28 UTC (rev 2799) @@ -2,7 +2,13 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-39 (opened November 10, 2013) +Version 2.1-40 (opened December 3, 2013) + + * anova.cca: start deprecation of old anova.cca and rename it to + ccanova. Vegan should fail all tests while deprecation is + incomplete and new code is not yet in use. + +Version 2.1-39 (closed December 3, 2013) * anova.cca: started to rewrite the anova.cca family of functions for permute package. At the first stage, a temporary development Deleted: pkg/vegan/man/anova.cca.Rd =================================================================== --- pkg/vegan/man/anova.cca.Rd 2013-12-03 16:37:33 UTC (rev 2798) +++ pkg/vegan/man/anova.cca.Rd 2013-12-03 17:03:28 UTC (rev 2799) @@ -1,80 +0,0 @@ -\name{anova.cca} -\alias{anova.cca} -\alias{anova.ccanull} -\alias{anova.ccabyaxis} -\alias{anova.ccabyterm} -\alias{anova.ccabymargin} -\alias{anova.prc} - -\title{Permutation Test for Constrained Correspondence Analysis, - Redundancy Analysis and Constrained Analysis of Principal Coordinates } -\description{ - This function is deprecated. -} -\usage{ -\method{anova}{cca}(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{ - - This function contains a deprecated version of \code{anova.cca}. - The new 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{anova.cca} 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. - - Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the - significance of canonical axes in redundancy analysis. - \emph{Methods in Ecology and Evolution} 2, 269--277. -} -\author{Jari Oksanen} - -\keyword{ multivariate } -\keyword{ htest } - Added: pkg/vegan/man/ccanova.Rd =================================================================== --- pkg/vegan/man/ccanova.Rd (rev 0) +++ pkg/vegan/man/ccanova.Rd 2013-12-03 17:03:28 UTC (rev 2799) @@ -0,0 +1,72 @@ +\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 } + From noreply at r-forge.r-project.org Tue Dec 3 18:13:16 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 18:13:16 +0100 (CET) Subject: [Vegan-commits] r2800 - in pkg/vegan: R inst man Message-ID: <20131203171316.8400C184724@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 18:13:16 +0100 (Tue, 03 Dec 2013) New Revision: 2800 Added: pkg/vegan/R/anova.cca.R pkg/vegan/R/anova.ccabyterm.R pkg/vegan/man/anova.cca.Rd Removed: pkg/vegan/R/anovacca.R pkg/vegan/R/anovacca.byterm.R pkg/vegan/man/anovacca.Rd Modified: pkg/vegan/inst/ChangeLog Log: second step of new anova.cca: rename anovacca to anova.cca -- expect trouble Copied: pkg/vegan/R/anova.cca.R (from rev 2796, pkg/vegan/R/anovacca.R) =================================================================== --- pkg/vegan/R/anova.cca.R (rev 0) +++ pkg/vegan/R/anova.cca.R 2013-12-03 17:13:16 UTC (rev 2800) @@ -0,0 +1,90 @@ +`anova.cca` <- + function(object, ..., permutations = how(nperm=999), by = NULL, + model = c("reduced", "direct", "full"), + parallel = getOption("mc.cores"), strata = NULL, + 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 + 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 + ## evaluate 'parallel' and 'model' here + if (length(dotargs)) { + isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) + if (any(isCCA)) { + dotargs <- dotargs[isCCA] + object <- c(list(object), dotargs) + sol <- + anova.ccalist(object, + permutations = permutations, + model = model, + parallel = parallel) + attr(sol, "Random.seed") <- seed + attr(sol, "control") <- control + return(sol) + } + } + ## We only have a single model: check if it is empty + if (is.null(object$CA) || is.null(object$CCA) || + object$CCA$rank == 0 || object$CA$rank == 0) + return(anova.ccanull(object)) + ## by cases + if (!is.null(by)) { + by <- match.arg(by, c("terms", "margin", "axis")) + sol <- switch(by, + "terms" = anova.ccabyterm(object, + permutations = permutations, + model = model, parallel = parallel), + "margin" = anova.ccabymargin(object, + permutations = permutations, + model = model, parallel = parallel, + scope = scope), + "axis" = anova.ccabyaxis(object, + permutations = permutations, + model = model, parallel = parallel, + cutoff = cutoff)) + attr(sol, "Random.seed") <- seed + attr(sol, "control") <- control + return(sol) + } + ## basic overall test + tst <- permutest.cca(object, permutations = permutations, ...) + Fval <- c(tst$F.0, NA) + Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) + Pval <- c(Pval, NA) + table <- data.frame(tst$df, tst$chi, Fval, Pval) + is.rda <- inherits(object, "rda") + colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"), + "F", "Pr(>F)") + head <- paste0("Permutation test for ", tst$method, " under ", + tst$model, " model\n", howHead(control)) + mod <- paste("Model:", c(object$call)) + structure(table, heading = c(head, mod), Random.seed = seed, + control = control, + class = c("anova.cca", "anova", "data.frame")) +} Copied: pkg/vegan/R/anova.ccabyterm.R (from rev 2796, pkg/vegan/R/anovacca.byterm.R) =================================================================== --- pkg/vegan/R/anova.ccabyterm.R (rev 0) +++ pkg/vegan/R/anova.ccabyterm.R 2013-12-03 17:13:16 UTC (rev 2800) @@ -0,0 +1,171 @@ +### Implementation of by-cases for vegan 2.2 versions of +### anova.cca. These are all internal functions that are not intended +### to be called by users in normal sessions, but they should be +### called from anova.cca (2.2). Therefore the user interface is rigid +### and input is not checked. The 'permutations' should be a +### permutation matrix. + +### by = terms builds models as a sequence of adding terms and submits +### this to anova.ccalist + +`anova.ccabyterm` <- + function(object, permutations, model, parallel) +{ + ## We need term labels but without Condition() terms + trms <- terms(object) + trmlab <- attr(trms, "term.labels") + trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), + "term.labels")] + ntrm <- length(trmlab) + m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-"))) + mods <- list(m0) + for(i in seq_along(trmlab)) { + fla <- paste(". ~ . + ", trmlab[i]) + mods[[i+1]] <- update(mods[[i]], fla) + } + ## The result + sol <- anova.ccalist(mods, permutations = permutations, + model = model, parallel = parallel) + ## Reformat + out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]), + c(sol[-1,4], sol[ntrm+1,2]), + c(sol[-1,5], NA), + c(sol[-1,6], NA)) + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") + rownames(out) <- c(trmlab, "Residual") + head <- paste0("Permutation test for ", object$method, " under ", + model, " model\n", + "Terms added sequentially (first to last)\n", + howHead(attr(permutations, "control"))) + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) + class(out) <- c("anova","data.frame") + out +} + +## by = margin: this is not a anova.ccalist case, but we omit each +## term in turn and compare against the complete model. + +`anova.ccabymargin` <- + function(object, permutations, scope, ...) +{ + nperm <- nrow(permutations) + ## Refuse to handle models with missing data + if (!is.null(object$na.action)) + stop("by = 'margin' models cannot handle missing data") + ## We need term labels but without Condition() terms + if (!is.null(scope) && is.character(scope)) + trms <- scope + else + trms <- drop.scope(object) + trmlab <- trms[trms %in% attr(terms(object$terminfo), + "term.labels")] + if(length(trmlab) == 0) + stop("the scope was empty: no available marginal terms") + ## baseline: all terms + big <- permutest(object, permutations, ...) + dfbig <- big$df[2] + chibig <- big$chi[2] + scale <- big$den/dfbig + ## Collect all marginal models. This differs from old version + ## (vegan 2.0) where other but 'nm' were partialled out within + ## Condition(). Now we only fit the model without 'nm' and compare + ## the difference against the complete model. + mods <- lapply(trmlab, function(nm, ...) + permutest(update(object, paste(".~.-", nm)), + permutations, ...), ...) + ## Chande in df + Df <- sapply(mods, function(x) x$df[2]) - dfbig + ## F of change + Chisq <- sapply(mods, function(x) x$chi[2]) - chibig + Fstat <- (Chisq/Df)/(chibig/dfbig) + ## Simulated F-values + Fval <- sapply(mods, function(x) x$num) + ## Had we an empty model we need to clone the denominator + if (length(Fval) == 1) + Fval <- matrix(Fval, nrow=nperm) + Fval <- sweep(-Fval, 1, big$num, "+") + Fval <- sweep(Fval, 2, Df, "/") + Fval <- sweep(Fval, 1, scale, "/") + ## Simulated P-values + Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1) + ## Collect results to anova data.frame + out <- data.frame(c(Df, dfbig), c(Chisq, chibig), + c(Fstat, NA), c(Pval, NA)) + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") + rownames(out) <- c(trmlab, "Residual") + head <- paste0("Permutation test for ", object$method, " under ", + mods[[1]]$model, " model\n", + "Marginal effects of terms\n", + howHead(attr(permutations, "control"))) + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) + class(out) <- c("anova", "data.frame") + out +} + +### Marginal test for axes + +`anova.ccabyaxis` <- + function(object, permutations, model, parallel, cutoff = 1) +{ + nperm <- nrow(permutations) + ## Observed F-values and Df + eig <- object$CCA$eig + resdf <- nobs(object) - length(eig) - max(object$pCCA$rank, 0) - 1 + Fstat <- eig/object$CA$tot.chi*resdf + Df <- rep(1, length(eig)) + ## Marginal P-values + LC <- object$CCA$u + ## missing values? + if (!is.null(object$na.action)) + LC <- napredict(structure(object$na.action, + class="exclude"), LC) + ## subset? + if (!is.null(object$subset)) { + tmp <- matrix(NA, nrow=length(object$subset), + ncol = ncol(LC)) + tmp[object$subset,] <- LC + LC <- tmp + object <- update(object, subset = object$subset) + } + LC <- as.data.frame(LC) + fla <- reformulate(names(LC)) + Pvals <- rep(NA, length(eig)) + environment(object$terms) <- environment() + for (i in 1:length(eig)) { + part <- paste("~ . +Condition(", + paste(names(LC)[-i], collapse = "+"), ")") + upfla <- update(fla, part) + ## only one axis, and cannot partial out? + if (length(eig) == 1) + mod <- permutest(object, permutations, model = model, + parallel = parallel) + else + mod <- + permutest(update(object, upfla, data = LC), + permutations, model = model, + parallel = parallel) + Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) + if (Pvals[i] > cutoff) + break + } + out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), + c(Fstat, NA), c(Pvals,NA)) + rownames(out) <- c(names(eig), "Residual") + isRDA <- inherits(object, "rda") + colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), + "F", "Pr(>F)") + head <- paste0("Permutation test for ", object$method, " under ", + model, " model\n", + "Marginal tests for axes\n", + howHead(attr(permutations, "control"))) + mod <- paste("Model:", c(object$call)) + attr(out, "heading") <- c(head, mod) + class(out) <- c("anova", "data.frame") + out +} Deleted: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-12-03 17:03:28 UTC (rev 2799) +++ pkg/vegan/R/anovacca.R 2013-12-03 17:13:16 UTC (rev 2800) @@ -1,90 +0,0 @@ -`anovacca` <- - function(object, ..., permutations = how(nperm=999), by = NULL, - model = c("reduced", "direct", "full"), - parallel = getOption("mc.cores"), strata = NULL, - 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 - 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 - ## evaluate 'parallel' and 'model' here - if (length(dotargs)) { - isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) - if (any(isCCA)) { - dotargs <- dotargs[isCCA] - object <- c(list(object), dotargs) - sol <- - anova.ccalist(object, - permutations = permutations, - model = model, - parallel = parallel) - attr(sol, "Random.seed") <- seed - attr(sol, "control") <- control - return(sol) - } - } - ## We only have a single model: check if it is empty - if (is.null(object$CA) || is.null(object$CCA) || - object$CCA$rank == 0 || object$CA$rank == 0) - return(anova.ccanull(object)) - ## by cases - if (!is.null(by)) { - by <- match.arg(by, c("terms", "margin", "axis")) - sol <- switch(by, - "terms" = anovacca.byterm(object, - permutations = permutations, - model = model, parallel = parallel), - "margin" = anovacca.bymargin(object, - permutations = permutations, - model = model, parallel = parallel, - scope = scope), - "axis" = anovacca.byaxis(object, - permutations = permutations, - model = model, parallel = parallel, - cutoff = cutoff)) - attr(sol, "Random.seed") <- seed - attr(sol, "control") <- control - return(sol) - } - ## basic overall test - tst <- permutest.cca(object, permutations = permutations, ...) - Fval <- c(tst$F.0, NA) - Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) - Pval <- c(Pval, NA) - table <- data.frame(tst$df, tst$chi, Fval, Pval) - is.rda <- inherits(object, "rda") - colnames(table) <- c("Df", ifelse(is.rda, "Variance", "ChiSquare"), - "F", "Pr(>F)") - head <- paste0("Permutation test for ", tst$method, " under ", - tst$model, " model\n", howHead(control)) - mod <- paste("Model:", c(object$call)) - structure(table, heading = c(head, mod), Random.seed = seed, - control = control, - class = c("anova.cca", "anova", "data.frame")) -} Deleted: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-12-03 17:03:28 UTC (rev 2799) +++ pkg/vegan/R/anovacca.byterm.R 2013-12-03 17:13:16 UTC (rev 2800) @@ -1,171 +0,0 @@ -### Implementation of by-cases for vegan 2.2 versions of -### anova.cca. These are all internal functions that are not intended -### to be called by users in normal sessions, but they should be -### called from anova.cca (2.2). Therefore the user interface is rigid -### and input is not checked. The 'permutations' should be a -### permutation matrix. - -### by = terms builds models as a sequence of adding terms and submits -### this to anova.ccalist - -`anovacca.byterm` <- - function(object, permutations, model, parallel) -{ - ## We need term labels but without Condition() terms - trms <- terms(object) - trmlab <- attr(trms, "term.labels") - trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), - "term.labels")] - ntrm <- length(trmlab) - m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-"))) - mods <- list(m0) - for(i in seq_along(trmlab)) { - fla <- paste(". ~ . + ", trmlab[i]) - mods[[i+1]] <- update(mods[[i]], fla) - } - ## The result - sol <- anova.ccalist(mods, permutations = permutations, - model = model, parallel = parallel) - ## Reformat - out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]), - c(sol[-1,4], sol[ntrm+1,2]), - c(sol[-1,5], NA), - c(sol[-1,6], NA)) - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") - rownames(out) <- c(trmlab, "Residual") - head <- paste0("Permutation test for ", object$method, " under ", - model, " model\n", - "Terms added sequentially (first to last)\n", - howHead(attr(permutations, "control"))) - mod <- paste("Model:", c(object$call)) - attr(out, "heading") <- c(head, mod) - class(out) <- c("anova","data.frame") - out -} - -## by = margin: this is not a anova.ccalist case, but we omit each -## term in turn and compare against the complete model. - -`anovacca.bymargin` <- - function(object, permutations, scope, ...) -{ - nperm <- nrow(permutations) - ## Refuse to handle models with missing data - if (!is.null(object$na.action)) - stop("by = 'margin' models cannot handle missing data") - ## We need term labels but without Condition() terms - if (!is.null(scope) && is.character(scope)) - trms <- scope - else - trms <- drop.scope(object) - trmlab <- trms[trms %in% attr(terms(object$terminfo), - "term.labels")] - if(length(trmlab) == 0) - stop("the scope was empty: no available marginal terms") - ## baseline: all terms - big <- permutest(object, permutations, ...) - dfbig <- big$df[2] - chibig <- big$chi[2] - scale <- big$den/dfbig - ## Collect all marginal models. This differs from old version - ## (vegan 2.0) where other but 'nm' were partialled out within - ## Condition(). Now we only fit the model without 'nm' and compare - ## the difference against the complete model. - mods <- lapply(trmlab, function(nm, ...) - permutest(update(object, paste(".~.-", nm)), - permutations, ...), ...) - ## Chande in df - Df <- sapply(mods, function(x) x$df[2]) - dfbig - ## F of change - Chisq <- sapply(mods, function(x) x$chi[2]) - chibig - Fstat <- (Chisq/Df)/(chibig/dfbig) - ## Simulated F-values - Fval <- sapply(mods, function(x) x$num) - ## Had we an empty model we need to clone the denominator - if (length(Fval) == 1) - Fval <- matrix(Fval, nrow=nperm) - Fval <- sweep(-Fval, 1, big$num, "+") - Fval <- sweep(Fval, 2, Df, "/") - Fval <- sweep(Fval, 1, scale, "/") - ## Simulated P-values - Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1) - ## Collect results to anova data.frame - out <- data.frame(c(Df, dfbig), c(Chisq, chibig), - c(Fstat, NA), c(Pval, NA)) - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") - rownames(out) <- c(trmlab, "Residual") - head <- paste0("Permutation test for ", object$method, " under ", - mods[[1]]$model, " model\n", - "Marginal effects of terms\n", - howHead(attr(permutations, "control"))) - mod <- paste("Model:", c(object$call)) - attr(out, "heading") <- c(head, mod) - class(out) <- c("anova", "data.frame") - out -} - -### Marginal test for axes - -`anovacca.byaxis` <- - function(object, permutations, model, parallel, cutoff = 1) -{ - nperm <- nrow(permutations) - ## Observed F-values and Df - eig <- object$CCA$eig - resdf <- nobs(object) - length(eig) - max(object$pCCA$rank, 0) - 1 - Fstat <- eig/object$CA$tot.chi*resdf - Df <- rep(1, length(eig)) - ## Marginal P-values - LC <- object$CCA$u - ## missing values? - if (!is.null(object$na.action)) - LC <- napredict(structure(object$na.action, - class="exclude"), LC) - ## subset? - if (!is.null(object$subset)) { - tmp <- matrix(NA, nrow=length(object$subset), - ncol = ncol(LC)) - tmp[object$subset,] <- LC - LC <- tmp - object <- update(object, subset = object$subset) - } - LC <- as.data.frame(LC) - fla <- reformulate(names(LC)) - Pvals <- rep(NA, length(eig)) - environment(object$terms) <- environment() - for (i in 1:length(eig)) { - part <- paste("~ . +Condition(", - paste(names(LC)[-i], collapse = "+"), ")") - upfla <- update(fla, part) - ## only one axis, and cannot partial out? - if (length(eig) == 1) - mod <- permutest(object, permutations, model = model, - parallel = parallel) - else - mod <- - permutest(update(object, upfla, data = LC), - permutations, model = model, - parallel = parallel) - Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) - if (Pvals[i] > cutoff) - break - } - out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), - c(Fstat, NA), c(Pvals,NA)) - rownames(out) <- c(names(eig), "Residual") - isRDA <- inherits(object, "rda") - colnames(out) <- c("Df", ifelse(isRDA, "Variance", "ChiSquare"), - "F", "Pr(>F)") - head <- paste0("Permutation test for ", object$method, " under ", - model, " model\n", - "Marginal tests for axes\n", - howHead(attr(permutations, "control"))) - mod <- paste("Model:", c(object$call)) - attr(out, "heading") <- c(head, mod) - class(out) <- c("anova", "data.frame") - out -} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-03 17:03:28 UTC (rev 2799) +++ pkg/vegan/inst/ChangeLog 2013-12-03 17:13:16 UTC (rev 2800) @@ -4,9 +4,10 @@ Version 2.1-40 (opened December 3, 2013) - * anova.cca: start deprecation of old anova.cca and rename it to - ccanova. Vegan should fail all tests while deprecation is - incomplete and new code is not yet in use. + * anova.cca: Function is now based on the new code, and the old + (deprecated) code is called ccanova. Except several functions to + fail while they depend on the old interface (certainly add1.cca, + drop1.cca, ordistep, ordiR2step). Version 2.1-39 (closed December 3, 2013) Copied: pkg/vegan/man/anova.cca.Rd (from rev 2798, pkg/vegan/man/anovacca.Rd) =================================================================== --- pkg/vegan/man/anova.cca.Rd (rev 0) +++ pkg/vegan/man/anova.cca.Rd 2013-12-03 17:13:16 UTC (rev 2800) @@ -0,0 +1,179 @@ +\name{anova.cca} +\alias{anova.cca} +%\alias{anova.ccanull} +%\alias{anova.ccabyaxis} +%\alias{anova.ccabyterm} +%\alias{anova.ccabymargin} +%\alias{anova.prc} +\alias{permutest} +%\alias{permutest.default} +\alias{permutest.cca} + +\title{Permutation Test for Constrained Correspondence Analysis, + Redundancy Analysis and Constrained Analysis of Principal Coordinates } + +\description{ + The function performs an ANOVA like permutation test for Constrained + Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis + (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA, + \code{\link{capscale}}) to assess the significance of constraints. +} + +\usage{ +\method{anova}{cca}(object, ..., permutations = how(nperm=999), + by = NULL, model = c("reduced", "direct", "full"), + parallel = getOption("mc.cores"), strata = NULL, + cutoff = 1, scope = NULL) +\method{permutest}{cca}(x, permutations = how(nperm = 99), + model = c("reduced", "direct"), first = FALSE, strata = NULL, + parallel = getOption("mc.cores"), ...) +} + +\arguments{ + + \item{object}{One or several result objects from \code{\link{cca}}, + \code{\link{rda}} or \code{\link{capscale}}. If there are several + result objects, they are compared against each other in the ordre + they were supplied. For a single object, a test specified in + \code{by} or an overal test is given.} + + \item{x}{A single ordination result object.} + + \item{permutations}{Either a \code{\link[permute]{how}} result + defining permutations, or a permutation matrix with each row giving + the permutation indices, or the number of permutations for simple + permutations. See \code{\link{permutations}} for details.} + + \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{model}{Permutation model: \code{model="direct"} permutes + community data, and \code{model="reduced"} permutes residuals + of the community data after Conditions (partial model).} + + \item{parallel}{Use parallel processing with the given number of + cores.} + + \item{strata}{An integer vector or factor specifying the strata for + permutation. If supplied, observations are permuted only within + the specified strata. It is an error to use this when + \code{permutations} is a matrix, or a \code{\link[permute]{how}} + defines \code{blocks}. This is a legacy argument that will be + deprecated in the future: use + \code{permutations = how(\dots, blocks)} instead. } + + \item{cutoff}{Only effective with \code{by="axis"} where stops + permutations after an axis exceeds the \code{cutoff}.} + + \item{scope}{Only effective with \code{by="margin"} where it can be + used to select the marginal terms for testing. The default is to + test all marginal terms in \code{\link{drop.scope}}.} + + \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{ + + Functions \code{anova.cca} and \code{permutest.cca} implement + ANOVA like permutation tests for the joint effect of constraints in + \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}. + Functions \code{anova.cca} and \code{permutest.cca} differ in + printout style and in interface. Function \code{permutest.cca} is + the proper workhorse, but \code{anova.cca} passes all parameters to + \code{permutest.cca}. + + Function \code{anova} can analyse a sequence of constrained + ordination models. The analysis is based on the differences in + residual deviances in permutations of nested models. + + The default test is for the sum of all constrained eigenvalues. + Setting \code{first = TRUE} will perform a test for the first + constrained eigenvalue. Argument \code{first} can be set either in + \code{anova.cca} or in \code{permutest.cca}. It is also possible to + perform significance tests for each axis or for each term + (constraining variable) using argument \code{by} in + \code{anova.cca}. Setting \code{by = "axis"} will perform separate + significance tests for each constrained axis. All previous + constrained axes will be used as conditions (\dQuote{partialled + out}) and a test for the first constrained eigenvalues is + performed (Legendre et al. 2011). + You can stop permutation tests after exceeding a given + significance level with argument \code{cutoff} to speed up + calculations in large models. Setting \code{by = "terms"} will + perform separate significance test for each term (constraining + variable). The terms are assessed sequentially from first to last, + and the order of the terms will influence their + significances. Setting \code{by = "margin"} will perform separate + significance test for each marginal term in a model with all other + terms. The marginal test also accepts a \code{scope} argument for + the \code{\link{drop.scope}} which can be a character vector of term + labels that are analysed, or a fitted model of lower scope. The + marginal effects are also known as \dQuote{Type III} effects, but + the current function only evaluates marginal terms. It will, for + instance, ignore main effects that are included in interaction + terms. In calculating pseudo-\eqn{F}, all terms are compared to the + same residual of the full model. + + Community data are permuted with choice \code{model="direct"}, + and residuals after partial CCA/ RDA/ dbRDA with choice + \code{model="reduced"} (default). If there is no partial CCA/ + RDA/ dbRDA stage, \code{model="reduced"} simply permutes the data + and is equivalent to \code{model="direct"}. The test statistic is + \dQuote{pseudo-\eqn{F}}, which is the ratio of constrained and + unconstrained total Inertia (Chi-squares, variances or something + similar), each divided by their respective ranks. If there are no + conditions (\dQuote{partial} terms), the sum of all eigenvalues + remains constant, so that pseudo-\eqn{F} and eigenvalues would give + equal results. In partial CCA/ RDA/ dbRDA, the effect of + conditioning variables (\dQuote{covariables}) is removed before + permutation, and these residuals are added to the non-permuted + fitted values of partial CCA (fitted values of \code{X ~ Z}). + Consequently, the total Chi-square is not fixed, and test based on + pseudo-\eqn{F} would differ from the test based on plain + eigenvalues. CCA is a weighted method, and environmental data are + re-weighted at each permutation step using permuted weights. } + +\value{ + The function \code{anova.cca} calls \code{permutest.cca} and fills an + \code{\link{anova}} table. +} + +\note{ + Some cases of \code{anova} need access to the original data on + constraints (at least \code{by = "term"} and \code{by = "margin"}), + and they may fail if data are unavailable. +} +\references{ + Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd + English ed. Elsevier. + + Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the + significance of canonical axes in redundancy analysis. + \emph{Methods in Ecology and Evolution} 2, 269--277. +} +\author{Jari Oksanen} + +\seealso{\code{\link{anova.cca}}, \code{\link{cca}}, + \code{\link{rda}}, \code{\link{capscale}} to get something to + analyse. Function \code{\link{drop1.cca}} calls \code{anova.cca} + with \code{by = "margin"}, and \code{\link{add1.cca}} an analysis + for single terms additions, which can be used in automatic or + semiautomatic model building (see \code{\link{deviance.cca}}). } + +\examples{ +data(varespec) +data(varechem) +vare.cca <- cca(varespec ~ Al + P + K, varechem) +## overall test +anova(vare.cca) +} +\keyword{ multivariate } +\keyword{ htest } Deleted: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-12-03 17:03:28 UTC (rev 2799) +++ pkg/vegan/man/anovacca.Rd 2013-12-03 17:13:16 UTC (rev 2800) @@ -1,179 +0,0 @@ -\name{anovacca} -\alias{anovacca} -%\alias{anova.ccanull} -%\alias{anova.ccabyaxis} -%\alias{anova.ccabyterm} -%\alias{anova.ccabymargin} -%\alias{anova.prc} -\alias{permutest} -%\alias{permutest.default} -\alias{permutest.cca} - -\title{Permutation Test for Constrained Correspondence Analysis, - Redundancy Analysis and Constrained Analysis of Principal Coordinates } - -\description{ - The function performs an ANOVA like permutation test for Constrained - Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis - (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA, - \code{\link{capscale}}) to assess the significance of constraints. -} - -\usage{ -anovacca(object, ..., permutations = how(nperm=999), - by = NULL, model = c("reduced", "direct", "full"), - parallel = getOption("mc.cores"), strata = NULL, - cutoff = 1, scope = NULL) -\method{permutest}{cca}(x, permutations = how(nperm = 99), - model = c("reduced", "direct"), first = FALSE, strata = NULL, - parallel = getOption("mc.cores"), ...) -} - -\arguments{ - - \item{object}{One or several result objects from \code{\link{cca}}, [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2800 From noreply at r-forge.r-project.org Tue Dec 3 18:34:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 18:34:58 +0100 (CET) Subject: [Vegan-commits] r2801 - in pkg/vegan: . R man Message-ID: <20131203173458.816F718477A@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 18:34:58 +0100 (Tue, 03 Dec 2013) New Revision: 2801 Modified: pkg/vegan/NAMESPACE pkg/vegan/R/add1.cca.R pkg/vegan/R/ccanova.R pkg/vegan/R/drop1.cca.R pkg/vegan/R/ordiR2step.R pkg/vegan/R/ordistep.R pkg/vegan/man/add1.cca.Rd pkg/vegan/man/ccanova.Rd Log: stage 3 of new anova.cca: start adapting functions dependent on anova.cca and fix things flagged in R CMD build Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/NAMESPACE 2013-12-03 17:34:58 UTC (rev 2801) @@ -30,7 +30,7 @@ vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores, wcmdscale, wisconsin) ## Export temporary function later intended to replace anova.cca() -export(anovacca) ## <-- REMOVE THIS WHEN anova.cca IS UPGRADED <--!!! +export(ccanova) ## <-- REMOVE THIS WHEN ccanova IS REMOVED <--!!! ## export pasteCall for 'permute' export(pasteCall) ## export anova.cca for 'BiodiversityR': this should be fixed there Modified: pkg/vegan/R/add1.cca.R =================================================================== --- pkg/vegan/R/add1.cca.R 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/R/add1.cca.R 2013-12-03 17:34:58 UTC (rev 2801) @@ -1,6 +1,6 @@ `add1.cca`<- function(object, scope, test = c("none", "permutation"), - pstep = 100, perm.max = 200, ...) + permutations = how(nperm = 199), ...) { if (inherits(object, "prc")) stop("'step'/'add1' cannot be used for 'prc' objects") @@ -27,7 +27,7 @@ else nfit <- update(object, as.formula(paste(". ~ . +", tt))) - tmp <- anova(nfit, step = pstep, perm.max = perm.max, ...) + tmp <- anova(nfit, permutations = permutations, ...) adds[i+1,] <- unlist(tmp[1,3:5]) } colnames(adds) <- colnames(tmp)[3:5] Modified: pkg/vegan/R/ccanova.R =================================================================== --- pkg/vegan/R/ccanova.R 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/R/ccanova.R 2013-12-03 17:34:58 UTC (rev 2801) @@ -1,4 +1,4 @@ -`anova.cca` <- +`ccanova` <- function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999, by = NULL, ...) { Modified: pkg/vegan/R/drop1.cca.R =================================================================== --- pkg/vegan/R/drop1.cca.R 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/R/drop1.cca.R 2013-12-03 17:34:58 UTC (rev 2801) @@ -1,6 +1,6 @@ `drop1.cca` <- function(object, scope, test = c("none", "permutation"), - pstep = 100, perm.max = 200, ...) + permutations = how(nperm = 199), ...) { if (inherits(object, "prc")) stop("'step'/'drop1' cannot be used for 'prc' objects") @@ -13,8 +13,8 @@ scope <- rn else if (!is.character(scope)) scope <- drop.scope(scope) - adds <- anova(object, by = "margin", step = pstep, - perm.max = perm.max, scope = scope, ...) + adds <- anova(object, by = "margin", scope = scope, + permutations = permutations, ...) nr <- nrow(adds) out <- cbind(out, rbind(NA, adds[rn,3:5])) class(out) <- cl Modified: pkg/vegan/R/ordiR2step.R =================================================================== --- pkg/vegan/R/ordiR2step.R 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/R/ordiR2step.R 2013-12-03 17:34:58 UTC (rev 2801) @@ -4,7 +4,7 @@ `ordiR2step` <- function(object, scope, direction = c("both", "forward"), - Pin = 0.05, R2scope = TRUE, pstep = 100, perm.max = 1000, + Pin = 0.05, R2scope = TRUE, permutations = how(nperm=499), trace = TRUE, ...) { direction <- match.arg(direction) @@ -78,7 +78,7 @@ if (R2scope) R2.adds[best] <= R2.all else TRUE) { ## Second criterion: added variable is significant tst <- add1(object, scope = adds[best], test="permu", - pstep = pstep, perm.max = perm.max, + permutations = permutations, alpha = Pin, trace = FALSE, ...) if (trace) { print(tst[-1,]) @@ -95,7 +95,7 @@ } } if (NROW(anotab) > 0) { - anotab <- rbind(anotab, "" = c(R2.all, rep(NA, 5))) + anotab <- rbind(anotab, "" = c(R2.all, rep(NA, 4))) class(anotab) <- c("anova", class(anotab)) object$anova <- anotab } Modified: pkg/vegan/R/ordistep.R =================================================================== --- pkg/vegan/R/ordistep.R 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/R/ordistep.R 2013-12-03 17:34:58 UTC (rev 2801) @@ -1,6 +1,6 @@ `ordistep` <- function(object, scope, direction =c("both", "backward", "forward"), - Pin = 0.05, Pout = 0.1, pstep = 100, perm.max = 1000, + Pin = 0.05, Pout = 0.1, permutations = how(nperm = 199), steps=50, trace = TRUE, ...) { if (!inherits(object, "cca")) @@ -43,17 +43,18 @@ change <- NULL ## Consider dropping if (backward && length(scope$drop)) { - aod <- drop1(object, scope = scope$drop, test="perm", pstep = pstep, - perm.max = perm.max, alpha = Pout, trace = trace, ...) + aod <- drop1(object, scope = scope$drop, test="perm", + permutations = permutations, + alpha = Pout, trace = trace, ...) aod <- aod[-1,] - o <- order(-aod[,5], aod[,4], aod[,2]) + o <- order(-aod[,4], aod[,2]) aod <- aod[o,] rownames(aod) <- paste("-", rownames(aod), sep = " ") if (trace) { cat("\n") print(aod) } - if (is.na(aod[1,5]) || aod[1,5] > Pout) { + if (is.na(aod[1,4]) || aod[1,4] > Pout) { anotab <- rbind(anotab, aod[1,]) change <- rownames(aod)[1] object <- eval.parent(update(object, paste("~ .", change))) @@ -70,14 +71,14 @@ aod <- add1(object, scope = scope$add, test = "perm", pstep = pstep, perm.max = perm.max, alpha = Pin, trace = trace, ...) aod <- aod[-1,] - o <- order(aod[,5], aod[,4], aod[,2]) + o <- order(aod[,4], aod[,2]) aod <- aod[o,] rownames(aod) <- paste("+", rownames(aod), sep = " ") if (trace) { cat("\n") print(aod) } - if (!is.na(aod[1,5]) && aod[1,5] <= Pin) { + if (!is.na(aod[1,4]) && aod[1,4] <= Pin) { anotab <- rbind(anotab, aod[1,]) change <- rownames(aod)[1] object <- eval.parent(update(object, paste( "~ .",change))) Modified: pkg/vegan/man/add1.cca.Rd =================================================================== --- pkg/vegan/man/add1.cca.Rd 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/man/add1.cca.Rd 2013-12-03 17:34:58 UTC (rev 2801) @@ -9,9 +9,9 @@ } \usage{ \method{add1}{cca}(object, scope, test = c("none", "permutation"), - pstep = 100, perm.max = 200, ...) + permutations = how(nperm=199), ...) \method{drop1}{cca}(object, scope, test = c("none", "permutation"), - pstep = 100, perm.max = 200, ...) + permutations = how(nperm=199), ...) } \arguments{ @@ -20,9 +20,12 @@ \item{scope}{ A formula giving the terms to be considered for adding or dropping; see \code{\link{add1}} for details.} \item{test}{ Should a permutation test be added using \code{\link{anova.cca}}. } - \item{pstep}{Number of permutations in one step, passed as argument - \code{step} to \code{\link{anova.cca}}.} - \item{perm.max}{ Maximum number of permutation in \code{\link{anova.cca}}. } + + \item{permutations}{Permutation scheme as defined in + \code{\link[permute]{ho}}; the default defines a simple + permutations (and could also be expressed as a single number). Any + structure accepted by \code{\link{anova.cca}} acn be used.} + \item{\dots}{Other arguments passed to \code{\link{add1.default}}, \code{\link{drop1.default}}, and \code{\link{anova.cca}}.} } Modified: pkg/vegan/man/ccanova.Rd =================================================================== --- pkg/vegan/man/ccanova.Rd 2013-12-03 17:13:16 UTC (rev 2800) +++ pkg/vegan/man/ccanova.Rd 2013-12-03 17:34:58 UTC (rev 2801) @@ -33,7 +33,7 @@ \details{ Function \code{ccanova} is a deprecated version of \code{anova.cca}. - The new \code{link{\anova.cca}} function is completely + 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 From noreply at r-forge.r-project.org Tue Dec 3 19:37:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 19:37:39 +0100 (CET) Subject: [Vegan-commits] r2802 - in pkg/vegan: R inst man Message-ID: <20131203183739.69C30181474@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 19:37:39 +0100 (Tue, 03 Dec 2013) New Revision: 2802 Modified: pkg/vegan/R/add1.cca.R pkg/vegan/R/drop1.cca.R pkg/vegan/R/ordistep.R pkg/vegan/inst/ChangeLog pkg/vegan/man/add1.cca.Rd pkg/vegan/man/anova.cca.Rd pkg/vegan/man/ordistep.Rd Log: stage 4 or new anova.cca: Pass examples in R CMD check, but still fail in inst/tests Modified: pkg/vegan/R/add1.cca.R =================================================================== --- pkg/vegan/R/add1.cca.R 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/R/add1.cca.R 2013-12-03 18:37:39 UTC (rev 2802) @@ -15,7 +15,7 @@ if (!is.character(scope)) scope <- add.scope(object, update.formula(object, scope)) ns <- length(scope) - adds <- matrix(0, ns+1, 3) + adds <- matrix(0, ns+1, 2) adds[1, ] <- NA for (i in 1:ns) { tt <- scope[i] @@ -28,9 +28,9 @@ nfit <- update(object, as.formula(paste(". ~ . +", tt))) tmp <- anova(nfit, permutations = permutations, ...) - adds[i+1,] <- unlist(tmp[1,3:5]) + adds[i+1,] <- unlist(tmp[1,3:4]) } - colnames(adds) <- colnames(tmp)[3:5] + colnames(adds) <- colnames(tmp)[3:4] out <- cbind(out, adds) class(out) <- cl } Modified: pkg/vegan/R/drop1.cca.R =================================================================== --- pkg/vegan/R/drop1.cca.R 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/R/drop1.cca.R 2013-12-03 18:37:39 UTC (rev 2802) @@ -16,7 +16,7 @@ adds <- anova(object, by = "margin", scope = scope, permutations = permutations, ...) nr <- nrow(adds) - out <- cbind(out, rbind(NA, adds[rn,3:5])) + out <- cbind(out, rbind(NA, adds[rn,3:4])) class(out) <- cl } out Modified: pkg/vegan/R/ordistep.R =================================================================== --- pkg/vegan/R/ordistep.R 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/R/ordistep.R 2013-12-03 18:37:39 UTC (rev 2802) @@ -68,8 +68,9 @@ } ## Consider adding if (forward && length(scope$add)) { - aod <- add1(object, scope = scope$add, test = "perm", pstep = pstep, - perm.max = perm.max, alpha = Pin, trace = trace, ...) + aod <- add1(object, scope = scope$add, test = "perm", + permutations = permutations, + alpha = Pin, trace = trace, ...) aod <- aod[-1,] o <- order(aod[,4], aod[,2]) aod <- aod[o,] Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/inst/ChangeLog 2013-12-03 18:37:39 UTC (rev 2802) @@ -4,10 +4,21 @@ Version 2.1-40 (opened December 3, 2013) - * anova.cca: Function is now based on the new code, and the old - (deprecated) code is called ccanova. Except several functions to - fail while they depend on the old interface (certainly add1.cca, - drop1.cca, ordistep, ordiR2step). + * anova.cca: Function is now based on the new code, but the old is + avaialable in a function called ccanova. The API changes: + arguments 'step' and 'perm.max' are gone and replaced with + 'permutations' that accepts a how() object defining permutations, + or a single number like previously or a permutation matrix. The + new anova.cca adds an option of analysing a sequence of ordination + models. This also means that '...' is now the second argument and + the names of all arguments must be written in full. This change + can be expected to cause trouble outside vegan. Currently the + tests in examples are passed, but tests fail (looks like being + caused by the change in API). + + * add1.cca, drop1.cca, ordistep, ordiR2step: functions were + adapted to new anova.cca and this brought along similar changes in + API. Version 2.1-39 (closed December 3, 2013) Modified: pkg/vegan/man/add1.cca.Rd =================================================================== --- pkg/vegan/man/add1.cca.Rd 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/man/add1.cca.Rd 2013-12-03 18:37:39 UTC (rev 2802) @@ -22,7 +22,7 @@ \item{test}{ Should a permutation test be added using \code{\link{anova.cca}}. } \item{permutations}{Permutation scheme as defined in - \code{\link[permute]{ho}}; the default defines a simple + \code{\link[permute]{how}}; the default defines a simple permutations (and could also be expressed as a single number). Any structure accepted by \code{\link{anova.cca}} acn be used.} Modified: pkg/vegan/man/anova.cca.Rd =================================================================== --- pkg/vegan/man/anova.cca.Rd 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/man/anova.cca.Rd 2013-12-03 18:37:39 UTC (rev 2802) @@ -73,6 +73,8 @@ used to select the marginal terms for testing. The default is to test all marginal terms in \code{\link{drop.scope}}.} + \item{first}{Analyse only significance of the first axis.} + \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 Modified: pkg/vegan/man/ordistep.Rd =================================================================== --- pkg/vegan/man/ordistep.Rd 2013-12-03 17:34:58 UTC (rev 2801) +++ pkg/vegan/man/ordistep.Rd 2013-12-03 18:37:39 UTC (rev 2802) @@ -16,10 +16,10 @@ } \usage{ ordistep(object, scope, direction = c("both", "backward", "forward"), - Pin = 0.05, Pout = 0.1, pstep = 100, perm.max = 1000, steps = 50, + Pin = 0.05, Pout = 0.1, permutation = how(nperm = 199), steps = 50, trace = TRUE, ...) ordiR2step(object, scope, direction = c("both", "forward"), - Pin = 0.05, R2scope = TRUE, pstep = 100, perm.max = 1000, + Pin = 0.05, R2scope = TRUE, permutations = how(nperm = 499), trace = TRUE, ...) } %- maybe also 'usage' for other objects documented here. From noreply at r-forge.r-project.org Tue Dec 3 19:48:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 19:48:54 +0100 (CET) Subject: [Vegan-commits] r2803 - pkg/vegan/man Message-ID: <20131203184854.5235E184316@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 19:48:54 +0100 (Tue, 03 Dec 2013) New Revision: 2803 Modified: pkg/vegan/man/ordistep.Rd Log: typo (laziness) Modified: pkg/vegan/man/ordistep.Rd =================================================================== --- pkg/vegan/man/ordistep.Rd 2013-12-03 18:37:39 UTC (rev 2802) +++ pkg/vegan/man/ordistep.Rd 2013-12-03 18:48:54 UTC (rev 2803) @@ -16,7 +16,7 @@ } \usage{ ordistep(object, scope, direction = c("both", "backward", "forward"), - Pin = 0.05, Pout = 0.1, permutation = how(nperm = 199), steps = 50, + Pin = 0.05, Pout = 0.1, permutations = how(nperm = 199), steps = 50, trace = TRUE, ...) ordiR2step(object, scope, direction = c("both", "forward"), Pin = 0.05, R2scope = TRUE, permutations = how(nperm = 499), From noreply at r-forge.r-project.org Tue Dec 3 21:39:40 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 21:39:40 +0100 (CET) Subject: [Vegan-commits] r2804 - pkg/vegan/man Message-ID: <20131203203940.1A04F1858D5@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 21:39:39 +0100 (Tue, 03 Dec 2013) New Revision: 2804 Modified: pkg/vegan/man/ordistep.Rd Log: really do document new anova.cca API in ordistep Modified: pkg/vegan/man/ordistep.Rd =================================================================== --- pkg/vegan/man/ordistep.Rd 2013-12-03 18:48:54 UTC (rev 2803) +++ pkg/vegan/man/ordistep.Rd 2013-12-03 20:39:39 UTC (rev 2804) @@ -51,12 +51,10 @@ lower adjusted \eqn{R^2}{R2} than scope are accepted. } - \item{pstep}{ - Number of permutations in one step. See \code{\link{add1.cca}}. -} - \item{perm.max}{ - Maximum number of permutation in \code{\link{anova.cca}}. -} + \item{permutations}{ Number or permutations, a permutation matrix or + a \code{\link[permute]{how}} object to define the permutations. This + is passed to \code{\link{anova.cca}}: see there for details. } + \item{steps}{ Maximum number of iteration steps of dropping and adding terms. } From noreply at r-forge.r-project.org Tue Dec 3 22:05:17 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Dec 2013 22:05:17 +0100 (CET) Subject: [Vegan-commits] r2805 - in pkg/vegan: inst tests Message-ID: <20131203210517.99C3B184316@r-forge.r-project.org> Author: jarioksa Date: 2013-12-03 22:05:17 +0100 (Tue, 03 Dec 2013) New Revision: 2805 Modified: pkg/vegan/inst/ChangeLog pkg/vegan/tests/vegan-tests.R Log: comment out failing anova.cca tests, but keep the *.save file to remind us of the problems in every check Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-03 20:39:39 UTC (rev 2804) +++ pkg/vegan/inst/ChangeLog 2013-12-03 21:05:17 UTC (rev 2805) @@ -19,6 +19,16 @@ * add1.cca, drop1.cca, ordistep, ordiR2step: functions were adapted to new anova.cca and this brought along similar changes in API. + + * tests for cca/rda/capscale: commented out test that failed with + the anova.cca. Known issue was that 'by = "term"' and 'by = + "axis"' stop with error with missing data. This was designed and + and can be re-designed to handle missing data by listwise deletion + so that models will have the same number of observation for every + variable. An unknown issue was that 'by = "margin"' failed in + capscale(). This may be a scoping issue an needs inspection. We + keep the old vegan-tests.Rout.save file so that we are reminded of + the problems at every check. Version 2.1-39 (closed December 3, 2013) Modified: pkg/vegan/tests/vegan-tests.R =================================================================== --- pkg/vegan/tests/vegan-tests.R 2013-12-03 20:39:39 UTC (rev 2804) +++ pkg/vegan/tests/vegan-tests.R 2013-12-03 21:05:17 UTC (rev 2805) @@ -37,30 +37,35 @@ ### data= argument ## cca/rda m <- cca(fla, data=df, na.action=na.exclude, subset = Use != "Pasture" & spno > 7) -anova(m, perm=100) -anova(m, by="term", perm=100) -anova(m, by="margin", perm=100) -anova(m, by="axis", perm=100) +anova(m, permutations=99) +## vegan 2.1-40 cannot handle missing data in next two +##anova(m, by="term", permutations=99) +##anova(m, by="margin", permutations=99) +anova(m, by="axis", permutations=99) ## capscale p <- capscale(fla, data=df, na.action=na.exclude, subset = Use != "Pasture" & spno > 7) -anova(p, perm=100) -anova(p, by="term", perm=100) -anova(p, by="margin", perm=100) -anova(p, by="axis", perm=100) +anova(p, permutations=99) +## vegan 2.1-40 cannot hndle missing data in next two +##anova(p, by="term", permutations=99) +##anova(p, by="margin", permutations=99) +##anova(p, by="axis", permutations=99) ## see that capscale can be updated and also works with 'dist' input dis <- vegdist(dune) p <- update(p, dis ~ .) -anova(p, perm=100) -anova(p, by="term", perm=100) -anova(p, by="margin", perm=100) -anova(p, by="axis", perm=100) +anova(p, permutations=99) +## vegan 2.1-40 cannot handle missing data in next three +##anova(p, by="term", permutations=99) +##anova(p, by="margin", permutations=99) +##anova(p, by="axis", permutations=99) ### attach()ed data frame instead of data= attach(df) q <- cca(fla, na.action = na.omit, subset = Use != "Pasture" & spno > 7) -anova(q, perm=100) -anova(q, by="term", perm=100) -anova(q, by="margin", perm=100) -anova(q, by="axis", perm=100) +anova(q, permutations=99) +## commented tests below fail in vegan 2.1-40 because number of +## observations changes +##anova(q, by="term", permutations=99) +##anova(q, by="margin", permutations=99) +anova(q, by="axis", permutations=99) ### Check that constrained ordination functions can be embedded. ### The data.frame 'df' is still attach()ed. foo <- function(bar, Y, X, ...) @@ -77,7 +82,7 @@ detach(df) ### Check that statistics match in partial constrained ordination m <- cca(dune ~ A1 + Moisture + Condition(Management), dune.env, subset = A1 > 3) -tab <- anova(m, by = "axis", perm.max = 100) +tab <- anova(m, by = "axis", permutations = 99) m tab all.equal(tab[,2], c(m$CCA$eig, m$CA$tot.chi), check.attributes=FALSE) From noreply at r-forge.r-project.org Thu Dec 5 12:14:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 5 Dec 2013 12:14:49 +0100 (CET) Subject: [Vegan-commits] r2806 - in branches/2.0: . R inst man Message-ID: <20131205111449.C663D185B5E@r-forge.r-project.org> Author: jarioksa Date: 2013-12-05 12:14:49 +0100 (Thu, 05 Dec 2013) New Revision: 2806 Modified: branches/2.0/DESCRIPTION branches/2.0/R/permutest.betadisper.R branches/2.0/inst/ChangeLog branches/2.0/man/betadisper.Rd branches/2.0/man/permutest.betadisper.Rd Log: open vegan 2.0-10: adapt permutest.betadisper to permute 0.8-0 in CRAN Modified: branches/2.0/DESCRIPTION =================================================================== --- branches/2.0/DESCRIPTION 2013-12-03 21:05:17 UTC (rev 2805) +++ branches/2.0/DESCRIPTION 2013-12-05 11:14:49 UTC (rev 2806) @@ -1,12 +1,12 @@ Package: vegan Title: Community Ecology Package -Version: 2.0-9 -Date: September 25, 2013 +Version: 2.0-10 +Date: December 5, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Maintainer: Jari Oksanen -Depends: permute, lattice, R (>= 2.14.0) +Depends: permute (>= 0.8-0), lattice, R (>= 2.14.0) Suggests: MASS, mgcv, cluster, scatterplot3d, rgl, tcltk Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. Modified: branches/2.0/R/permutest.betadisper.R =================================================================== --- branches/2.0/R/permutest.betadisper.R 2013-12-03 21:05:17 UTC (rev 2805) +++ branches/2.0/R/permutest.betadisper.R 2013-12-05 11:14:49 UTC (rev 2806) @@ -1,5 +1,5 @@ `permutest.betadisper` <- function(x, pairwise = FALSE, - control = permControl(nperm = 999), ...) + control = how(nperm = 999), ...) { t.statistic <- function(x, y) { m <- length(x) @@ -11,6 +11,7 @@ pooled <- sqrt(((m-1)*xvar + (n-1)*yvar) / (m+n-2)) (xbar - ybar) / (pooled * sqrt(1/m + 1/n)) } + if(!inherits(x, "betadisper")) stop("Only for class \"betadisper\"") ## will issue error if only a single group @@ -20,42 +21,61 @@ mod.Q <- mod$qr p <- mod.Q$rank resids <- qr.resid(mod.Q, x$distances) - res <- numeric(length = control$nperm + 1) + + ## extract groups + group <- x$group + + ## get set of permutations - shuffleSet checks design + perms <- shuffleSet(length(group), control = control) + + ## number of permutations being performed, possibly adjusted after + ## checking in shuffleSet + nperm <- nrow(perms) + + ## 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) n.pairs <- ncol(combin) - t.stats <- matrix(0, ncol = n.pairs, nrow = control$nperm + 1) - t.stats[1,] <- apply(combn(levels(x$group), 2), 2, function(z) { - t.statistic(x$distances[x$group == z[1]], - x$distances[x$group == z[2]])}) + 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]])}) } - for(i in seq(along = res[-1])) { - perm <- shuffle(nobs, control = control) - perm.resid <- resids[perm] - f <- qr.fitted(mod.Q, perm.resid) + + ## begin loop over shuffleSet perms + for(i in seq_len(nperm)) { + perm <- perms[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][x$group == combin[1, j]] - grp2 <- x$distance[perm][x$group == combin[2, j]] + 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) } } } + + ## compute permutation p-value pval <- sum(res >= res[1]) / length(res) + if(pairwise) { df <- apply(combin, 2, function(z) { - length(x$distances[x$group == z[1]]) + - length(x$distance[x$group == z[2]]) - 2}) + 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))) @@ -64,12 +84,13 @@ } else { pairwise <- NULL } - retval <- cbind(mod.aov[, 1:4], c(control$nperm, NA), c(pval, NA)) + + retval <- cbind(mod.aov[, 1:4], c(nperm, NA), c(pval, NA)) dimnames(retval) <- list(c("Groups", "Residuals"), c("Df", "Sum Sq", "Mean Sq", "F", "N.Perm", "Pr(>F)")) retval <- list(tab = retval, pairwise = pairwise, - groups = levels(x$group), control = control) + groups = levels(group), control = control) class(retval) <- "permutest.betadisper" retval } Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-03 21:05:17 UTC (rev 2805) +++ branches/2.0/inst/ChangeLog 2013-12-05 11:14:49 UTC (rev 2806) @@ -2,6 +2,11 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ +Version 2.0-10 (opened December 5, 2013) + + * merge 2527: adapt permutest.betadisper to the CRAN release of + permute 0.8-0. + Version 2.0-9 (released September 25, 2013) * merge 2618: a typo. Modified: branches/2.0/man/betadisper.Rd =================================================================== --- branches/2.0/man/betadisper.Rd 2013-12-03 21:05:17 UTC (rev 2805) +++ branches/2.0/man/betadisper.Rd 2013-12-05 11:14:49 UTC (rev 2806) @@ -279,7 +279,7 @@ dis[c(2, 20)] <- NA mod2 <- betadisper(dis, groups) ## warnings mod2 -permutest(mod2, control = permControl(nperm = 100)) +permutest(mod2, control = how(nperm = 100)) anova(mod2) plot(mod2) boxplot(mod2) @@ -288,7 +288,7 @@ ## Using group centroids mod3 <- betadisper(dis, groups, type = "centroid") mod3 -permutest(mod3, control = permControl(nperm = 100)) +permutest(mod3, control = how(nperm = 100)) anova(mod3) plot(mod3) boxplot(mod3) Modified: branches/2.0/man/permutest.betadisper.Rd =================================================================== --- branches/2.0/man/permutest.betadisper.Rd 2013-12-03 21:05:17 UTC (rev 2805) +++ branches/2.0/man/permutest.betadisper.Rd 2013-12-05 11:14:49 UTC (rev 2806) @@ -10,7 +10,7 @@ } \usage{ \method{permutest}{betadisper}(x, pairwise = FALSE, - control = permControl(nperm = 999), \dots) + control = how(nperm = 999), \dots) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -18,8 +18,7 @@ call to \code{betadisper}.} \item{pairwise}{logical; perform pairwise comparisons of group means?} \item{control}{a list of control values for the permutations - to replace the default values returned by the function - \code{\link{permControl}}} + as returned by the function \code{\link[permute]{how}}} \item{\dots}{Arguments passed to other methods.} } \details{ @@ -49,7 +48,7 @@ pairwise comparisons of group mean distances (dispersions or variances).} \item{groups}{character; the levels of the grouping factor.} \item{control}{a list, the result of a call to - \code{\link{permControl}}.} + \code{\link{how}}.} } \references{ Anderson, M.J. (2006) Distance-based tests for homogeneity of From noreply at r-forge.r-project.org Thu Dec 5 12:50:52 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 5 Dec 2013 12:50:52 +0100 (CET) Subject: [Vegan-commits] r2807 - in branches/2.0: . R inst man vignettes Message-ID: <20131205115052.594A3186866@r-forge.r-project.org> Author: jarioksa Date: 2013-12-05 12:50:52 +0100 (Thu, 05 Dec 2013) New Revision: 2807 Removed: branches/2.0/R/confint.fisherfit.R branches/2.0/R/plot.profile.fisherfit.R branches/2.0/R/profile.fisherfit.R Modified: branches/2.0/NAMESPACE branches/2.0/R/boxplot.specaccum.R branches/2.0/R/decostand.R branches/2.0/R/factorfit.R branches/2.0/R/fisher.alpha.R branches/2.0/R/fisherfit.R branches/2.0/R/nestednodf.R branches/2.0/R/ordiArrowMul.R branches/2.0/R/plot.specaccum.R branches/2.0/R/print.cca.R branches/2.0/R/print.fisherfit.R branches/2.0/R/renyiaccum.R branches/2.0/R/specaccum.R branches/2.0/R/tsallisaccum.R branches/2.0/R/vectorfit.R branches/2.0/inst/ChangeLog branches/2.0/man/diversity.Rd branches/2.0/man/fisherfit.Rd branches/2.0/man/renyi.Rd branches/2.0/man/specaccum.Rd branches/2.0/man/tsallis.Rd branches/2.0/vignettes/diversity-vegan.Rnw Log: merge small bug fixes and enhancements to 2.0-10 (up to r2641) Modified: branches/2.0/NAMESPACE =================================================================== --- branches/2.0/NAMESPACE 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/NAMESPACE 2013-12-05 11:50:52 UTC (rev 2807) @@ -131,7 +131,6 @@ # confint: stats -- also uses MASS:::confint.glm & MASS:::profile.glm # does this work with namespaces?? S3method(confint, MOStest) -S3method(confint, fisherfit) # cophenetic: stats S3method(cophenetic, spantree) # density: stats @@ -264,7 +263,6 @@ S3method(plot, preston) S3method(plot, prestonfit) S3method(plot, procrustes) -S3method(plot, profile.fisherfit) S3method(plot, rad) S3method(plot, radfit) S3method(plot, radfit.frame) @@ -360,7 +358,6 @@ # profile: stats # see note on 'confint' S3method(profile, MOStest) -S3method(profile, fisherfit) S3method(profile, humpfit) # radfit: vegan S3method(radfit, data.frame) Modified: branches/2.0/R/boxplot.specaccum.R =================================================================== --- branches/2.0/R/boxplot.specaccum.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/boxplot.specaccum.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,11 +1,11 @@ -"boxplot.specaccum" <- +`boxplot.specaccum` <- function(x, add=FALSE, ...) { if (x$method != "random") stop("boxplot available only for method=\"random\"") if (!add) { plot(x$sites, x$richness, type="n", xlab="Sites", ylab="Species", - ylim=c(1, max(x$richness)), ...) + ylim=c(1, max(x$richness, na.rm = TRUE)), ...) } tmp <- boxplot(data.frame(t(x$perm)), add=TRUE, at=x$sites, axes=FALSE, ...) invisible(tmp) Deleted: branches/2.0/R/confint.fisherfit.R =================================================================== --- branches/2.0/R/confint.fisherfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/confint.fisherfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,6 +0,0 @@ -"confint.fisherfit" <- - function (object, parm, level=0.95, ...) -{ - if (!require(MASS)) stop("Needs packages MASS .. not found") - confint(profile(object), level=level, ...) -} Modified: branches/2.0/R/decostand.R =================================================================== --- branches/2.0/R/decostand.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/decostand.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,4 +1,4 @@ -"decostand" <- +`decostand` <- function (x, method, MARGIN, range.global, logbase = 2, na.rm = FALSE, ...) { wasDataFrame <- is.data.frame(x) @@ -34,7 +34,7 @@ if (missing(MARGIN)) MARGIN <- 1 tmp <- apply(x^2, MARGIN, sum, na.rm = na.rm) - tmp <- pmax(k, sqrt(tmp)) + tmp <- pmax(.Machine$double.eps, sqrt(tmp)) x <- sweep(x, MARGIN, tmp, "/") }, range = { if (missing(MARGIN)) Modified: branches/2.0/R/factorfit.R =================================================================== --- branches/2.0/R/factorfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/factorfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -41,7 +41,7 @@ var = double(1), PACKAGE = "vegan")$var tmp[i] <- 1 - invar/totvar } - pval.this <- (sum(tmp > r.this) + 1)/(permutations + 1) + pval.this <- (sum(tmp >= r.this) + 1)/(permutations + 1) pval <- c(pval, pval.this) } } Modified: branches/2.0/R/fisher.alpha.R =================================================================== --- branches/2.0/R/fisher.alpha.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/fisher.alpha.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,12 +1,12 @@ -"fisher.alpha" <- - function (x, MARGIN = 1, se = FALSE, ...) +`fisher.alpha` <- + function (x, MARGIN = 1, ...) { x <- as.matrix(x) if(ncol(x) == 1) x <- t(x) sol <- apply(x, MARGIN, fisherfit) out <- unlist(lapply(sol, function(x) x$estimate)) - if (se) { + if (FALSE) { out <- list(alpha = out) out$se <- unlist(lapply(sol, function(x) sqrt(diag(solve(x$hessian)))[1])) out$df.residual <- unlist(lapply(sol, df.residual)) Modified: branches/2.0/R/fisherfit.R =================================================================== --- branches/2.0/R/fisherfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/fisherfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,24 +1,49 @@ -"fisherfit" <- - function (x, ...) +## Fisher alpha is actually based only on the number of species S and +## number of individuals. + +`fisherfit` <- + function(x, ...) { - Dev.logseries <- function(n.r, p, N) { - r <- as.numeric(names(n.r)) - x <- N/(N + p) - logmu <- log(p) + log(x) * r - log(r) - lhood <- -sum(n.r * (logmu - log(n.r)) + 1) - p * log(1 - - x) - lhood + nr <- as.fisher(x) + S <- sum(nr) + N <- sum(x) + ## Solve 'x' (Fisher alpha). + d1fun <- function(x, S, N) x * log(1 + N/x) - S + ## We may need to bracket the interval + hi <- 50 + lo <- 1 + tries <- 0 + repeat { + sol <- try(uniroot(d1fun, c(lo, hi), S = S, N = N, ...), silent = TRUE) + if (inherits(sol, "try-error")) { + if(d1fun(hi, S, N) < 0) + hi <- 2*hi + if(d1fun(lo, S, N) > 0) + lo <- lo/2 + tries <- tries + 1 + } + else break + ## alpha can tend to +Inf: set root = NA etc. + if (tries > 200) { + sol <- list(root = NA, f.root = NA, iter = NA, init.it = NA, + estim.prec = NA) + break + } } - tmp <- as.rad(x) - N <- sum(x) - tmp <- tmp/N - p <- 1/sum(tmp^2) - n.r <- as.fisher(x) - LSeries <- nlm(Dev.logseries, n.r = n.r, p = p, N = N, - hessian = TRUE, ...) - LSeries$df.residual <- sum(x > 0) - 1 - LSeries$nuisance <- N/(N + LSeries$estimate) - LSeries$fisher <- n.r - class(LSeries) <- "fisherfit" - LSeries + ## 'extendInt' arg was added in R r63162 | maechler | 2013-07-03 + ## 11:47:22 +0300 (Wed, 03 Jul 2013). Latest release is R 3.0.2 of + ## 2013-09-25, but it still does not have the argument. In the + ## future we may switch to the following: + + ##sol <- uniroot(d1fun, c(1,50), extendInt = "yes", S = S, N = N, ...) + + nuisance <- N/(N + sol$root) + ## we used nlm() earlier, and the following output is compatible + out <- list(estimate = sol$root, hessian = NA, + iterations = sol$iter, df.residual = NA, + nuisance = nuisance, fisher = nr, + estim.prec = sol$estim.prec, + code = 2*is.na(sol$estim.prec) + 1) + class(out) <- "fisherfit" + out } Modified: branches/2.0/R/nestednodf.R =================================================================== --- branches/2.0/R/nestednodf.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/nestednodf.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -22,7 +22,7 @@ } nr <- NROW(comm) nc <- NCOL(comm) - fill <- sum(rfill)/length(comm) + fill <- sum(rfill)/prod(dim(comm)) N.paired.rows <- numeric(nr * (nr - 1)/2) N.paired.cols <- numeric(nc * (nc - 1)/2) counter <- 0 @@ -35,7 +35,7 @@ if (weighted) { second <- comm[j, ] N.paired.rows[counter] <- - sum(first - second > 0 & second > 0)/sum(second > 0) + sum(first - second >= 0 & second > 0)/sum(second > 0) } else { N.paired.rows[counter] <- @@ -53,7 +53,7 @@ if (weighted) { second <- comm[, j] N.paired.cols[counter] <- - sum(first - second > 0 & second > 0)/sum(second > 0) + sum(first - second >= 0 & second > 0)/sum(second > 0) } else { N.paired.cols[counter] <- Modified: branches/2.0/R/ordiArrowMul.R =================================================================== --- branches/2.0/R/ordiArrowMul.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/ordiArrowMul.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -5,7 +5,7 @@ { u <- par("usr") u <- u - rep(at, each = 2) - r <- c(range(x[,1]), range(x[,2])) + r <- c(range(x[,1], na.rm = TRUE), range(x[,2], na.rm = TRUE)) ## 'rev' takes care of reversed axes like xlim(1,-1) rev <- sign(diff(u))[-2] if (rev[1] < 0) Deleted: branches/2.0/R/plot.profile.fisherfit.R =================================================================== --- branches/2.0/R/plot.profile.fisherfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/plot.profile.fisherfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,16 +0,0 @@ -`plot.profile.fisherfit` <- - function (x, type = "l", ...) -{ - tmp <- attr(x, "original.fit") - est <- tmp$coefficients - se <- tmp$std.err - alpha <- x$alpha[, 1] - tau <- x$alpha[, 2] - sp <- spline(tau, alpha) - plot(sp$x, sp$y, type = type, xlab = "alpha", ylab = "tau", - ...) - abline(-est/se, 1/se, lty = 2) - abline(v = est, lty = 3) - abline(h = 0, lty = 3) - invisible() -} Modified: branches/2.0/R/plot.specaccum.R =================================================================== --- branches/2.0/R/plot.specaccum.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/plot.specaccum.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,17 +1,32 @@ `plot.specaccum` <- - function(x, add = FALSE, ci = 2, ci.type = c("bar","line","polygon"), - col = par("fg"), ci.col = col, ci.lty = 1, xlab, - ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) + function(x, add = FALSE, random = FALSE, ci = 2, + ci.type = c("bar","line","polygon"), col = par("fg"), ci.col = col, + ci.lty = 1, xlab, ylab = x$method, ylim, + xvar = c("sites", "individuals", "effort"), ...) { + if(random && x$method != "random") + stop("random = TRUE can be used only with method='random'") xvar <- match.arg(xvar) + ## adjust weights to number of sites + if (random && !is.null(x$weights) && xvar == "sites") { + n <- length(x$effort) + adj <- n/x$effort[n] + } else { + adj <- 1 + } xaxvar <- x[[xvar]] if (missing(xlab)) xlab <- paste(toupper(substring(xvar, 1, 1)), substring(xvar, 2), sep="") + if (random) + ci <- FALSE ci.type <- match.arg(ci.type) if (!add) { if (missing(ylim)) - ylim <- c(1, max(x$richness, x$richness + ci*x$sd)) + if (random) + ylim <- c(1, max(x$perm, na.rm = TRUE)) + else + ylim <- c(1, max(x$richness, x$richness + ci*x$sd, na.rm = TRUE)) plot(xaxvar, x$richness, xlab=xlab, ylab=ylab, ylim=ylim, type="n", ...) } @@ -25,6 +40,21 @@ c(x$richness - ci*x$sd, rev(x$richness + ci*x$sd)), col=ci.col, lty=ci.lty, ...) ) - lines(xaxvar, x$richness,col=col, ...) + if (random) { + if (is.null(x$weights)) { + for(i in seq_len(NCOL(x$perm))) + lines(xaxvar, x$perm[,i], col=col, ...) + } else { + for(i in seq_len(NCOL(x$perm))) + lines(x$weights[,i]*adj, x$perm[,i], col=col, ...) + } + } else + lines(xaxvar, x$richness,col=col, ...) invisible() } + +`lines.specaccum` <- + function(x, ...) +{ + plot(x, add = TRUE, ...) +} Modified: branches/2.0/R/print.cca.R =================================================================== --- branches/2.0/R/print.cca.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/print.cca.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -27,7 +27,7 @@ ## Remove "Proportion" if only one component if (is.null(x$CCA) && is.null(x$pCCA)) tbl <- tbl[,-2] - printCoefmat(tbl, digits = digits, na.print = "") + printCoefmat(tbl, digits = digits, na.print = "", zap.ind = 1:2) cat("Inertia is", x$inertia, "\n") if (!is.null(x$CCA$alias)) cat("Some constraints were aliased because they were collinear (redundant)\n") Modified: branches/2.0/R/print.fisherfit.R =================================================================== --- branches/2.0/R/print.fisherfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/print.fisherfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,12 +1,8 @@ -"print.fisherfit" <- +`print.fisherfit` <- function (x, ...) { cat("\nFisher log series model\n") - cat("No. of species:", sum(x$fisher), "\n\n") - out <- cbind(x$estimate, sqrt(diag(solve(x$hessian)))) - colnames(out) <- c("Estimate", "Std. Error") - rownames(out) <- "alpha" - printCoefmat(out) - cat("\n") + cat("No. of species:", sum(x$fisher), "\n") + cat("Fisher alpha: ", x$estimate, "\n\n") invisible(x) } Deleted: branches/2.0/R/profile.fisherfit.R =================================================================== --- branches/2.0/R/profile.fisherfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/profile.fisherfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,43 +0,0 @@ -"profile.fisherfit" <- - function (fitted, alpha = 0.01, maxsteps = 20, del = zmax/5, ...) -{ - Dev.logseries <- function(n.r, p, N) { - r <- as.numeric(names(n.r)) - x <- N/(N + p) - logmu <- log(p) + log(x) * r - log(r) - lhood <- -sum(n.r * (logmu - log(n.r)) + 1) - p * log(1 - - x) - lhood - } - par <- fitted$estimate - names(par) <- "alpha" - std.err <- sqrt(diag(solve(fitted$hessian))) - minll <- fitted$minimum - nr <- fitted$fisher - N <- sum(as.numeric(names(nr)) * nr) - zmax <- sqrt(qchisq(1 - alpha/2, 1)) - zi <- 0 - bi <- par - for (sgn in c(-1, 1)) { - step <- 0 - z <- 0 - b <- 0 - while ((step <- step + 1) < maxsteps && abs(z) < zmax) { - b <- par + sgn * step * del * std.err - fm <- Dev.logseries(nr, b, N) - zz <- 2 * (fm - minll) - if (zz > -0.001) - zz <- max(zz, 0) - else stop("profiling has found a better solution, so original fit had not converged") - z <- sgn * sqrt(zz) - bi <- c(bi, b) - zi <- c(zi, z) - } - } - si <- order(bi) - out <- list() - out$alpha <- data.frame(tau = zi[si], par.vals = bi[si]) - attr(out, "original.fit") <- list(coefficients = par, std.err = std.err) - class(out) <- c("profile.fisherfit", "profile.glm", "profile") - out -} Modified: branches/2.0/R/renyiaccum.R =================================================================== --- branches/2.0/R/renyiaccum.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/renyiaccum.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,6 +1,9 @@ `renyiaccum` <- -function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100, raw = FALSE, ...) -{ +function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100, + raw = FALSE, subset, ...) +{ + if (!missing(subset)) + x <- subset(x, subset) x <- as.matrix(x) n <- nrow(x) p <- ncol(x) Modified: branches/2.0/R/specaccum.R =================================================================== --- branches/2.0/R/specaccum.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/specaccum.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,7 +1,15 @@ `specaccum` <- function (comm, method = "exact", permutations = 100, conditioned=TRUE, - gamma="jack1", ...) + gamma="jack1", w = NULL, subset, ...) { + METHODS <- c("collector", "random", "exact", "rarefaction", "coleman") + method <- match.arg(method, METHODS) + if (!is.null(w) && !(method %in% c("random", "collector"))) + stop(gettextf("weights 'w' can be only used with methods 'random' and 'collector'")) + if (!missing(subset)) { + comm <- subset(comm, subset) + w <- subset(w, subset) + } x <- comm x <- as.matrix(x) x <- x[, colSums(x) > 0, drop=FALSE] @@ -15,22 +23,34 @@ accumulator <- function(x, ind) { rowSums(apply(x[ind, ], 2, cumsum) > 0) } - METHODS <- c("collector", "random", "exact", "rarefaction", "coleman") - method <- match.arg(method, METHODS) specaccum <- sdaccum <- sites <- perm <- NULL if (n == 1 && method != "rarefaction") message("No actual accumulation since only 1 site provided") switch(method, collector = { sites <- 1:n + xout <- weights <- cumsum(w) specaccum <- accumulator(x, sites) }, random = { perm <- array(dim = c(n, permutations)) + if (!is.null(w)) + weights <- array(dim = c(n, permutations)) for (i in 1:permutations) { - perm[, i] <- accumulator(x, sample(n)) + perm[, i] <- accumulator(x, ord <- sample(n)) + if(!is.null(w)) + weights[,i] <- cumsum(w[ord]) } sites <- 1:n - specaccum <- apply(perm, 1, mean) - sdaccum <- apply(perm, 1, sd) + if (is.null(w)) { + specaccum <- apply(perm, 1, mean) + sdaccum <- apply(perm, 1, sd) + } else { + sumw <- sum(w) + xout <- seq(sumw/n, sumw, length.out = n) + intx <- sapply(seq_len(n), function(i) + approx(weights[,i], perm[,i], xout = xout)$y) + specaccum <- apply(intx, 1, mean) + sdaccum <- apply(intx, 1, sd) + } }, exact = { freq <- colSums(x > 0) freq <- freq[freq > 0] @@ -87,6 +107,10 @@ }) out <- list(call = match.call(), method = method, sites = sites, richness = specaccum, sd = sdaccum, perm = perm) + if (!is.null(w)) { + out$weights <- weights + out$effort <- xout + } if (method == "rarefaction") out$individuals <- ind class(out) <- "specaccum" Modified: branches/2.0/R/tsallisaccum.R =================================================================== --- branches/2.0/R/tsallisaccum.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/tsallisaccum.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -1,6 +1,9 @@ tsallisaccum <- -function (x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE, ...) +function (x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE, + subset, ...) { + if (!missing(subset)) + x <- subset(x, subset) x <- as.matrix(x) n <- nrow(x) p <- ncol(x) Modified: branches/2.0/R/vectorfit.R =================================================================== --- branches/2.0/R/vectorfit.R 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/R/vectorfit.R 2013-12-05 11:50:52 UTC (rev 2807) @@ -18,6 +18,7 @@ H <- qr.fitted(Q, Pw) heads <- qr.coef(Q, Pw) r <- diag(cor(H, Pw)^2) + r[is.na(r)] <- 0 heads <- decostand(heads, "norm", 2) heads <- t(heads) if (is.null(colnames(X))) Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/inst/ChangeLog 2013-12-05 11:50:52 UTC (rev 2807) @@ -4,8 +4,17 @@ Version 2.0-10 (opened December 5, 2013) + * merge 2641: subset in renyi/spec/tsallisaccum. + * merge 2630,1,2: fisherfit new algo and delete profile & confint. + * merge 2628,9: plot vectorfit *should* work with constant + (non-variable) vectors: partial conflict, needs checking. + * merge 2627: zap zeros in print.cca. + * merge 2626: nestednodf fill and consinstency in quantitative + data. * merge 2527: adapt permutest.betadisper to the CRAN release of permute 0.8-0. + * merge 2451, 2454, 2455, 2465: weighted specaccum. + * conflicts (not applied): r2625 (oecosimu), 2638 (oecosimu.Rd) Version 2.0-9 (released September 25, 2013) Modified: branches/2.0/man/diversity.Rd =================================================================== --- branches/2.0/man/diversity.Rd 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/man/diversity.Rd 2013-12-05 11:50:52 UTC (rev 2807) @@ -20,7 +20,7 @@ drarefy(x, sample) rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species", label = TRUE, ...) -fisher.alpha(x, MARGIN = 1, se = FALSE, ...) +fisher.alpha(x, MARGIN = 1, ...) specnumber(x, groups, MARGIN = 1) } @@ -86,11 +86,7 @@ \code{fisher.alpha} estimates the \eqn{\alpha} parameter of Fisher's logarithmic series (see \code{\link{fisherfit}}). The estimation is possible only for genuine - counts of individuals. The function can optionally return standard - errors of \eqn{\alpha}. These should be regarded only as rough - indicators of the accuracy: the confidence limits of \eqn{\alpha} are - strongly non-symmetric and the standard errors cannot be used in - Normal inference. + counts of individuals. Function \code{specnumber} finds the number of species. With \code{MARGIN = 2}, it finds frequencies of species. If \code{groups} Modified: branches/2.0/man/fisherfit.Rd =================================================================== --- branches/2.0/man/fisherfit.Rd 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/man/fisherfit.Rd 2013-12-05 11:50:52 UTC (rev 2807) @@ -2,9 +2,6 @@ \alias{fisherfit} \alias{as.fisher} \alias{plot.fisherfit} -\alias{profile.fisherfit} -\alias{confint.fisherfit} -\alias{plot.profile.fisherfit} \alias{prestonfit} \alias{prestondistr} \alias{as.preston} @@ -25,9 +22,6 @@ } \usage{ fisherfit(x, ...) -\method{confint}{fisherfit}(object, parm, level = 0.95, ...) -\method{profile}{fisherfit}(fitted, alpha = 0.01, maxsteps = 20, del = zmax/5, - ...) prestonfit(x, tiesplit = TRUE, ...) prestondistr(x, truncate = -1, ...) \method{plot}{prestonfit}(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue", @@ -45,12 +39,6 @@ \arguments{ \item{x}{Community data vector for fitting functions or their result object for \code{plot} functions.} - \item{object, fitted}{Fitted model.} - \item{parm}{Not used.} - \item{level}{The confidence level required.} - \item{alpha}{The extend of profiling as significance.} - \item{maxsteps}{Maximum number of steps in profiling.} - \item{del}{Step length.} \item{tiesplit}{Split frequencies \eqn{1, 2, 4, 8} etc between adjacent octaves.} \item{truncate}{Truncation point for log-Normal model, in log2 @@ -73,9 +61,8 @@ \details{ In Fisher's logarithmic series the expected number of species \eqn{f} with \eqn{n} observed individuals is - \eqn{f_n = \alpha x^n / n} (Fisher et al. 1943). The estimation - follows Kempton & Taylor (1974) and uses function - \code{\link{nlm}}. The estimation is possible only for genuine + \eqn{f_n = \alpha x^n / n} (Fisher et al. 1943). + The estimation is possible only for genuine counts of individuals. The parameter \eqn{\alpha} is used as a diversity index, and \eqn{\alpha} and its standard error can be estimated with a separate function \code{\link{fisher.alpha}}. The @@ -84,20 +71,6 @@ function \code{as.fisher} transforms abundance data into Fisher frequency table. - Function \code{fisherfit} estimates the standard error of - \eqn{\alpha}{alpha}. However, the confidence limits cannot be directly - estimated from the standard errors, but you should use function - \code{confint} based on profile likelihood. Function \code{confint} - uses function \code{\link[MASS]{confint.glm}} of the \pkg{MASS} - package, using \code{profile.fisherfit} for the profile - likelihood. Function \code{profile.fisherfit} follows - \code{\link[MASS]{profile.glm}} and finds the \eqn{\tau}{tau} parameter or - signed square root of two times log-Likelihood profile. The profile can - be inspected with a \code{plot} function which shows the \eqn{\tau}{tau} - and a dotted line corresponding to the Normal assumption: if standard - errors can be directly used in Normal inference these two lines - are similar. - Preston (1948) was not satisfied with Fisher's model which seemed to imply infinite species richness, and postulated that rare species is a diminishing class and most species are in the middle of frequency @@ -162,11 +135,8 @@ \code{method}. Function \code{prestondistr} omits the entry \code{fitted}. The function \code{fisherfit} returns the result of \code{\link{nlm}}, where item \code{estimate} is \eqn{\alpha}. The - result object is amended with the following items: - \item{df.residuals}{Residual degrees of freedom.} - \item{nuisance}{Parameter \eqn{x}.} \item{fisher}{Observed data - from \code{as.fisher}.} - + result object is amended with the \code{nuisance} parameter and item + \code{fisher} for the observed data from \code{as.fisher} } \references{ Fisher, R.A., Corbet, A.S. & Williams, C.B. (1943). The relation @@ -174,10 +144,6 @@ random sample of animal population. \emph{Journal of Animal Ecology} 12: 42--58. - Kempton, R.A. & Taylor, L.R. (1974). Log-series and log-normal - parameters as diversity discriminators for - Lepidoptera. \emph{Journal of Animal Ecology} 43: 381--399. - Preston, F.W. (1948) The commonness and rarity of species. \emph{Ecology} 29, 254--283. @@ -186,7 +152,7 @@ distribution. \emph{Journal of Animal Ecology} 74, 409--422. } -\author{Bob O'Hara (\code{fisherfit}) and Jari Oksanen. } +\author{Bob O'Hara and Jari Oksanen. } \seealso{\code{\link{diversity}}, \code{\link{fisher.alpha}}, \code{\link{radfit}}, \code{\link{specpool}}. Function @@ -200,8 +166,6 @@ data(BCI) mod <- fisherfit(BCI[5,]) mod -plot(profile(mod)) -confint(mod) # prestonfit seems to need large samples mod.oct <- prestonfit(colSums(BCI)) mod.ll <- prestondistr(colSums(BCI)) Modified: branches/2.0/man/renyi.Rd =================================================================== --- branches/2.0/man/renyi.Rd 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/man/renyi.Rd 2013-12-05 11:50:52 UTC (rev 2807) @@ -14,16 +14,17 @@ \code{renyiaccum} finds these statistics with accumulating sites. } \usage{ -renyi(x, scales = c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf), hill = FALSE) +renyi(x, scales = c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf), + hill = FALSE) \method{plot}{renyi}(x, ...) renyiaccum(x, scales = c(0, 0.5, 1, 2, 4, Inf), permutations = 100, - raw = FALSE, ...) -\method{plot}{renyiaccum} (x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", + raw = FALSE, subset, ...) +\method{plot}{renyiaccum}(x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", ...) -\method{persp}{renyiaccum} (x, theta = 220, col = heat.colors(100), zlim, ...) +\method{persp}{renyiaccum}(x, theta = 220, col = heat.colors(100), zlim, ...) rgl.renyiaccum(x, rgl.height = 0.2, ...) } -%- maybe also 'usage' for other objects documented here. + \arguments{ \item{x}{Community data matrix or plotting object. } \item{scales}{Scales of \enc{R?nyi}{Renyi} diversity.} @@ -33,6 +34,8 @@ \item{raw}{if \code{FALSE} then return summary statistics of permutations, and if \code{TRUE} then returns the individual permutations.} + \item{subset}{logical expression indicating sites (rows) to keep: missing + values are taken as \code{FALSE}.} \item{what}{Items to be plotted.} \item{type}{Type of plot, where \code{type = "l"} means lines.} \item{theta}{Angle defining the viewing direction (azimuthal) in Modified: branches/2.0/man/specaccum.Rd =================================================================== --- branches/2.0/man/specaccum.Rd 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/man/specaccum.Rd 2013-12-05 11:50:52 UTC (rev 2807) @@ -17,10 +17,11 @@ } \usage{ specaccum(comm, method = "exact", permutations = 100, - conditioned =TRUE, gamma = "jack1", ...) -\method{plot}{specaccum}(x, add = FALSE, ci = 2, ci.type = c("bar", "line", "polygon"), - col = par("fg"), ci.col = col, ci.lty = 1, xlab, - ylab = x$method, ylim, xvar = c("sites", "individuals"), ...) + conditioned =TRUE, gamma = "jack1", w = NULL, subset, ...) +\method{plot}{specaccum}(x, add = FALSE, random = FALSE, ci = 2, + ci.type = c("bar", "line", "polygon"), col = par("fg"), ci.col = col, + ci.lty = 1, xlab, ylab = x$method, ylim, + xvar = c("sites", "individuals", "effort"), ...) \method{boxplot}{specaccum}(x, add = FALSE, ...) fitspecaccum(object, model, method = "random", ...) \method{plot}{fitspecaccum}(x, col = par("fg"), lty = 1, xlab = "Sites", @@ -43,9 +44,14 @@ \item{conditioned}{ Estimation of standard deviation is conditional on the empirical dataset for the exact SAC} \item{gamma}{Method for estimating the total extrapolated number of species in the - survey area by function \code{\link{specpool}}} + survey area by function \code{\link{specpool}}} + \item{w}{Weights giving the sampling effort (an experimental feature + that may be removed).} + \item{subset}{logical expression indicating sites (rows) to keep: missing + values are taken as \code{FALSE}.} \item{x}{A \code{specaccum} result object} \item{add}{Add to an existing graph.} + \item{random}{\dots} \item{ci}{Multiplier used to get confidence intervals from standard deviation (standard error of the estimate). Value \code{ci = 0} suppresses drawing confidence intervals.} Modified: branches/2.0/man/tsallis.Rd =================================================================== --- branches/2.0/man/tsallis.Rd 2013-12-05 11:14:49 UTC (rev 2806) +++ branches/2.0/man/tsallis.Rd 2013-12-05 11:50:52 UTC (rev 2807) @@ -9,65 +9,112 @@ } \usage{ tsallis(x, scales = seq(0, 2, 0.2), norm = FALSE, hill = FALSE) -tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100, raw = FALSE, ...) +tsallisaccum(x, scales = seq(0, 2, 0.2), permutations = 100, + raw = FALSE, subset, ...) \method{persp}{tsallisaccum}(x, theta = 220, phi = 15, col = heat.colors(100), zlim, ...) } -%- maybe also 'usage' for other objects documented here. + \arguments{ \item{x}{Community data matrix or plotting object. } \item{scales}{Scales of Tsallis diversity.} - \item{norm}{Logical, if \code{TRUE} diversity values are normalized by their maximum (diversity value at equiprobability conditions).} + + \item{norm}{Logical, if \code{TRUE} diversity values are normalized + by their maximum (diversity value at equiprobability conditions).} + \item{hill}{Calculate Hill numbers.} - \item{permutations}{Number of random permutations in accumulating sites.} - \item{raw}{If \code{FALSE} then return summary statistics of permutations, and if TRUE then returns the individual permutations.} - \item{theta, phi}{angles defining the viewing direction. \code{theta} gives the azimuthal direction and \code{phi} the colatitude.} - \item{col}{Colours used for surface.} - \item{zlim}{Limits of vertical axis.} - \item{\dots}{Other arguments which are passed to \code{tsallis} and to graphical functions.} + + \item{permutations}{Number of random permutations in accumulating + sites.} -} -\details{ -The Tsallis diversity (also equivalent to Patil and Taillie diversity) is a one-parametric generalised entropy function, defined as: + \item{raw}{If \code{FALSE} then return summary statistics of + permutations, and if TRUE then returns the individual + permutations.} + \item{subset}{logical expression indicating sites (rows) to keep: + missing values are taken as \code{FALSE}.} + + \item{theta, phi}{angles defining the viewing + direction. \code{theta} gives the azimuthal direction and + \code{phi} the colatitude.} + + \item{col}{Colours used for surface.} \item{zlim}{Limits of + vertical axis.} + + \item{\dots}{Other arguments which are passed to \code{tsallis} and + to graphical functions.} + +} + +\details{ The Tsallis diversity (also equivalent to Patil and Taillie +diversity) is a one-parametric generalised entropy function, defined +as: + \deqn{H_q = \frac{1}{q-1} (1-\sum_{i=1}^S p_i^q)}{H.q = 1/(q-1)(1-sum(p^q))} -where \eqn{q} is a scale parameter, \eqn{S} the number of species in the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it gives the number of species minus one, as \eqn{q} tends to 1 this gives Shannon diversity, for \eqn{q=2} this gives the Simpson index (see function \code{\link{diversity}}). +where \eqn{q} is a scale parameter, \eqn{S} the number of species in +the sample (Tsallis 1988, Tothmeresz 1995). This diversity is concave +for all \eqn{q>0}, but non-additive (Keylock 2005). For \eqn{q=0} it +gives the number of species minus one, as \eqn{q} tends to 1 this +gives Shannon diversity, for \eqn{q=2} this gives the Simpson index +(see function \code{\link{diversity}}). -If \code{norm = TRUE}, \code{tsallis} gives values normalized by the maximum: +If \code{norm = TRUE}, \code{tsallis} gives values normalized by the +maximum: \deqn{H_q(max) = \frac{S^{1-q}-1}{1-q}}{H.q(max) = (S^(1-q)-1)/(1-q)} -where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum is defined as \eqn{ln(S)}. +where \eqn{S} is the number of species. As \eqn{q} tends to 1, maximum [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2807 From noreply at r-forge.r-project.org Thu Dec 5 13:34:47 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 5 Dec 2013 13:34:47 +0100 (CET) Subject: [Vegan-commits] r2808 - in branches/2.0: R inst man Message-ID: <20131205123447.2B856186798@r-forge.r-project.org> Author: jarioksa Date: 2013-12-05 13:34:46 +0100 (Thu, 05 Dec 2013) New Revision: 2808 Modified: branches/2.0/R/plot.renyiaccum.R branches/2.0/R/print.oecosimu.R branches/2.0/R/renyiaccum.R branches/2.0/inst/ChangeLog branches/2.0/man/nobs.adonis.Rd branches/2.0/man/renyi.Rd branches/2.0/man/screeplot.cca.Rd Log: merge revs in range 2678 to 2713 to 2.0-10 Modified: branches/2.0/R/plot.renyiaccum.R =================================================================== --- branches/2.0/R/plot.renyiaccum.R 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/R/plot.renyiaccum.R 2013-12-05 12:34:46 UTC (rev 2808) @@ -1,12 +1,15 @@ `plot.renyiaccum` <- -function (x, what=c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", ...) +function (x, what=c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"), + type = "l", ...) { - if (any(what %in% colnames(x[,1,]))) - x <- x[,,what] + what <- what[what %in% dimnames(x)[[3]]] + if (any(what %in% dimnames(x)[[3]])) + x <- x[,,what, drop = FALSE] dm <- dim(x) - lin <- rep(colnames(x[,1,]), each=dm[1]*dm[2]) + dnam <- dimnames(x) + lin <- rep(dnam[[3]], each=dm[1]*dm[2]) Sites <- rep(1:dm[1], len=prod(dm)) - alp <- factor(rownames(x[1,,]), levels=rownames(x[1,,])) + alp <- factor(dnam[[2]], levels=dnam[[2]]) alpha <- rep(rep(alp, each=dm[1]), len=prod(dm)) Diversity <- as.vector(x) xyplot(Diversity ~ Sites | alpha, groups=lin, type=type, ...) Modified: branches/2.0/R/print.oecosimu.R =================================================================== --- branches/2.0/R/print.oecosimu.R 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/R/print.oecosimu.R 2013-12-05 12:34:46 UTC (rev 2808) @@ -28,8 +28,8 @@ } probs <- switch(x$oecosimu$alternative, two.sided = c(0.025, 0.5, 0.975), - less = c(0, 0.5, 0.95), - greater = c(0.05, 0.5, 1)) + greater = c(0, 0.5, 0.95), + less = c(0.05, 0.5, 1)) 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), Modified: branches/2.0/R/renyiaccum.R =================================================================== --- branches/2.0/R/renyiaccum.R 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/R/renyiaccum.R 2013-12-05 12:34:46 UTC (rev 2808) @@ -1,6 +1,6 @@ `renyiaccum` <- function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100, - raw = FALSE, subset, ...) + raw = FALSE, collector = FALSE, subset, ...) { if (!missing(subset)) x <- subset(x, subset) @@ -20,12 +20,16 @@ result[,,k] <- as.matrix(renyi((apply(x[sample(n),],2,cumsum)), scales=scales, ...)) } + if (raw) + collector <- FALSE + if (collector) + ref <- as.matrix(renyi(apply(x, 2, cumsum), scales = scales, ...)) if (raw) { if (m==1) { result <- result[,1,] } }else{ - tmp <- array(dim=c(n,m,6)) + tmp <- array(dim=c(n,m,6 + as.numeric(collector))) for (i in 1:n) { for (j in 1:m) { tmp[i,j,1] <- mean(result[i,j,1:permutations]) @@ -34,12 +38,14 @@ tmp[i,j,4] <- max(result[i,j,1:permutations]) tmp[i,j,5] <- quantile(result[i,j,1:permutations],0.025) tmp[i,j,6] <- quantile(result[i,j,1:permutations],0.975) + if (collector) + tmp[i,j,7] <- ref[i,j] } } result <- tmp dimnames(result) <- list(pooled.sites=c(1:n), scale=scales, - c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975")) + c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975", if (collector) "Collector")) } class(result) <- c("renyiaccum", class(result)) result Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/inst/ChangeLog 2013-12-05 12:34:46 UTC (rev 2808) @@ -4,6 +4,11 @@ Version 2.0-10 (opened December 5, 2013) + * merge 2713 man/: remove references to very old R versions in man + files (R/ part of this rev not applied) + * merge 2708: adapt quantilesto test direction. + * merge 2679: add collector curve to renyiaccum. + * merge 2678: renyiaccum can plot one scale. * merge 2641: subset in renyi/spec/tsallisaccum. * merge 2630,1,2: fisherfit new algo and delete profile & confint. * merge 2628,9: plot vectorfit *should* work with constant Modified: branches/2.0/man/nobs.adonis.Rd =================================================================== --- branches/2.0/man/nobs.adonis.Rd 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/man/nobs.adonis.Rd 2013-12-05 12:34:46 UTC (rev 2808) @@ -31,14 +31,15 @@ } } -\details{ Function \code{nobs} is generic in \R version 2.13.0, and +\details{ Function \code{nobs} is generic in \R, and \pkg{vegan} provides methods for objects from \code{\link{adonis}}, \code{\link{betadisper}}, \code{\link{cca}} and other related methods, \code{\link{CCorA}}, \code{\link{decorana}}, \code{\link{isomap}}, \code{\link{metaMDS}}, \code{\link{pcnm}}, \code{\link{procrustes}}, \code{\link{radfit}}, - \code{\link{varpart}} and \code{\link{wcmdscale}}. } \value{ A - single number, normally an integer, giving the number of + \code{\link{varpart}} and \code{\link{wcmdscale}}. } + +\value{ A single number, normally an integer, giving the number of observations. } \author{ Modified: branches/2.0/man/renyi.Rd =================================================================== --- branches/2.0/man/renyi.Rd 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/man/renyi.Rd 2013-12-05 12:34:46 UTC (rev 2808) @@ -18,8 +18,9 @@ hill = FALSE) \method{plot}{renyi}(x, ...) renyiaccum(x, scales = c(0, 0.5, 1, 2, 4, Inf), permutations = 100, - raw = FALSE, subset, ...) -\method{plot}{renyiaccum}(x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", + raw = FALSE, collector = FALSE, subset, ...) +\method{plot}{renyiaccum}(x, what = c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"), + type = "l", ...) \method{persp}{renyiaccum}(x, theta = 220, col = heat.colors(100), zlim, ...) rgl.renyiaccum(x, rgl.height = 0.2, ...) @@ -34,6 +35,10 @@ \item{raw}{if \code{FALSE} then return summary statistics of permutations, and if \code{TRUE} then returns the individual permutations.} + \item{collector}{Accumulate the diversities in the order the sites are + in the data set, and the collector curve can be plotted against + summary of permutations. The argument is ignored if \code{raw = TRUE}. + } \item{subset}{logical expression indicating sites (rows) to keep: missing values are taken as \code{FALSE}.} \item{what}{Items to be plotted.} Modified: branches/2.0/man/screeplot.cca.Rd =================================================================== --- branches/2.0/man/screeplot.cca.Rd 2013-12-05 11:50:52 UTC (rev 2807) +++ branches/2.0/man/screeplot.cca.Rd 2013-12-05 12:34:46 UTC (rev 2808) @@ -116,10 +116,7 @@ Legendre, P. and Legendre, L. (2012) \emph{Numerical Ecology}. 3rd English ed. Elsevier. } -\note{Function \code{screeplot} is generic from \code{R} version - 2.5.0. In these versions you can use plain \code{screeplot} command - without suffices \code{cca}, \code{prcomp} etc. - } + \author{Gavin L. Simpson} \seealso{ \code{\link{cca}}, \code{\link{decorana}}, \code{\link{princomp}} and From noreply at r-forge.r-project.org Fri Dec 6 19:37:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 6 Dec 2013 19:37:41 +0100 (CET) Subject: [Vegan-commits] r2809 - in pkg/vegan: R inst Message-ID: <20131206183741.CD8AF186937@r-forge.r-project.org> Author: jarioksa Date: 2013-12-06 19:37:41 +0100 (Fri, 06 Dec 2013) New Revision: 2809 Modified: pkg/vegan/R/envfit.default.R pkg/vegan/inst/ChangeLog Log: envift does not choke on character variables but ignores them (with a warning) Modified: pkg/vegan/R/envfit.default.R =================================================================== --- pkg/vegan/R/envfit.default.R 2013-12-05 12:34:46 UTC (rev 2808) +++ pkg/vegan/R/envfit.default.R 2013-12-06 18:37:41 UTC (rev 2809) @@ -1,4 +1,4 @@ -"envfit.default" <- +`envfit.default` <- function (ord, env, permutations = 999, strata, choices = c(1, 2), display = "sites", w = weights(ord), na.rm = FALSE, ...) { @@ -32,9 +32,13 @@ } if (is.data.frame(env)) { facts <- sapply(env, is.factor) + vects <- sapply(env, is.numeric) + if (!all(facts | vects)) + warning("the following variables are ignored because they are neither numeric nor factors:\n", + paste(colnames(env)[!(facts | vects)], collapse=", ")) if (sum(facts)) { # have factors Pfac <- env[, facts, drop = FALSE] - P <- env[, !facts, drop = FALSE] + P <- env[, vects, drop = FALSE] if (length(P)) { # also have vectors vectors <- vectorfit(X, P, permutations, strata, choices, w = w, ...) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-05 12:34:46 UTC (rev 2808) +++ pkg/vegan/inst/ChangeLog 2013-12-06 18:37:41 UTC (rev 2809) @@ -20,6 +20,15 @@ adapted to new anova.cca and this brought along similar changes in API. + * envfit: function assumed that environmental variables are either + factors or numeric, and choked if they were neither but, say, + character strings. Now the function ignores variables which are + neither factors nor numeric (with a warning). This is one possible + reason for problems reported in + https://stat.ethz.ch/pipermail/r-sig-ecology/2013-December/004217.html, + although the reported case is irreproducible and we cannot be + sure. + * tests for cca/rda/capscale: commented out test that failed with the anova.cca. Known issue was that 'by = "term"' and 'by = "axis"' stop with error with missing data. This was designed and From noreply at r-forge.r-project.org Sun Dec 8 08:36:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 8 Dec 2013 08:36:18 +0100 (CET) Subject: [Vegan-commits] r2810 - branches/2.0/R pkg/vegan/R pkg/vegan/inst Message-ID: <20131208073619.36FD9186901@r-forge.r-project.org> Author: jarioksa Date: 2013-12-08 08:36:14 +0100 (Sun, 08 Dec 2013) New Revision: 2810 Modified: branches/2.0/R/envfit.default.R pkg/vegan/R/envfit.default.R pkg/vegan/R/factorfit.R pkg/vegan/R/vectorfit.R pkg/vegan/inst/ChangeLog Log: cleaner handling of all non-numeric variables as factors in envfit Modified: branches/2.0/R/envfit.default.R =================================================================== --- branches/2.0/R/envfit.default.R 2013-12-06 18:37:41 UTC (rev 2809) +++ branches/2.0/R/envfit.default.R 2013-12-08 07:36:14 UTC (rev 2810) @@ -1,4 +1,4 @@ -"envfit.default" <- +`envfit.default` <- function (ord, env, permutations = 999, strata, choices = c(1, 2), display = "sites", w = weights(ord), na.rm = FALSE, ...) { @@ -17,10 +17,14 @@ na.action <- structure(seq_along(keep)[!keep], class="omit") } if (is.data.frame(env)) { - facts <- unlist(lapply(env, is.factor)) - if (sum(facts)) { + facts <- sapply(env, is.factor) + vects <- sapply(env, is.numeric) + if (!all(facts | vects)) + warning("the following variables are ignored because they are neither numeric nor factors:\n", + paste(colnames(env)[!(facts | vects)], collapse=", ")) + if (sum(facts)) { # have factors Pfac <- env[, facts, drop = FALSE] - P <- env[, !facts, drop = FALSE] + P <- env[, vects, drop = FALSE] if (length(P)) { if (permutations) { if (!exists(".Random.seed", envir = .GlobalEnv, Modified: pkg/vegan/R/envfit.default.R =================================================================== --- pkg/vegan/R/envfit.default.R 2013-12-06 18:37:41 UTC (rev 2809) +++ pkg/vegan/R/envfit.default.R 2013-12-08 07:36:14 UTC (rev 2810) @@ -31,13 +31,9 @@ ncol(permat), nr)) } if (is.data.frame(env)) { - facts <- sapply(env, is.factor) vects <- sapply(env, is.numeric) - if (!all(facts | vects)) - warning("the following variables are ignored because they are neither numeric nor factors:\n", - paste(colnames(env)[!(facts | vects)], collapse=", ")) - if (sum(facts)) { # have factors - Pfac <- env[, facts, drop = FALSE] + if (any(!vects)) { # have factors + Pfac <- env[, !vects, drop = FALSE] P <- env[, vects, drop = FALSE] if (length(P)) { # also have vectors vectors <- vectorfit(X, P, permutations, strata, Modified: pkg/vegan/R/factorfit.R =================================================================== --- pkg/vegan/R/factorfit.R 2013-12-06 18:37:41 UTC (rev 2809) +++ pkg/vegan/R/factorfit.R 2013-12-08 07:36:14 UTC (rev 2810) @@ -2,9 +2,13 @@ function (X, P, permutations = 0, strata, w, ...) { P <- as.data.frame(P) + ## Check that all variables are factors, and coerce if necessary + if(any(!sapply(P, is.factor))) + P <- data.frame(lapply(P, function(x) + if (is.factor(x)) x else factor(x))) P <- droplevels(P) ## make sure only the used levels are present if (any(!sapply(P, is.factor))) - stop("All fitted variables must be factors") + stop("All non-numeric variables must be factors") NR <- nrow(X) NC <- ncol(X) NF <- ncol(P) Modified: pkg/vegan/R/vectorfit.R =================================================================== --- pkg/vegan/R/vectorfit.R 2013-12-06 18:37:41 UTC (rev 2809) +++ pkg/vegan/R/vectorfit.R 2013-12-08 07:36:14 UTC (rev 2810) @@ -54,7 +54,7 @@ ## permutations are the matrix columns and variables are rows if (!is.matrix(permstore)) permstore <- matrix(permstore, ncol=permutations) - permstore <- sweep(permstore, 1, r, ">") + permstore <- sweep(permstore, 1, r, ">=") validn <- rowSums(is.finite(permstore)) pvals <- (rowSums(permstore, na.rm = TRUE) + 1)/(validn + 1) } Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-06 18:37:41 UTC (rev 2809) +++ pkg/vegan/inst/ChangeLog 2013-12-08 07:36:14 UTC (rev 2810) @@ -22,13 +22,15 @@ * envfit: function assumed that environmental variables are either factors or numeric, and choked if they were neither but, say, - character strings. Now the function ignores variables which are - neither factors nor numeric (with a warning). This is one possible - reason for problems reported in + character strings. Now the function tries to coerce all + non-numeric variables into factors, including character strings + and logical. This is one possible reason for problems reported in https://stat.ethz.ch/pipermail/r-sig-ecology/2013-December/004217.html, although the reported case is irreproducible and we cannot be - sure. + sure. Also fixed handling of tied values in assessing the P-values + in vectorfit. + * tests for cca/rda/capscale: commented out test that failed with the anova.cca. Known issue was that 'by = "term"' and 'by = "axis"' stop with error with missing data. This was designed and From noreply at r-forge.r-project.org Sun Dec 8 08:44:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 8 Dec 2013 08:44:19 +0100 (CET) Subject: [Vegan-commits] r2811 - in branches/2.0: R inst Message-ID: <20131208074420.580771848F4@r-forge.r-project.org> Author: jarioksa Date: 2013-12-08 08:44:18 +0100 (Sun, 08 Dec 2013) New Revision: 2811 Modified: branches/2.0/R/envfit.default.R branches/2.0/R/factorfit.R branches/2.0/R/vectorfit.R branches/2.0/inst/ChangeLog Log: merge 2810 to vegan 2.0-10 (2809 escaped in previous commit) Modified: branches/2.0/R/envfit.default.R =================================================================== --- branches/2.0/R/envfit.default.R 2013-12-08 07:36:14 UTC (rev 2810) +++ branches/2.0/R/envfit.default.R 2013-12-08 07:44:18 UTC (rev 2811) @@ -17,13 +17,9 @@ na.action <- structure(seq_along(keep)[!keep], class="omit") } if (is.data.frame(env)) { - facts <- sapply(env, is.factor) vects <- sapply(env, is.numeric) - if (!all(facts | vects)) - warning("the following variables are ignored because they are neither numeric nor factors:\n", - paste(colnames(env)[!(facts | vects)], collapse=", ")) - if (sum(facts)) { # have factors - Pfac <- env[, facts, drop = FALSE] + if (any(!vects)) { # have factors + Pfac <- env[, !vects, drop = FALSE] P <- env[, vects, drop = FALSE] if (length(P)) { if (permutations) { Modified: branches/2.0/R/factorfit.R =================================================================== --- branches/2.0/R/factorfit.R 2013-12-08 07:36:14 UTC (rev 2810) +++ branches/2.0/R/factorfit.R 2013-12-08 07:44:18 UTC (rev 2811) @@ -2,9 +2,13 @@ function (X, P, permutations = 0, strata, w, ...) { P <- as.data.frame(P) + ## Check that all variables are factors, and coerce if necessary + if(any(!sapply(P, is.factor))) + P <- data.frame(lapply(P, function(x) + if (is.factor(x)) x else factor(x))) P <- droplevels(P) ## make sure only the used levels are present if (any(!sapply(P, is.factor))) - stop("All fitted variables must be factors") + stop("All non-numeric variables must be factors") NR <- nrow(X) NC <- ncol(X) NF <- ncol(P) Modified: branches/2.0/R/vectorfit.R =================================================================== --- branches/2.0/R/vectorfit.R 2013-12-08 07:36:14 UTC (rev 2810) +++ branches/2.0/R/vectorfit.R 2013-12-08 07:44:18 UTC (rev 2811) @@ -37,7 +37,7 @@ Hperm <- qr.fitted(Q, take) permstore[i, ] <- diag(cor(Hperm, take))^2 } - permstore <- sweep(permstore, 2, r, ">") + permstore <- sweep(permstore, 2, r, ">=") pvals <- (apply(permstore, 2, sum) + 1)/(permutations + 1) } else pvals <- NULL Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-08 07:36:14 UTC (rev 2810) +++ branches/2.0/inst/ChangeLog 2013-12-08 07:44:18 UTC (rev 2811) @@ -3,7 +3,9 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ Version 2.0-10 (opened December 5, 2013) - + + * merge 2809,2810: treat all non-numeric variables as factors + inenvfit. * merge 2713 man/: remove references to very old R versions in man files (R/ part of this rev not applied) * merge 2708: adapt quantilesto test direction. From noreply at r-forge.r-project.org Sun Dec 8 16:19:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 8 Dec 2013 16:19:46 +0100 (CET) Subject: [Vegan-commits] r2812 - branches/2.0/inst www Message-ID: <20131208151946.619F21868A4@r-forge.r-project.org> Author: jarioksa Date: 2013-12-08 16:19:45 +0100 (Sun, 08 Dec 2013) New Revision: 2812 Modified: branches/2.0/inst/NEWS.Rd www/NEWS.html Log: NEWS about 2.0-10 Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-12-08 07:44:18 UTC (rev 2811) +++ branches/2.0/inst/NEWS.Rd 2013-12-08 15:19:45 UTC (rev 2812) @@ -2,6 +2,80 @@ \title{vegan News} \encoding{UTF-8} +\section{Changes in version 2.0-10}{ + + \subsection{GENERAL}{ + \itemize{ + + \item This version is adapted to the changes in \pkg{permute} + package version 0.8-0 and no more triggers NOTEs in package + checks. This release may be the last of the 2.0 series, and the + next \pkg{vegan} release is scheduled to be a major release with + newly designed \code{oecosimu} and community pattern simulation, + support for parallel processing, and full support of the + \pkg{permute} package. If you are interested in these + developments, you may try the development versions of + \pkg{vegan} in + \href{http://r-forge.r-project.org/projects/vegan/}{R-Forge} or + \href{https://github.com/jarioksa/vegan}{GitHub} and report the + problems and user experience to us. } } % end general + + \subsection{BUG FIXES}{ + + \itemize{ + + \item \code{envfit} function assumed that all external variables + were either numeric or factors, and failed if they were, say, + character strings. Now only numeric variables are taken as + continuous vectors, and all other variables (character strings, + logical) are coerced to factors if possible. The function also + should work with degenerate data, like only one level of a + factor or a constant value of a continuous environmental + variable. + + \item \code{nestednodf} with quantitative data was not + consistent with binary models, and the fill was wrongly + calculated with quantitative data. + + \item \code{oecosimu} now correctly adapts displayed quantiles + of simulated values to the \code{alternative} test direction. + + \item \code{renyiaccum} plotting failed if only one level of + diversity \code{scale} was used. + + } + } % bug fixes + + \subsection{NEW FEATURES}{ + \itemize{ + + \item The Kempton and Taylor algorithm was found unreliable in + \code{fisherfit} and \code{fisher.alpha}, and now the estimation + of Fisher \eqn{\alpha}{alpha} is only based on the number of + species and the number of individuals. The estimation of + standard errors and profile confidence intervals also had to be + scrapped. + + \item \code{renyiaccum}, \code{specaccum} and + \code{tsallisaccum} functions gained \code{subset} argument. + + \item \code{renyiaccum} can now add a \code{collector} curve to + to the analysis. The collector curve is the diversity + accumulation in the order of the sampling units. With an + interesting ordering or sampling units this allows comparing + actual species accumulations with the expected randomized + accumulation. + + \item \code{specaccum} can now perform weighted accumulation + using the sampling effort as weights. + + } + + } % new features + + +} % end 2.0-10 + \section{Changes in version 2.0-9}{ \itemize{ Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-12-08 07:44:18 UTC (rev 2811) +++ www/NEWS.html 2013-12-08 15:19:45 UTC (rev 2812) @@ -8,6 +8,94 @@

vegan News

+

Changes in version 2.0-10

+ + + +

GENERAL

+ + +
    +
  • This version is adapted to the changes in permute +package version 0.8-0 and no more triggers NOTEs in package +checks. This release may be the last of the 2.0 series, and the +next vegan release is scheduled to be a major release with +newly designed oecosimu and community pattern simulation, +support for parallel processing, and full support of the +permute package. If you are interested in these +developments, you may try the development versions of +vegan in +R-Forge or +GitHub and report the +problems and user experience to us.

    +
+ + + +

BUG FIXES

+ + +
    +
  • envfit function assumed that all external variables +were either numeric or factors, and failed if they were, say, +character strings. Now only numeric variables are taken as +continuous vectors, and all other variables (character strings, +logical) are coerced to factors if possible. The function also +should work with degenerate data, like only one level of a +factor or a constant value of a continuous environmental +variable. +

    +
  • +
  • nestednodf with quantitative data was not +consistent with binary models, and the fill was wrongly +calculated with quantitative data. +

    +
  • +
  • oecosimu now correctly adapts displayed quantiles +of simulated values to the alternative test direction. +

    +
  • +
  • renyiaccum plotting failed if only one level of +diversity scale was used. +

    +
+ + + + +

NEW FEATURES

+ + + +
    +
  • The Kempton and Taylor algorithm was found unreliable in +fisherfit and fisher.alpha, and now the estimation +of Fisher alpha is only based on the number of +species and the number of individuals. The estimation of +standard errors and profile confidence intervals also had to be +scrapped. +

    +
  • +
  • renyiaccum, specaccum and +tsallisaccum functions gained subset argument. +

    +
  • +
  • renyiaccum can now add a collector curve to +to the analysis. The collector curve is the diversity +accumulation in the order of the sampling units. With an +interesting ordering or sampling units this allows comparing +actual species accumulations with the expected randomized +accumulation. +

    +
  • +
  • specaccum can now perform weighted accumulation +using the sampling effort as weights. +

    +
+ + + +

Changes in version 2.0-9

From noreply at r-forge.r-project.org Mon Dec 9 09:09:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Dec 2013 09:09:23 +0100 (CET) Subject: [Vegan-commits] r2813 - branches/2.0 pkg/vegan Message-ID: <20131209080924.04A0F180602@r-forge.r-project.org> Author: jarioksa Date: 2013-12-09 09:09:23 +0100 (Mon, 09 Dec 2013) New Revision: 2813 Modified: branches/2.0/DESCRIPTION pkg/vegan/DESCRIPTION Log: vegan actually depends on R >= 2.15.0: paste0() Modified: branches/2.0/DESCRIPTION =================================================================== --- branches/2.0/DESCRIPTION 2013-12-08 15:19:45 UTC (rev 2812) +++ branches/2.0/DESCRIPTION 2013-12-09 08:09:23 UTC (rev 2813) @@ -1,12 +1,12 @@ Package: vegan Title: Community Ecology Package Version: 2.0-10 -Date: December 5, 2013 +Date: December 10, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Maintainer: Jari Oksanen -Depends: permute (>= 0.8-0), lattice, R (>= 2.14.0) +Depends: permute (>= 0.8-0), lattice, R (>= 2.15.0) Suggests: MASS, mgcv, cluster, scatterplot3d, rgl, tcltk Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-12-08 15:19:45 UTC (rev 2812) +++ pkg/vegan/DESCRIPTION 2013-12-09 08:09:23 UTC (rev 2813) @@ -6,7 +6,7 @@ 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.14.0) +Depends: permute (>= 0.7-8), lattice, R (>= 2.15.0) Suggests: MASS, mgcv, cluster, parallel, scatterplot3d, rgl, tcltk Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. From noreply at r-forge.r-project.org Tue Dec 10 09:44:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 10 Dec 2013 09:44:55 +0100 (CET) Subject: [Vegan-commits] r2814 - in pkg/vegan: R inst man Message-ID: <20131210084455.AB297185DD1@r-forge.r-project.org> Author: jarioksa Date: 2013-12-10 09:44:55 +0100 (Tue, 10 Dec 2013) New Revision: 2814 Modified: pkg/vegan/R/ordispider.R pkg/vegan/inst/ChangeLog pkg/vegan/man/ordihull.Rd Log: add choice of spatial medians in ordispider Modified: pkg/vegan/R/ordispider.R =================================================================== --- pkg/vegan/R/ordispider.R 2013-12-09 08:09:23 UTC (rev 2813) +++ pkg/vegan/R/ordispider.R 2013-12-10 08:44:55 UTC (rev 2814) @@ -1,8 +1,10 @@ `ordispider` <- function (ord, groups, display = "sites", w = weights(ord, display), + spiders = c("centroid", "median"), show.groups, label = FALSE, ...) { weights.default <- function(object, ...) NULL + spiders <- match.arg(spiders) if (inherits(ord, "cca") && missing(groups)) { lc <- scores(ord, display = "lc", ...) wa <- scores(ord, display = "wa", ...) @@ -30,6 +32,8 @@ groups <- groups[take] w <- w[take] } + if (spiders == "median" && sd(w) > sqrt(.Machine$double.eps)) + warning("weights are ignored with 'median' spiders") out <- seq(along = groups) inds <- names(table(groups)) if (label) @@ -41,7 +45,10 @@ if (length(gr) > 1) { X <- pts[gr, ] W <- w[gr] - ave <- apply(X, 2, weighted.mean, w = W) + ave <- switch(spiders, + "centroid" = apply(X, 2, weighted.mean, w = W), + "median" = ordimedian(X, rep(1, nrow(X))) + ) spids[,gr] <- ave ordiArgAbsorber(ave[1], ave[2], X[, 1], X[, 2], FUN = segments, ...) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-09 08:09:23 UTC (rev 2813) +++ pkg/vegan/inst/ChangeLog 2013-12-10 08:44:55 UTC (rev 2814) @@ -30,6 +30,9 @@ sure. Also fixed handling of tied values in assessing the P-values in vectorfit. + * ordispider: can now use spatial medians as centres instead of + the default centroids. The kind of centre is defined by new + argument 'spiders'. * tests for cca/rda/capscale: commented out test that failed with the anova.cca. Known issue was that 'by = "term"' and 'by = Modified: pkg/vegan/man/ordihull.Rd =================================================================== --- pkg/vegan/man/ordihull.Rd 2013-12-09 08:09:23 UTC (rev 2813) +++ pkg/vegan/man/ordihull.Rd 2013-12-10 08:44:55 UTC (rev 2814) @@ -24,7 +24,8 @@ draw = c("lines","polygon", "none"), w = weights(ord, display), col = NULL, alpha = 127, show.groups, label = FALSE, ...) ordispider(ord, groups, display="sites", w = weights(ord, display), - show.groups, label = FALSE, ...) + spiders = c("centroid", "median"), show.groups, + label = FALSE, ...) ordicluster(ord, cluster, prune = 0, display = "sites", w = weights(ord, display), ...) \method{summary}{ordihull}(object, ...) @@ -80,6 +81,9 @@ corresponding value found from the Chi-squared distribution with 2df. } + \item{spiders}{Are centres or spider bodies calculated either as + centroids (averages) or spatial medians.} + \item{cluster}{Result of hierarchic cluster analysis, such as \code{\link{hclust}} or \code{\link[cluster]{agnes}}.} From noreply at r-forge.r-project.org Wed Dec 11 14:58:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 11 Dec 2013 14:58:54 +0100 (CET) Subject: [Vegan-commits] r2815 - branches/2.0/inst branches/2.0/man pkg/vegan/man Message-ID: <20131211135855.06269186B41@r-forge.r-project.org> Author: jarioksa Date: 2013-12-11 14:58:49 +0100 (Wed, 11 Dec 2013) New Revision: 2815 Modified: branches/2.0/inst/ChangeLog branches/2.0/man/simper.Rd pkg/vegan/man/simper.Rd Log: patch from github: new email for Eduard Sz?\195?\182cs Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-10 08:44:55 UTC (rev 2814) +++ branches/2.0/inst/ChangeLog 2013-12-11 13:58:49 UTC (rev 2815) @@ -3,7 +3,8 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ Version 2.0-10 (opened December 5, 2013) - + + * r2815: update email in simper.Rd. * merge 2809,2810: treat all non-numeric variables as factors inenvfit. * merge 2713 man/: remove references to very old R versions in man Modified: branches/2.0/man/simper.Rd =================================================================== --- branches/2.0/man/simper.Rd 2013-12-10 08:44:55 UTC (rev 2814) +++ branches/2.0/man/simper.Rd 2013-12-11 13:58:49 UTC (rev 2815) @@ -83,7 +83,7 @@ summary(sim) } \author{ - Eduard Sz?cs \email{szoe8822 at uni-landau.de} + Eduard Sz?cs \email{eduardszoecs at gmail.com} } \references{ Modified: pkg/vegan/man/simper.Rd =================================================================== --- pkg/vegan/man/simper.Rd 2013-12-10 08:44:55 UTC (rev 2814) +++ pkg/vegan/man/simper.Rd 2013-12-11 13:58:49 UTC (rev 2815) @@ -100,7 +100,7 @@ summary(sim) } \author{ - Eduard Sz?cs \email{szoe8822 at uni-landau.de} + Eduard Sz?cs \email{eduardszoecs at gmail.com} } \references{ From noreply at r-forge.r-project.org Thu Dec 12 11:26:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Dec 2013 11:26:12 +0100 (CET) Subject: [Vegan-commits] r2816 - in branches/2.0: . inst Message-ID: <20131212102612.C5B71186938@r-forge.r-project.org> Author: jarioksa Date: 2013-12-12 11:26:12 +0100 (Thu, 12 Dec 2013) New Revision: 2816 Modified: branches/2.0/DESCRIPTION branches/2.0/inst/ChangeLog branches/2.0/inst/NEWS.Rd Log: CRAN release 2.0-10 Modified: branches/2.0/DESCRIPTION =================================================================== --- branches/2.0/DESCRIPTION 2013-12-11 13:58:49 UTC (rev 2815) +++ branches/2.0/DESCRIPTION 2013-12-12 10:26:12 UTC (rev 2816) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package Version: 2.0-10 -Date: December 10, 2013 +Date: December 12, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: branches/2.0/inst/ChangeLog =================================================================== --- branches/2.0/inst/ChangeLog 2013-12-11 13:58:49 UTC (rev 2815) +++ branches/2.0/inst/ChangeLog 2013-12-12 10:26:12 UTC (rev 2816) @@ -2,7 +2,7 @@ VEGAN RELEASE VERSIONS at http://cran.r-project.org/ -Version 2.0-10 (opened December 5, 2013) +Version 2.0-10 (released December 12, 2013) * r2815: update email in simper.Rd. * merge 2809,2810: treat all non-numeric variables as factors Modified: branches/2.0/inst/NEWS.Rd =================================================================== --- branches/2.0/inst/NEWS.Rd 2013-12-11 13:58:49 UTC (rev 2815) +++ branches/2.0/inst/NEWS.Rd 2013-12-12 10:26:12 UTC (rev 2816) @@ -31,7 +31,8 @@ logical) are coerced to factors if possible. The function also should work with degenerate data, like only one level of a factor or a constant value of a continuous environmental - variable. + variable. The ties were wrongly in assessing permutation + \eqn{P}-values in \code{vectorfit}. \item \code{nestednodf} with quantitative data was not consistent with binary models, and the fill was wrongly From noreply at r-forge.r-project.org Thu Dec 12 11:30:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Dec 2013 11:30:04 +0100 (CET) Subject: [Vegan-commits] r2817 - branches pkg/vegan pkg/vegan/inst Message-ID: <20131212103004.BAE61186B6E@r-forge.r-project.org> Author: jarioksa Date: 2013-12-12 11:30:04 +0100 (Thu, 12 Dec 2013) New Revision: 2817 Modified: branches/vegan_releases.txt pkg/vegan/DESCRIPTION pkg/vegan/inst/ChangeLog pkg/vegan/inst/NEWS.Rd Log: maintenance after CRAN release of vegan_2.0-10 Modified: branches/vegan_releases.txt =================================================================== --- branches/vegan_releases.txt 2013-12-12 10:26:12 UTC (rev 2816) +++ branches/vegan_releases.txt 2013-12-12 10:30:04 UTC (rev 2817) @@ -13,6 +13,7 @@ vegan release: revision (date) directory at vegan-forge +2.0-10: r2816 (Thu, 12 Dec 2013) branches/2.0 2.0-9: r2622 (Wed, 25 Sep 2013) branches/2.0 2.0-8: r2549 (Wed, 10 Jul 2013) branches/2.0 2.0-7: r2482 (Tue, 19 Mar 2013) branches/2.0 Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-12-12 10:26:12 UTC (rev 2816) +++ pkg/vegan/DESCRIPTION 2013-12-12 10:30:04 UTC (rev 2817) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-40 -Date: December 3, 2013 +Version: 2.1-41 +Date: December 12, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-12-12 10:26:12 UTC (rev 2816) +++ pkg/vegan/inst/ChangeLog 2013-12-12 10:30:04 UTC (rev 2817) @@ -2,8 +2,13 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-40 (opened December 3, 2013) +Version 2.1-41 (opened December 12, 2013) + + * new version opened with the CRAN release of vegan_2.0-10 on + December 12, 2013. +Version 2.1-40 (closed December 12, 2013) + * anova.cca: Function is now based on the new code, but the old is avaialable in a function called ccanova. The API changes: arguments 'step' and 'perm.max' are gone and replaced with Modified: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2013-12-12 10:26:12 UTC (rev 2816) +++ pkg/vegan/inst/NEWS.Rd 2013-12-12 10:30:04 UTC (rev 2817) @@ -2,6 +2,81 @@ \title{vegan News} \encoding{UTF-8} +\section{Changes in version 2.0-10}{ + + \subsection{GENERAL}{ + \itemize{ + + \item This version is adapted to the changes in \pkg{permute} + package version 0.8-0 and no more triggers NOTEs in package + checks. This release may be the last of the 2.0 series, and the + next \pkg{vegan} release is scheduled to be a major release with + newly designed \code{oecosimu} and community pattern simulation, + support for parallel processing, and full support of the + \pkg{permute} package. If you are interested in these + developments, you may try the development versions of + \pkg{vegan} in + \href{http://r-forge.r-project.org/projects/vegan/}{R-Forge} or + \href{https://github.com/jarioksa/vegan}{GitHub} and report the + problems and user experience to us. } } % end general + + \subsection{BUG FIXES}{ + + \itemize{ + + \item \code{envfit} function assumed that all external variables + were either numeric or factors, and failed if they were, say, + character strings. Now only numeric variables are taken as + continuous vectors, and all other variables (character strings, + logical) are coerced to factors if possible. The function also + should work with degenerate data, like only one level of a + factor or a constant value of a continuous environmental + variable. The ties were wrongly in assessing permutation + \eqn{P}-values in \code{vectorfit}. + + \item \code{nestednodf} with quantitative data was not + consistent with binary models, and the fill was wrongly + calculated with quantitative data. + + \item \code{oecosimu} now correctly adapts displayed quantiles + of simulated values to the \code{alternative} test direction. + + \item \code{renyiaccum} plotting failed if only one level of + diversity \code{scale} was used. + + } + } % bug fixes + + \subsection{NEW FEATURES}{ + \itemize{ + + \item The Kempton and Taylor algorithm was found unreliable in + \code{fisherfit} and \code{fisher.alpha}, and now the estimation + of Fisher \eqn{\alpha}{alpha} is only based on the number of + species and the number of individuals. The estimation of + standard errors and profile confidence intervals also had to be + scrapped. + + \item \code{renyiaccum}, \code{specaccum} and + \code{tsallisaccum} functions gained \code{subset} argument. + + \item \code{renyiaccum} can now add a \code{collector} curve to + to the analysis. The collector curve is the diversity + accumulation in the order of the sampling units. With an + interesting ordering or sampling units this allows comparing + actual species accumulations with the expected randomized + accumulation. + + \item \code{specaccum} can now perform weighted accumulation + using the sampling effort as weights. + + } + + } % new features + + +} % end 2.0-10 + \section{Changes in version 2.0-9}{ \itemize{ From noreply at r-forge.r-project.org Thu Dec 12 11:32:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 12 Dec 2013 11:32:06 +0100 (CET) Subject: [Vegan-commits] r2818 - www Message-ID: <20131212103206.64A6A186B75@r-forge.r-project.org> Author: jarioksa Date: 2013-12-12 11:32:06 +0100 (Thu, 12 Dec 2013) New Revision: 2818 Modified: www/NEWS.html Log: update NEWS.html Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2013-12-12 10:30:04 UTC (rev 2817) +++ www/NEWS.html 2013-12-12 10:32:06 UTC (rev 2818) @@ -43,7 +43,8 @@ logical) are coerced to factors if possible. The function also should work with degenerate data, like only one level of a factor or a constant value of a continuous environmental -variable. +variable. The ties were wrongly in assessing permutation +P-values in vectorfit.

  • nestednodf with quantitative data was not