[Vegan-commits] r2198 - 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 May 27 16:47:04 CEST 2012


Author: jarioksa
Date: 2012-05-27 16:47:03 +0200 (Sun, 27 May 2012)
New Revision: 2198

Modified:
   branches/2.0/R/betadisper.R
   branches/2.0/inst/ChangeLog
   branches/2.0/inst/NEWS.Rd
   branches/2.0/man/betadisper.Rd
   www/NEWS.html
Log:
merge r2195 thru 2197: bias adjusted betadisper

Modified: branches/2.0/R/betadisper.R
===================================================================
--- branches/2.0/R/betadisper.R	2012-05-27 14:34:38 UTC (rev 2197)
+++ branches/2.0/R/betadisper.R	2012-05-27 14:47:03 UTC (rev 2198)
@@ -1,5 +1,5 @@
 `betadisper` <-
-    function(d, group, type = c("median","centroid"))
+    function(d, group, type = c("median","centroid"), bias.adjust=FALSE)
 {
     ## inline function for spatial medians
     spatialMed <- function(vectors, group, pos) {
@@ -67,7 +67,8 @@
     ## Remove zero eigenvalues
     eig <- eig[(want <- abs(eig/eig[1]) > TOL)]
     ## scale Eigenvectors
-    vectors <- vectors[, want, drop = FALSE] %*% diag(sqrt(abs(eig)))
+    vectors <- vectors[, want, drop = FALSE] %*% diag(sqrt(abs(eig)),
+                               nrow = length(eig))
     ## store which are the positive eigenvalues
     pos <- eig > 0
     ## group centroids in PCoA space
@@ -89,6 +90,10 @@
 
     ## zij are the distances of each point to its group centroid
     zij <- sqrt(abs(dist.pos - dist.neg))
+    if (bias.adjust) {
+        n.group <- table(group)
+        zij <- zij*sqrt(n.group[group]/(n.group[group]-1))
+    }
     ## add in correct labels
     colnames(vectors) <- names(eig) <- paste("PCoA", seq_along(eig), sep = "")
     if(is.matrix(centroids))
@@ -101,5 +106,6 @@
     class(retval) <- "betadisper"
     attr(retval, "method") <- attr(d, "method")
     attr(retval, "type") <- type
+    attr(retval, "bias.adjust") <- bias.adjust
     retval
 }

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2012-05-27 14:34:38 UTC (rev 2197)
+++ branches/2.0/inst/ChangeLog	2012-05-27 14:47:03 UTC (rev 2198)
@@ -3,7 +3,8 @@
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
 Version 2.0-4 (opened March 9, 2012)
-
+	
+	* merge r2195-7: bias adjusted betadisper.
 	* merge r2191-2193: standardise handling of 'select' arg in
 	those plotting functions that support it. Adds non-exported
 	function .checkSelect().

Modified: branches/2.0/inst/NEWS.Rd
===================================================================
--- branches/2.0/inst/NEWS.Rd	2012-05-27 14:34:38 UTC (rev 2197)
+++ branches/2.0/inst/NEWS.Rd	2012-05-27 14:47:03 UTC (rev 2198)
@@ -67,6 +67,17 @@
     }
   } % end new features 	 
 
+  \subsection{ANALYSES}{
+    \itemize{
+    
+      \item The method in \code{betadisper} is biased with small,
+        unequal sample sizes.  A bias adjusted version was developed
+        by Adrian Stier and Ben Bolker, and can be invoked with
+        argument \code{bias.adjust} (defaults \code{FALSE}).
+         
+    }
+  } % end analyses
+
 }%end version 2.0-4
 
 \section{Changes in version 2.0-3}{

Modified: branches/2.0/man/betadisper.Rd
===================================================================
--- branches/2.0/man/betadisper.Rd	2012-05-27 14:34:38 UTC (rev 2197)
+++ branches/2.0/man/betadisper.Rd	2012-05-27 14:47:03 UTC (rev 2198)
@@ -25,7 +25,7 @@
   Tukey's 'Honest Significant Difference' method.
 }
 \usage{
-betadisper(d, group, type = c("median","centroid"))
+betadisper(d, group, type = c("median","centroid"), bias.adjust = FALSE)
 
 \method{anova}{betadisper}(object, \dots)
 
@@ -50,7 +50,8 @@
     \code{\link[base]{as.factor}}. Can consist of a factor with a single
     level (i.e.~one group).}
   \item{type}{the type of analysis to perform. Use the spatial median or
-  the group centroid? The spatial median is now the default.}
+    the group centroid? The spatial median is now the default.}
+  \item{bias.adjust}{logical: adjust for small sample bias in beta diversity estimates?}
   \item{display}{character; partial match to access scores for
     \code{"sites"} or \code{"species"}.}
   \item{object, x}{an object of class \code{"betadisper"}, the result of a
@@ -133,6 +134,14 @@
   One additional use of these functions is in assessing beta diversity
   (Anderson \emph{et al} 2006). Function \code{\link{betadiver}}
   provides some popular dissimilarity measures for this purpose.
+
+  As noted in passing by Anderson (2001) and in a related
+  context by O'Neill (2000), estimates of dispersion around a
+  central location (median or centroid) that is calculated from the same data
+  will be biased downward. This bias matters most when comparing diversity
+  among treatments with small, unequal numbers of samples.  Setting
+  \code{bias.adjust=TRUE} when using \code{betadisper} imposes a 
+  \eqn{\sqrt{n/(n-1)}}{sqrt(n/(n-1))} correction (Stier et al. 2012).
 }
 \value{
   The \code{anova} method returns an object of class \code{"anova"}
@@ -184,14 +193,25 @@
   error rates.
 }
 \references{
+  Anderson, M. J. (2001) A new method for non-parametric multivariate 
+  analysis of variance. \emph{Austral Ecology} \strong{26}, 32--46.
+
   Anderson, M.J. (2006) Distance-based tests for homogeneity of
-  multivariate dispersions. \emph{Biometrics} \strong{62(1)}, 245--253.
+  multivariate dispersions. \emph{Biometrics} \strong{62}, 245--253.
 
   Anderson, M.J., Ellingsen, K.E. & McArdle, B.H. (2006) Multivariate
   dispersion as a measure of beta diversity. \emph{Ecology Letters}
-  \strong{9(6)}, 683--693.
+  \strong{9}, 683--693.
+
+  O'Neill, M.E. (2000) A Weighted Least Squares Approach to Levene's 
+  Test of Homogeneity of Variance. \emph{Australian & New Zealand Journal of 
+  Statistics \strong{42}, 81-–100.
+
+  Stier, A.C., Geange, S.W., Hanson, K.M., & Bolker, B.M. (2012) Predator 
+  density and timing of arrival affect reef fish community assembly. Ms.
+  in revision, \emph{Oikos}.
 }
-\author{Gavin L. Simpson}
+\author{Gavin L. Simpson; bias correction by Adrian Stier and Ben Bolker.}
 \seealso{\code{\link{permutest.betadisper}}, \code{\link[stats]{anova.lm}},
   \code{\link{scores}}, \code{\link[graphics]{boxplot}},
   \code{\link{TukeyHSD}}. Further measure of beta diversity
@@ -249,6 +269,10 @@
 plot(mod3)
 boxplot(mod3)
 plot(TukeyHSD(mod3))
+
+## try out bias correction; compare with mod3
+(mod3B <- betadisper(dis, groups, type = "median", bias.adjust=TRUE))
+
 }
 \keyword{methods}
 \keyword{multivariate}

Modified: www/NEWS.html
===================================================================
--- www/NEWS.html	2012-05-27 14:34:38 UTC (rev 2197)
+++ www/NEWS.html	2012-05-27 14:47:03 UTC (rev 2198)
@@ -92,6 +92,21 @@
  
 
 
+<h4>ANALYSES</h4>
+
+
+
+<ul>
+<li><p> The method in <code>betadisper</code> is biased with small,
+unequal sample sizes.  A bias adjusted version was developed
+by Adrian Stier and Ben Bolker, and can be invoked with
+argument <code>bias.adjust</code> (defaults <code>FALSE</code>).
+</p>
+</li></ul>
+
+ 
+
+
 <h3>Changes in version 2.0-3</h3>
 
 



More information about the Vegan-commits mailing list