[Vegan-commits] r787 - branches/1.15/R branches/1.15/inst branches/1.15/man pkg/vegan/inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Apr 4 11:20:59 CEST 2009
Author: gsimpson
Date: 2009-04-04 11:20:59 +0200 (Sat, 04 Apr 2009)
New Revision: 787
Modified:
branches/1.15/R/betadisper.R
branches/1.15/inst/ChangeLog
branches/1.15/man/betadisper.Rd
pkg/vegan/inst/ChangeLog
Log:
merge r786 to 1.15 branch and update both changelogs
Modified: branches/1.15/R/betadisper.R
===================================================================
--- branches/1.15/R/betadisper.R 2009-04-04 09:15:43 UTC (rev 786)
+++ branches/1.15/R/betadisper.R 2009-04-04 09:20:59 UTC (rev 787)
@@ -1,6 +1,8 @@
`betadisper` <-
- function(d, group, type = c("centroid","median"), tol = 1e-07)
+ function(d, group, type = c("centroid","median"))
{
+ ## Tolerance for zero Eigenvalues
+ TOL <- 1e-7
## uses code from stats:::cmdscale by R Core Development Team
if(!inherits(d, "dist"))
stop("distances 'd' must be a 'dist' object")
@@ -19,14 +21,9 @@
e <- eigen(-x/2, symmetric = TRUE)
vectors <- e$vectors
eig <- e$values
- ## check d is Euclidean
- w0 <- eig[n] / eig[1]
- if(w0 > -tol)
- r <- sum(eig > (eig[1] * tol))
- else
- r <- length(eig)
- ## truncate eig if d is Euclidean
- eig <- eig[(rs <- seq_len(r))]
+ ## Remove zero eigenvalues
+ eig <- eig[abs(eig/eig[1]) > TOL]
+ rs <- seq_along(eig)
## scale Eigenvectors
vectors <- vectors[, rs, drop = FALSE] %*% diag(sqrt(abs(eig)))
## store which are the positive eigenvalues
Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog 2009-04-04 09:15:43 UTC (rev 786)
+++ branches/1.15/inst/ChangeLog 2009-04-04 09:20:59 UTC (rev 787)
@@ -5,8 +5,8 @@
Version 1.15-2 (opened January 14, 2009)
- * merged r781 from trunk to 1.15 branch: betadisper bug fix and
- upgrade to work more nicely with Euclidean 'd'.
+ * merged r781 and r786 from trunk to 1.15 branch: betadisper
+ bug fix and upgrade to work more nicely with Euclidean 'd'.
* copied contribdiv from pkg/vegan at rev681 (vegan at rev775).
Modified: branches/1.15/man/betadisper.Rd
===================================================================
--- branches/1.15/man/betadisper.Rd 2009-04-04 09:15:43 UTC (rev 786)
+++ branches/1.15/man/betadisper.Rd 2009-04-04 09:20:59 UTC (rev 787)
@@ -25,7 +25,7 @@
Tukey's 'Honest Significant Difference' method.
}
\usage{
-betadisper(d, group, type = c("centroid", "median"), tol = 1e-07)
+betadisper(d, group, type = c("centroid", "median"))
\method{anova}{betadisper}(object, \dots)
@@ -51,7 +51,6 @@
level (i.e.~one group).}
\item{type}{the type of analysis to perform. Only \code{type =
"centroid"} is currently supported.}
- \item{tol}{tolerance for checking if \code{d} is Euclidean.}
\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
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-04-04 09:15:43 UTC (rev 786)
+++ pkg/vegan/inst/ChangeLog 2009-04-04 09:20:59 UTC (rev 787)
@@ -14,9 +14,8 @@
* betadisper: Fix bug corrects the way distance to centroid is
computed when only one group is present in the data. betadisper
- can now also detect if 'd' is Euclidean up to a tolerance that
- can be set using new argument 'tol'. Bug report and suggested
- improvements provided by Etienne Laliberté.
+ can now also detect if 'd' is Euclidean, zapping zero Eigenvalues.
+ Bug report and suggested improvements provided by Etienne Laliberté.
Version 1.16-16 (closed April 2, 2009)
More information about the Vegan-commits
mailing list