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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 25 20:23:57 CEST 2011


Author: jarioksa
Date: 2011-09-25 20:23:57 +0200 (Sun, 25 Sep 2011)
New Revision: 1886

Modified:
   pkg/vegan/R/commsimulator.R
   pkg/vegan/R/make.commsim.R
   pkg/vegan/man/commsim.Rd
Log:
r0_old: 'new' commsim method that uses the same RNG sequence as commsimulators's 'r0'

Modified: pkg/vegan/R/commsimulator.R
===================================================================
--- pkg/vegan/R/commsimulator.R	2011-09-25 17:56:29 UTC (rev 1885)
+++ pkg/vegan/R/commsimulator.R	2011-09-25 18:23:57 UTC (rev 1886)
@@ -4,6 +4,8 @@
     method <- match.arg(method, 
                         c("r0","r1","r2","r00","c0","swap", "tswap",
                           "backtrack", "quasiswap"))
+    if (method == "r0")
+        method <- "r0_old"
     x <- as.matrix(x)
     out <- simulate(nullmodel(x, method), nsim = 1, thin = thin)
     out <- out[,,1]

Modified: pkg/vegan/R/make.commsim.R
===================================================================
--- pkg/vegan/R/make.commsim.R	2011-09-25 17:56:29 UTC (rev 1885)
+++ pkg/vegan/R/make.commsim.R	2011-09-25 18:23:57 UTC (rev 1886)
@@ -39,6 +39,17 @@
                     out[i, sample.int(nc, rs[i]), k] <- 1
             out
         }),
+        "r0_old" = commsim(method="r0_old", binary=TRUE, isSeq=FALSE,
+        mode="integer",
+        fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {
+            out <- array(0L, c(nr, nc, n))
+            I <- seq_len(nr)
+            p <- rep(1, nc)
+            for (k in seq_len(n))
+                for (i in I)
+                    out[i, sample.int(nc, rs[i], prob = p), k] <- 1
+            out
+        }),
         "r1" = commsim(method="r1", binary=TRUE, isSeq=FALSE,
         mode="integer",
         fun=function(x, n, nr, nc, rs, cs, rf, cf, s, fill, thin) {

Modified: pkg/vegan/man/commsim.Rd
===================================================================
--- pkg/vegan/man/commsim.Rd	2011-09-25 17:56:29 UTC (rev 1885)
+++ pkg/vegan/man/commsim.Rd	2011-09-25 18:23:57 UTC (rev 1886)
@@ -71,11 +71,14 @@
     This maintains the number of presences but fills 
     these anywhere so that neither species (column) nor 
     site (row) totals are preserved. See Wright et al. (1998) for review.}
-  \item{\code{"r0"}: }{non-sequential algorithm for binary matrices described 
-    in the page of \code{\link{commsimulator}}.
-    This maintains the site (row) frequencies,
-    fills presences anywhere on the row with no respect to 
-    species (column) frequencies. See Wright et al. (1998) for review.}
+  \item{\code{"r0", "r0_old"}: }{non-sequential algorithm for binary
+    matrices described in the page of \code{\link{commsimulator}}.
+    This maintains the site (row) frequencies, fills presences
+    anywhere on the row with no respect to species (column)
+    frequencies. Methods \code{"r0"} and \code{"r0_old"} implement the
+    same method, but use different random number sequences; use
+    \code{"r0_old"} is you want to reproduce reusult in \pkg{vegan
+    2.0-0} or older. See Wright et al. (1998) for a review.}
   \item{\code{"r1"}: }{non-sequential algorithm for binary matrices described 
     in the page of \code{\link{commsimulator}}.
     This maintains the site (row) frequencies,



More information about the Vegan-commits mailing list