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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat May 30 11:14:38 CEST 2009


Author: jarioksa
Date: 2009-05-30 11:14:37 +0200 (Sat, 30 May 2009)
New Revision: 837

Modified:
   pkg/vegan/R/factorfit.R
   pkg/vegan/R/print.factorfit.R
   pkg/vegan/R/print.vectorfit.R
   pkg/vegan/R/vectorfit.R
   pkg/vegan/inst/ChangeLog
Log:
observed value is now considered as one of the permutations in envfit

Modified: pkg/vegan/R/factorfit.R
===================================================================
--- pkg/vegan/R/factorfit.R	2009-05-30 06:51:36 UTC (rev 836)
+++ pkg/vegan/R/factorfit.R	2009-05-30 09:14:37 UTC (rev 837)
@@ -33,6 +33,8 @@
         r.this <- 1 - invar/totvar
         r <- c(r, r.this)
         if (permutations) {
+            if (permutations %% 100 == 0)
+                permutations <- permutations - 1
             A <- as.integer(P[[i]])
             NL <- nlevels(P[[i]])
             tmp <- rep(NA, permutations)
@@ -45,7 +47,7 @@
                             var = double(1), PACKAGE = "vegan")$var
                 tmp[i] <- 1 - invar/totvar
             }
-            pval.this <- sum(tmp > r.this)/permutations
+            pval.this <- (sum(tmp > r.this) + 1)/(permutations + 1)
             pval <- c(pval, pval.this)
         }
     }

Modified: pkg/vegan/R/print.factorfit.R
===================================================================
--- pkg/vegan/R/print.factorfit.R	2009-05-30 06:51:36 UTC (rev 836)
+++ pkg/vegan/R/print.factorfit.R	2009-05-30 09:14:37 UTC (rev 837)
@@ -1,15 +1,12 @@
 "print.factorfit" <-
     function (x, ...) 
 {
-    if (x$permutations) 
-        eps <- 1/x$permutations
-    else eps <- .Machine$double.eps
     cat("Centroids:\n")
     printCoefmat(x$centroids, tst.ind = 1:ncol(x$centroids), na.print = "", ...)
     cat("\nGoodness of fit:\n")
     out <- cbind(r2 = x$r, "Pr(>r)" = x$pvals)
     if (x$permutations) {
-        printCoefmat(out, has.Pvalue = TRUE, eps.Pvalue = eps, ...)
+        printCoefmat(out, has.Pvalue = TRUE, ...)
         cat("P values based on", x$permutations, "permutations")
         if (!is.null(x$strata)) 
             cat(", stratified within", x$strata)

Modified: pkg/vegan/R/print.vectorfit.R
===================================================================
--- pkg/vegan/R/print.vectorfit.R	2009-05-30 06:51:36 UTC (rev 836)
+++ pkg/vegan/R/print.vectorfit.R	2009-05-30 09:14:37 UTC (rev 837)
@@ -1,11 +1,8 @@
 "print.vectorfit" <-
     function (x, ...) 
 {
-    if (x$permutations) 
-        eps <- 1/x$permutations
-    else eps <- .Machine$double.eps
     out <- cbind(x$arrows, r2 = x$r, "Pr(>r)" = x$pvals)
-    printCoefmat(out, eps.Pvalue = eps, na.print = "", ...)
+    printCoefmat(out, na.print = "", ...)
     if (x$permutations) {
         cat("P values based on", x$permutations, "permutations")
         if (!is.null(x$strata)) 

Modified: pkg/vegan/R/vectorfit.R
===================================================================
--- pkg/vegan/R/vectorfit.R	2009-05-30 06:51:36 UTC (rev 836)
+++ pkg/vegan/R/vectorfit.R	2009-05-30 09:14:37 UTC (rev 837)
@@ -29,6 +29,8 @@
         colnames(heads) <- paste("Dim", 1:nc, sep = "")
     else colnames(heads) <- colnames(X)
     if (permutations) {
+        if (permutations %% 100 == 0)
+            permutations <- permutations - 1
         nr <- nrow(X)
         permstore <- matrix(nrow = permutations, ncol = ncol(P))
         for (i in 1:permutations) {
@@ -42,7 +44,7 @@
             permstore[i, ] <- diag(cor(Hperm, take))^2
         }
         permstore <- sweep(permstore, 2, r, ">")
-        pvals <- apply(permstore, 2, sum)/permutations
+        pvals <- (apply(permstore, 2, sum) + 1)/(permutations + 1)
     }
     else pvals <- NULL
     sol <- list(arrows = heads, r = r, permutations = permutations, 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-05-30 06:51:36 UTC (rev 836)
+++ pkg/vegan/inst/ChangeLog	2009-05-30 09:14:37 UTC (rev 837)
@@ -23,6 +23,9 @@
 	one of the permutations. Default N.perm decreased to 999 to account
 	for this.
 
+	* envfit (vectorfit, factorfit): observed value of test statistic
+	is now considered as one of the permutations.
+
 Version 1.16-18 (closed May 14, 2009)
 
 	* tsallis: got new argument 'hill' similar to that of renyi.



More information about the Vegan-commits mailing list