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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 19 20:49:25 CET 2011


Author: jarioksa
Date: 2011-12-19 20:49:24 +0100 (Mon, 19 Dec 2011)
New Revision: 2029

Modified:
   pkg/vegan/R/oecosimu.R
   pkg/vegan/R/print.oecosimu.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/oecosimu.Rd
Log:
added arg alternative='pick' to select the better of one-sided tests (for EcoSim compatibility)

Modified: pkg/vegan/R/oecosimu.R
===================================================================
--- pkg/vegan/R/oecosimu.R	2011-12-19 18:23:19 UTC (rev 2028)
+++ pkg/vegan/R/oecosimu.R	2011-12-19 19:49:24 UTC (rev 2029)
@@ -1,7 +1,7 @@
 `oecosimu` <-
     function(comm, nestfun, method, nsimul=99,
              burnin=0, thin=1, statistic = "statistic",
-             alternative = c("two.sided", "less", "greater"),
+             alternative = c("two.sided", "less", "greater", "pick"),
              parallel = getOption("mc.cores", 1L), ...)
 {
     alternative <- match.arg(alternative)
@@ -106,7 +106,8 @@
     p <- switch(alternative,
                 two.sided = 2*pmin(pless, pmore),
                 less = pless,
-                greater = pmore)
+                greater = pmore,
+                pick = pmin(pless, pmore))
     p <- pmin(1, (p + 1)/(nsimul + 1))
     
     ## ADDITION: if z is NA then it is not correct to calculate p values

Modified: pkg/vegan/R/print.oecosimu.R
===================================================================
--- pkg/vegan/R/print.oecosimu.R	2011-12-19 18:23:19 UTC (rev 2028)
+++ pkg/vegan/R/print.oecosimu.R	2011-12-19 19:49:24 UTC (rev 2029)
@@ -11,7 +11,8 @@
     alt.char <- switch(x$oecosimu$alternative,
                        two.sided = "not equal to",
                        less = "less than",
-                       greater = "greater than")
+                       greater = "greater than",
+                       pick = "less or greater than")
     cat("\nalternative hypothesis: simulated median is", alt.char, "the statistic")
     ## dim attribute is always there, but print all others
 
@@ -24,7 +25,8 @@
     probs <- switch(x$oecosimu$alternative,
                     two.sided = c(0.025, 0.5, 0.975),
                     less = c(0, 0.5, 0.95),
-                    greater = c(0.05, 0.5, 1))
+                    greater = c(0.05, 0.5, 1),
+                    pick = c(0.05, 0.5, 0.95))
     qu <- apply(x$oecosimu$simulated, 1, quantile, probs=probs, na.rm = TRUE)
     m <- cbind("statistic" = x$oecosimu$statistic,
                "z" = x$oecosimu$z, "mean" = x$oecosimu$means, t(qu),

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-12-19 18:23:19 UTC (rev 2028)
+++ pkg/vegan/inst/ChangeLog	2011-12-19 19:49:24 UTC (rev 2029)
@@ -19,7 +19,13 @@
 
 	* oecosimu: more informative text on 'alternative' hypotheses in
 	the printed output. Return also the mean of simulations and show
-	that in the printed output.
+	that in the printed output. Added 'alternative = "pick"' which
+	performs two one-sided tests (both "less" and "greater"), and
+	returns the results of the one with lower p-value. This does not
+	sound fair, but is provided for compatibility with EcosSim.exe
+	which returns both one-way tests for authors to choose (and
+	presumably they often pick the lower p-value, and if they know,
+	they can use specific 'alternative' in oecosimu()).
 	
 	* rarecurve: new function to draw rarefaction curves for each
 	plot, optionally with sample size vertical and corresponding

Modified: pkg/vegan/man/oecosimu.Rd
===================================================================
--- pkg/vegan/man/oecosimu.Rd	2011-12-19 18:23:19 UTC (rev 2028)
+++ pkg/vegan/man/oecosimu.Rd	2011-12-19 19:49:24 UTC (rev 2029)
@@ -28,7 +28,8 @@
 
 \usage{
 oecosimu(comm, nestfun, method, nsimul = 99, burnin = 0, thin = 1,
-   statistic = "statistic", alternative = c("two.sided", "less", "greater"), 
+   statistic = "statistic", 
+   alternative = c("two.sided", "less", "greater", "pick"), 
    parallel = getOption("mc.cores", 1L), ...)
 \method{as.ts}{oecosimu}(x, ...)
 \method{as.mcmc}{oecosimu}(x)
@@ -70,8 +71,11 @@
   \item{statistic}{The name of the statistic returned by
     \code{nestfun}.} 
   \item{alternative}{a character string specifying the alternative
-    hypothesis, must be one of \code{"two.sided"} (default), \code{"greater"}
-    or \code{"less"}.}
+    hypothesis, must be one of \code{"two.sided"} (default), \code{"greater"},
+    \code{"less"} or \code{"pick"}. The case \code{"pick"} analyses both 
+    \code{"greater"} and \code{"less"} one-sided tests and selects the one 
+    with lower  \eqn{p}-value; this is not recommended but is provided for 
+    compatibility with some other software.}
   \item{parallel}{Number of parallel processes or a predefined socket
     cluster.  With \code{parallel = 1} uses ordinary, non-parallel
     processing. The parallel processing is done with \pkg{parallel}



More information about the Vegan-commits mailing list