[Vegan-commits] r2629 - in pkg/vegan: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 29 11:55:03 CEST 2013


Author: jarioksa
Date: 2013-09-29 11:55:02 +0200 (Sun, 29 Sep 2013)
New Revision: 2629

Modified:
   pkg/vegan/R/decostand.R
   pkg/vegan/R/factorfit.R
   pkg/vegan/R/vectorfit.R
   pkg/vegan/inst/ChangeLog
Log:
envfit tries to do something sensible with insensible input (constant variable, one-level factor)

Modified: pkg/vegan/R/decostand.R
===================================================================
--- pkg/vegan/R/decostand.R	2013-09-29 05:33:22 UTC (rev 2628)
+++ pkg/vegan/R/decostand.R	2013-09-29 09:55:02 UTC (rev 2629)
@@ -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: pkg/vegan/R/factorfit.R
===================================================================
--- pkg/vegan/R/factorfit.R	2013-09-29 05:33:22 UTC (rev 2628)
+++ pkg/vegan/R/factorfit.R	2013-09-29 09:55:02 UTC (rev 2629)
@@ -53,7 +53,7 @@
             }
             tmp <- sapply(1:permutations,
                           function(indx,...) ptest(permat[indx,], ...))
-            pval.this <- (sum(tmp > r.this) + 1)/(permutations + 1)
+            pval.this <- (sum(tmp >= r.this) + 1)/(permutations + 1)
             pval <- c(pval, pval.this)
         }
     }

Modified: pkg/vegan/R/vectorfit.R
===================================================================
--- pkg/vegan/R/vectorfit.R	2013-09-29 05:33:22 UTC (rev 2628)
+++ pkg/vegan/R/vectorfit.R	2013-09-29 09:55:02 UTC (rev 2629)
@@ -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))) 
@@ -54,7 +55,8 @@
         if (!is.matrix(permstore))
             permstore <- matrix(permstore, ncol=permutations)
         permstore <- sweep(permstore, 1, r, ">")
-        pvals <- (rowSums(permstore) + 1)/(permutations + 1)
+        validn <- rowSums(is.finite(permstore))
+        pvals <- (rowSums(permstore, na.rm = TRUE) + 1)/(validn + 1)
     }
     else pvals <- NULL
     sol <- list(arrows = heads, r = r, permutations = permutations, 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-09-29 05:33:22 UTC (rev 2628)
+++ pkg/vegan/inst/ChangeLog	2013-09-29 09:55:02 UTC (rev 2629)
@@ -6,11 +6,21 @@
 
 	* opened with the release of vegan 2.0-9.
 
+	* decostand(..., "normalize") uses now .Machine$double.eps to
+	replace zero sum of squares instead of matrix minimum.
+
 	* envfit: if a variable is constant, no fitted vector can be
-	calculated and results will be given as NA (with
-	warnings). Plotting of all vectors will fail in such cases because
-	no finite scale was found for arrows. Fixed on ordiArrowMul.
+	calculated and results will be given as NA (with warnings).
+	Plotting of all vectors will fail in such cases because no finite
+	scale was found for arrows. Fixed on ordiArrowMul.
 
+	* envfit: try to produce something sensible if fitted variable has
+	constant values (invariable vector, one-level factor). Report
+	arrow heads as all zero, and R2=0 for vectors, and the centroid to
+	the data centroid and R2=0 for factors. Tied values are now
+	treated differently in factorfit: now they support null
+	hypothesis, previously they decreased the P-values. 
+
 	* nestednodf: matrix fill was wrongly calculated in weighted
 	analysis. The nominator was length of 'comm', and if input was a
 	data frame that was the number of columns instead of the number of



More information about the Vegan-commits mailing list