[Vegan-commits] r2132 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 17 12:27:03 CEST 2012
Author: jarioksa
Date: 2012-04-17 12:27:02 +0200 (Tue, 17 Apr 2012)
New Revision: 2132
Modified:
pkg/vegan/R/adipart.R
pkg/vegan/inst/ChangeLog
Log:
Squashed commit of the following:
commit 3613e7ddc309f6f186600c0761e1cb8cd5930ef9
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date: Tue Apr 17 13:15:36 2012 +0300
adipart assumed constant gamma diversity in all simulations
The default method ("r2dtable") had constant gamma, but some other
methods gave variable gamma diversities, and this gave biased
test results.
If we are interested in beta, the gamma should *not* vary, and setting
'relative = TRUE' probably makes sense with variable gamma.
commit 46fc8aca0a2eca71545a84d17ab82aa0583f9bf6
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date: Tue Apr 17 12:52:39 2012 +0300
indentation of adipart.R
Modified: pkg/vegan/R/adipart.R
===================================================================
--- pkg/vegan/R/adipart.R 2012-04-15 16:52:06 UTC (rev 2131)
+++ pkg/vegan/R/adipart.R 2012-04-17 10:27:02 UTC (rev 2132)
@@ -63,26 +63,27 @@
index <- match.arg(index)
weights <- match.arg(weights)
switch(index,
- "richness" = {
- divfun <- function(x) apply(x > 0, 1, sum)},
- "shannon" = {
- divfun <- function(x) diversity(x, index = "shannon", MARGIN = 1, base=base)},
- "simpson" = {
- divfun <- function(x) diversity(x, index = "simpson", MARGIN = 1)})
- sumMatr <- sum(lhs)
+ "richness" = {
+ divfun <- function(x) apply(x > 0, 1, sum)},
+ "shannon" = {
+ divfun <- function(x) diversity(x, index = "shannon", MARGIN = 1, base=base)},
+ "simpson" = {
+ divfun <- function(x) diversity(x, index = "simpson", MARGIN = 1)})
## this is the function passed to oecosimu
wdivfun <- function(x) {
+ ## matrix sum *can* change in oecosimu (but default is constant sumMatr)
+ sumMatr <- sum(x)
if (fullgamma) {
tmp <- lapply(1:(nlevs-1), function(i) t(model.matrix(ftmp[[i]], rhs)) %*% x)
- tmp[[nlevs]] <- matrix(colSums(lhs), nrow = 1, ncol = ncol(lhs))
+ tmp[[nlevs]] <- matrix(colSums(x), nrow = 1, ncol = ncol(x))
} else {
tmp <- lapply(1:nlevs, function(i) t(model.matrix(ftmp[[i]], rhs)) %*% x)
}
## weights will change in oecosimu thus need to be recalculated
if (weights == "prop")
wt <- lapply(1:nlevs, function(i) apply(tmp[[i]], 1, function(z) sum(z) / sumMatr))
- else wt <- lapply(1:nlevs, function(i) rep(1 / NROW(tmp[[i]]), NROW(tmp[[i]])))
+ else wt <- lapply(1:nlevs, function(i) rep(1 / NROW(tmp[[i]]), NROW(tmp[[i]])))
a <- sapply(1:nlevs, function(i) sum(divfun(tmp[[i]]) * wt[[i]]))
if (relative)
a <- a / a[length(a)]
@@ -91,15 +92,15 @@
}
if (nsimul > 0) {
sim <- oecosimu(lhs, wdivfun, method = method, nsimul=nsimul,
- burnin=burnin, thin=thin)
- } else {
- sim <- wdivfun(lhs)
- tmp <- rep(NA, length(sim))
- sim <- list(statistic = sim,
- oecosimu = list(z = tmp, pval = tmp, method = NA, statistic = sim))
- }
+ burnin=burnin, thin=thin)
+ } else {
+ sim <- wdivfun(lhs)
+ tmp <- rep(NA, length(sim))
+ sim <- list(statistic = sim,
+ oecosimu = list(z = tmp, pval = tmp, method = NA, statistic = sim))
+ }
nam <- c(paste("alpha", 1:(nlevs-1), sep="."), "gamma",
- paste("beta", 1:(nlevs-1), sep="."))
+ paste("beta", 1:(nlevs-1), sep="."))
names(sim$statistic) <- attr(sim$oecosimu$statistic, "names") <- nam
attr(sim, "call") <- match.call()
attr(sim, "index") <- index
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2012-04-15 16:52:06 UTC (rev 2131)
+++ pkg/vegan/inst/ChangeLog 2012-04-17 10:27:02 UTC (rev 2132)
@@ -16,6 +16,11 @@
was already analysed by Marti Anderson when introducing the
method).
+ * adipart: permutation tests assumed constant full gamma diversity
+ in all simulations even when the null model could produce variable
+ gamma diversities. The default method ("r2dtable") had constant
+ gamma diversity.
+
* anova of prc() objects by "axis", "terms" or "margin" failed due
to NAMESPACE issues. Reported as issue #7 by Eduard Szöcs in
github.com.
More information about the Vegan-commits
mailing list