[Vegan-commits] r2138 - branches/2.0/R branches/2.0/inst branches/2.0/man www

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 22 08:13:39 CEST 2012


Author: jarioksa
Date: 2012-04-22 08:13:38 +0200 (Sun, 22 Apr 2012)
New Revision: 2138

Modified:
   branches/2.0/R/adipart.R
   branches/2.0/R/print.adipart.R
   branches/2.0/inst/ChangeLog
   branches/2.0/inst/NEWS.Rd
   branches/2.0/man/pyrifos.Rd
   www/NEWS.html
Log:
merge r2132,5 (varying gamma diversity & print in adipart) and r2137 (pyrifos.Rd edit)

Modified: branches/2.0/R/adipart.R
===================================================================
--- branches/2.0/R/adipart.R	2012-04-22 05:46:18 UTC (rev 2137)
+++ branches/2.0/R/adipart.R	2012-04-22 06:13:38 UTC (rev 2138)
@@ -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: branches/2.0/R/print.adipart.R
===================================================================
--- branches/2.0/R/print.adipart.R	2012-04-22 05:46:18 UTC (rev 2137)
+++ branches/2.0/R/print.adipart.R	2012-04-22 06:13:38 UTC (rev 2138)
@@ -3,7 +3,11 @@
 {
     n <- if (is.null(x$oecosimu$simulated))
         0 else ncol(x$oecosimu$simulated)
-    cat("adipart with", n, "simulations\n")
+    if (n > 0)
+        cat("adipart with", n, "simulations using method",
+            dQuote(x$oecosimu$method), "\n")
+    else
+        cat("adipart ")
     att <- attributes(x)
     att$names <- att$call <- att$class <- att$n.levels <- att$terms <- att$model <- NULL
     cat("with", paste(names(att), att, collapse=", "))

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2012-04-22 05:46:18 UTC (rev 2137)
+++ branches/2.0/inst/ChangeLog	2012-04-22 06:13:38 UTC (rev 2138)
@@ -4,6 +4,10 @@
 
 Version 2.0-4 (opened March 9, 2012)
 
+	* merge r2137: explain data transformation in pyrifos.Rd.
+	* merge r2135: print.adipart displays null model method.
+	* merge r2132: adipart bug fix: assumed constant gamma in
+	permutations. 
 	* merge r2129: envfit failed with empty factor levels.
 	* merge r2128: anova(<prc-object>, by = ...) failed.
 	* merge r2127: more configurable msoplot.

Modified: branches/2.0/inst/NEWS.Rd
===================================================================
--- branches/2.0/inst/NEWS.Rd	2012-04-22 05:46:18 UTC (rev 2137)
+++ branches/2.0/inst/NEWS.Rd	2012-04-22 06:13:38 UTC (rev 2138)
@@ -7,6 +7,13 @@
   \subsection{BUG FIXES}{
     \itemize{
     
+      \item \code{adipart} assumed constant gamma diversity in
+        simulations when assessing the \eqn{P}-value.  This could give
+        biased results if the null model produces variable gamma
+        diversities and option \code{weights = "prop"} is used.  The
+        default null model (\code{"r2dtable"}) and the default option
+        (\code{weights = "unif"}) were analysed correctly.
+
       \item \code{anova(<prc-object>, by = "axis")} and other
       \code{by} cases failed due to \file{NAMESPACE} issues.
 

Modified: branches/2.0/man/pyrifos.Rd
===================================================================
--- branches/2.0/man/pyrifos.Rd	2012-04-22 05:46:18 UTC (rev 2137)
+++ branches/2.0/man/pyrifos.Rd	2012-04-22 06:13:38 UTC (rev 2138)
@@ -10,7 +10,7 @@
 }
 \usage{data(pyrifos)}
 \format{
-  A data frame with 132 observations on the log-transformed abundances
+  A data frame with 132 observations on the log-transformed (\code{log(10*x + 1)}) abundances
   of 178 species. There are only twelve sites (ditches, mesocosms), but
   these were studied repeatedly in eleven occasions. The treatment
   levels, treatment times, or ditch ID's are not in the data frame, but

Modified: www/NEWS.html
===================================================================
--- www/NEWS.html	2012-04-22 05:46:18 UTC (rev 2137)
+++ www/NEWS.html	2012-04-22 06:13:38 UTC (rev 2138)
@@ -18,13 +18,21 @@
 
 
 <ul>
+<li> <p><code>adipart</code> assumed constant gamma diversity in
+simulations when assessing the <i>P</i>-value.  This could give
+biased results if the null model produces variable gamma
+diversities and option <code>weights = "prop"</code> is used.  The
+default null model (<code>"r2dtable"</code>) and the default option
+(<code>weights = "unif"</code>) were analysed correctly.
+</p>
+</li>
 <li> <p><code>anova(<prc-object>, by = "axis")</code> and other
 <code>by</code> cases failed due to ‘<span class="file">NAMESPACE</span>’ issues.
 </p>
 </li>
 <li> <p><code>envfit</code> failed with unused factor levels.
 </p>
-</li></ul>
+</ul>
 
 
 
@@ -37,7 +45,7 @@
 <li> <p><code>msoplot</code> is more configurable, and allows, for
 instance, setting y-axis limits.
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -74,7 +82,7 @@
 <a href="https://github.com/jarioksa/vegan">GitHub</a>
 by Eduard Szöcs (Uni Landau, Germany).
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -106,7 +114,7 @@
 was reported as an error in <code>ordiplot</code> in
 <a href="https://stat.ethz.ch/pipermail/r-sig-ecology/2012-February/002768.html">R-sig-ecology</a> mailing list.
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -147,7 +155,7 @@
 intensity. Thanks to consultation to Yong Cao (Univ Illinois,
 USA).
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -189,7 +197,7 @@
 speed-up in the internal f.test() function is fully
 realised. Reported by Nicholas Lewin-Koh.
 </p>
-</li></ul>
+</ul>
 
   
 
@@ -209,7 +217,7 @@
 are class centroids of each point, but for constrained ordination
 with no <code>groups</code> they are the LC scores.
 </p>
-</li></ul>
+</ul>
 		 
   
 
@@ -250,7 +258,7 @@
 [<a href="http://www.esajournals.org/doi/abs/10.1890/ES10-00117.1">doi:10.1890/ES10-00117.1</a>],
 and was developed with the consultation of Brian Inouye.
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -289,7 +297,7 @@
 results but you probably wish to upgrade <span class="pkg">vegan</span> to avoid
 annoying warnings.
 </p>
-</li></ul>
+</ul>
 	
  
 
@@ -304,7 +312,7 @@
 showed that in most cases an improved ordering was found rather
 early in tries, and the results are equally good in most cases.
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -340,7 +348,7 @@
 <span class="pkg">permute</span>, but currently only <code>betadisper</code> uses the new
 feature. 
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -396,7 +404,7 @@
 were implemented because they were found good for species-area
 models by Dengler (<EM>J. Biogeogr.</EM> 36, 728-744; 2009).
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -438,7 +446,7 @@
 the length of the <code>pool</code> matches the number of
 observations.
 </p>
-</li></ul>
+</ul>
 
  
 
@@ -457,7 +465,7 @@
 was not intended for normal use, but packages depending on that
 code in <span class="pkg">vegan</span> should instead depend on <span class="pkg">permute</span>.
 </p>
-</li></ul>
+</ul>
   
  
 
@@ -470,7 +478,7 @@
 <li> <p><code>treeheight</code> uses much snappier code. The results
 should be unchanged.
 </p>
-</li></ul>
+</ul>
 
  
 



More information about the Vegan-commits mailing list