[Vegan-commits] r486 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 27 11:31:33 CEST 2008


Author: jarioksa
Date: 2008-08-27 11:31:33 +0200 (Wed, 27 Aug 2008)
New Revision: 486

Modified:
   pkg/R/oecosimu.R
   pkg/inst/ChangeLog
   pkg/man/oecosimu.Rd
Log:
oecosimu: the name of the statistic can be given as an argument

Modified: pkg/R/oecosimu.R
===================================================================
--- pkg/R/oecosimu.R	2008-08-25 16:39:58 UTC (rev 485)
+++ pkg/R/oecosimu.R	2008-08-27 09:31:33 UTC (rev 486)
@@ -1,6 +1,6 @@
 `oecosimu` <-
     function(comm, nestfun, method, nsimul=99,
-             burnin=0, thin=1, ...)
+             burnin=0, thin=1, statistic = "statistic", ...)
 {
     nestfun <- match.fun(nestfun)
     method <- match.arg(method, c("r00", "r0", "r1", "r2", "c0",
@@ -9,7 +9,7 @@
     comm <- ifelse(comm > 0, 1, 0)
     ind <- nestfun(comm, ...)
     if (is.list(ind))
-        indstat <- ind[["statistic"]]
+        indstat <- ind[[statistic]]
     else
         indstat <- ind
     n <- length(indstat)
@@ -33,7 +33,7 @@
             x <- commsimulator(x, method = method, thin = thin)
             tmp <- nestfun(x, ...)
             if (is.list(tmp))
-                simind[,i] <- tmp[["statistic"]]
+                simind[,i] <- tmp[[statistic]]
             else
                 simind[,i] <- tmp
         }
@@ -43,7 +43,7 @@
             x <- commsimulator(comm, method=method)
             tmp <- nestfun(x,...)
             if (is.list(tmp))
-                simind[,i] <- tmp[["statistic"]]
+                simind[,i] <- tmp[[statistic]]
             else
                 simind[,i] <- tmp
         }
@@ -52,7 +52,7 @@
     p <- 2*pmin(rowSums(indstat > simind), rowSums(indstat < simind))
     p <- (p + 1)/(nsimul + 1)
     if (is.null(names(indstat)))
-        names(indstat) <- "Statistic"
+        names(indstat) <- statistic
     if (!is.list(ind))
         ind <- list(statistic = ind)
     ind$oecosimu <- list(z = z, pval = p, simulated=simind, method=method,

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-08-25 16:39:58 UTC (rev 485)
+++ pkg/inst/ChangeLog	2008-08-27 09:31:33 UTC (rev 486)
@@ -10,9 +10,10 @@
 	discuss estimating signifcance using oecosimu().
 
 	* oecosimu: accepts now a vector of statistics and plain
-	statistics instead of the list item statistics. This means that
-	things like species richness for sites can be analysed with
-	approprite simulation model (needs fine tuning, though).
+	statistics instead of the list item statistics, and the user can
+	define the name of the statistic in the function call. This means
+	that things like functional diversity (treedive) for sites can be
+	analysed with approprite simulation model.
 	
 	* ordiParseFormula: formula of the partial terms has the same
 	environment as the general formula. Cures some tricky issues when

Modified: pkg/man/oecosimu.Rd
===================================================================
--- pkg/man/oecosimu.Rd	2008-08-25 16:39:58 UTC (rev 485)
+++ pkg/man/oecosimu.Rd	2008-08-27 09:31:33 UTC (rev 486)
@@ -25,7 +25,8 @@
 }
 
 \usage{
-oecosimu(comm, nestfun, method, nsimul = 99, burnin = 0, thin = 1, ...)
+oecosimu(comm, nestfun, method, nsimul = 99, burnin = 0, thin = 1,
+   statistic = "statistic",  ...)
 nestedchecker(comm)
 nestedn0(comm)
 nesteddisc(comm)
@@ -39,7 +40,8 @@
   \item{comm}{Community data. }
   \item{nestfun}{Function to analyse nestedness. Some functions are
   provided in \pkg{vegan}, but any function can be used if it accepts the
-  community as the first argument, and returns the result in item
+  community as the first argument, and returns either a plain number or
+  the result in list item with the name defined in argument
   \code{statistic}. See Examples for defining your own functions.}
   \item{method}{Null model method. See details.}
   \item{nsimul}{Number of simulated null communities.}
@@ -48,6 +50,8 @@
   \item{thin}{Number of discarded null communities between two
   evaluations of nestedness statistic in sequential methods
   \code{"swap"} and \code{"tswap"}.}
+  \item{statistic}{The name of the statistic returned by
+    \code{nestedfun}} 
   \item{kind}{The kind of plot produced.}
   \item{x}{Matrix for \code{commsimulator} or a \code{plot} object.}
   \item{col}{Colour scheme for matrix temperatures.}
@@ -94,12 +98,14 @@
   \code{\link{vignette}} or \code{\link{vegandocs}}. 
 
   In addition to these functions provided in \pkg{vegan}, any function
-  can be used that takes \code{comm} as the first argument, and
-  returns the nestedness index in item \code{statistic}. Function
-  \code{\link{chisq.test}} is such a function, and examples show how
-  to do this in general.  If you write a function that may be useful
-  to others, please consider submitting it to \pkg{vegan} for others
-  to enjoy (you will be credited as an author of that function).
+  can be used that takes \code{comm} as the first argument, and returns
+  the nestedness index either as plain numeric value or in an item with
+  name defined in \code{statistic} (which defaults to
+  \code{"statistic"}). Function \code{\link{chisq.test}} is such a
+  function, and examples show how to do this in general.  If you write a
+  function that may be useful to others, please consider submitting it
+  to \pkg{vegan} for others to enjoy (you will be credited as an author
+  of that function).
 
   Function \code{commsimulator} implements null models for community
   composition. The implemented models are \code{r00} which maintains the
@@ -236,12 +242,12 @@
   \code{thin}ning in large matrices. You should plot the simulated
   values to see that they are more or less stationary and there is no
   trend. Method \code{quasiswap} is implemented
-  in plain R, and it is very slow, and it slows down very strongly
-  with big matrices. In general, \code{backtrack} is faster and less
-  sensitive to matrix size, but it also can be very slow.
+  in C and it is much faster than \code{backtrack}.  Method
+  \code{backtrack} may be removed from later releases of \pkg{vegan}
+  because it is slow, but it is still included for comparison.
 
   If you wonder about the name of \code{oecosimu}, look at journal
-names in the References.  }
+  names in the References.  }
 
 \seealso{ \code{\link{r2dtable}} generates table with given marginals but
   with entries above one.  Function \code{\link[labdsv]{rndtaxa}}
@@ -256,11 +262,11 @@
 ## Use the first eigenvalue of correspondence analysis as an index
 ## of structure: a model for making your own functions.
 ## This is a minimal structure; fancier functions give fancier results
-caeval <- function(x) list(statistic = decorana(x, ira=1)$evals[1])
+caeval <- function(x) decorana(x, ira=1)$evals
 out <- oecosimu(sipoo, caeval, "swap", burnin=100, thin=10)
 out
 ## Inspect the swap sequence
-plot(out$oecosimu$simulated, type="l")
+matplot(t(out$oecosimu$simulated), type="l")
 }
 \keyword{ multivariate }
 



More information about the Vegan-commits mailing list