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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 24 15:13:31 CET 2009


Author: psolymos
Date: 2009-02-24 15:13:31 +0100 (Tue, 24 Feb 2009)
New Revision: 701

Modified:
   pkg/vegan/R/permatswap.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/permatfull.Rd
Log:
documantation added, internal fun removed


Modified: pkg/vegan/R/permatswap.R
===================================================================
--- pkg/vegan/R/permatswap.R	2009-02-24 10:02:53 UTC (rev 700)
+++ pkg/vegan/R/permatswap.R	2009-02-24 14:13:31 UTC (rev 701)
@@ -19,40 +19,6 @@
     x[x!=0] <- indshuffle(x[x!=0] - y) + y
     return(sample(x))
 }
-isDiagSimple <- function(x) {
-        x<- as.vector(x)
-        X <- as.numeric(x>0)
-        ## sX: number of non-zero cells
-        sX <- sum(X)
-        ## Either choose could be returned, but RNG is not needed,
-        ## because submatrix already is in random order, and we always return choose[0]
-        if (sX == 4) return(1) else 
-            if (identical(X, c(0,1,1,0)) || identical(X, c(1,0,0,1)))
-                return(1) else return(0)
-}
-abuswap <-
-function(m, fixedmar, thin = 1)
-{
-    x <- as.matrix(m)
-    n.col <- ncol(x)
-    n.row <- nrow(x)
-    changed <- 0
-    while(changed < thin) {
-        ran.row <- sample(n.row, 2)
-        ran.col <- sample(n.col, 2)
-        ev <- isDiagSimple(x[ran.row, ran.col])
-        if (ev == 1) {
-            ## Swap
-            if (fixedmar == "columns")
-                x[ran.row, ran.col] <- x[rev(ran.row), ran.col]
-            if (fixedmar == "rows")
-                x[ran.row, ran.col] <- x[ran.row, rev(ran.col)]
-
-                changed <- changed + 1
-            }
-        }
-    return(x)
-}
     if (!identical(all.equal(m, round(m)), TRUE))
        stop("function accepts only integers (counts)")
     mtype <- match.arg(mtype, c("prab", "count"))
@@ -125,7 +91,6 @@
                        temp <- .C("abuswap", m = as.double(temp),
                             as.integer(nn.row), as.integer(nn.col),
                             as.integer(1), as.integer(direct), PACKAGE = "vegan")$m
-#                        temp <- abuswap(temp, fixedmar, thin=1)
             } else
                 for (k in 1:burnin)
                     temp <- commsimulator(temp, method=method)
@@ -146,7 +111,6 @@
                                     as.integer(thin),
                                     as.integer(direct),
                                     PACKAGE = "vegan")$m
-#                        perm[[i]][id,] <- abuswap(temp, fixedmar, thin)
 	           } else perm[[i]][id,] <- commsimulator(temp, method=method, thin=thin)
             temp <- perm[[i]][id,]
             } # for i end

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-02-24 10:02:53 UTC (rev 700)
+++ pkg/vegan/inst/ChangeLog	2009-02-24 14:13:31 UTC (rev 701)
@@ -8,8 +8,7 @@
 	paper of Hardy 2008 (J Ecol 96, 914-926). These preserve row *and*
 	colunm occurrences, and row *or* column sums at the same
 	time. Thus these complement the methods available in vegan. Uses C
-	coce (not thoroughly tested yet). So now the much slower R
-	internal function is used. Needs some more work, and
+	code (not thoroughly tested yet). Needs some more work, and
 	documentation (examples and reference in Rd file).
 
 Version 1.16-13 (closed Feb 24, 2009)

Modified: pkg/vegan/man/permatfull.Rd
===================================================================
--- pkg/vegan/man/permatfull.Rd	2009-02-24 10:02:53 UTC (rev 700)
+++ pkg/vegan/man/permatfull.Rd	2009-02-24 14:13:31 UTC (rev 701)
@@ -38,7 +38,7 @@
   \item{ptype}{type of quantitative permutation, \code{"full"} to use \code{permatfull} and \code{"swap"} to use \code{permatswap}.}
   \item{mtype}{matrix data type, either \code{"count"} for count data, or \code{"prab"} for presence-absence type incidence data.}
   \item{times}{number of permuted matrices.}
-  \item{method}{character for method used for the swap algorithm (\code{"swap"}, \code{"tswap"}, \code{"quasiswap"}, \code{"backtrack"}) as described for function \code{\link{commsimulator}}. If \code{mtype="count"} the \code{"quasiswap"} and \code{"swap"} methods are available (see details).}
+  \item{method}{character for method used for the swap algorithm (\code{"swap"}, \code{"tswap"}, \code{"quasiswap"}, \code{"backtrack"}) as described for function \code{\link{commsimulator}}. If \code{mtype="count"} the \code{"quasiswap"}, \code{"swap"}, \code{"swsh"} and \code{"abuswap"} methods are available (see details).}
   \item{shuffle}{character, indicating whether individuals (\code{"ind"}), samples (\code{"samp"}) or both (\code{"both"}) should be shuffled, see details.}
   \item{burnin}{number of null communities discarded before proper analysis in sequential (\code{"swap", "tswap"}) methods.}
   \item{thin}{number of discarded permuted matrices between two evaluations in sequential (\code{"swap", "tswap"}) methods.}
@@ -74,7 +74,7 @@
 
 The algorithm \code{"swsh"} in the function \code{permatswap} is a hybrid algorithm. First, it makes binary quasiswaps to keep row and column incidences constant, then non-zero values are modified according to the \code{shuffle} argument (only \code{"samp"} and \code{"both"} are available in this case, because it is applied only on non-zero values).
 
-FIXME! The algorithm \code{"abuswap"} need documentation here once done.
+The algorithm \code{"abuswap"} produces two kinds of null models (based on \code{fixedmar="columns"} or \code{fixedmar="rows"}) as described in Hardy (2008; randomization sheme 2x and 3x, respectively).
 
 Constraints on row/colum sums, matrix fill, total sum and sums within
 strata can be checked by the \code{summary} method. \code{plot} method is for
@@ -115,8 +115,10 @@
 Original references for presence-absence algorithms are given on help
 page of \code{\link{commsimulator}}.
 
+Hardy, O. J. (2008) Testing the spatial phylogenetic structure of local communities: statistical performances of different null models and test statistics on a locally neutral community. Journal of Ecology 96, 914--926.
+
 Patefield, W. M. (1981) Algorithm AS159. An efficient method of generating r x c tables with given row and column totals. 
-Applied Statistics 30, 91-97.
+Applied Statistics 30, 91--97.
 }
 
 \author{\enc{P\'eter S\'olymos}{Peter Solymos}, \email{solymos at ualberta.ca} and Jari Oksanen}



More information about the Vegan-commits mailing list