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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Nov 29 11:32:12 CET 2009


Author: jarioksa
Date: 2009-11-29 11:32:11 +0100 (Sun, 29 Nov 2009)
New Revision: 1073

Modified:
   pkg/vegan/R/simulate.rda.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/simulate.rda.Rd
Log:
simulate.rda can permute residuals and do bootstrap samples

Modified: pkg/vegan/R/simulate.rda.R
===================================================================
--- pkg/vegan/R/simulate.rda.R	2009-11-29 09:31:48 UTC (rev 1072)
+++ pkg/vegan/R/simulate.rda.R	2009-11-29 10:32:11 UTC (rev 1073)
@@ -1,5 +1,5 @@
 `simulate.rda` <-
-    function(object, nsim = 1, seed = NULL, ...) 
+    function(object, nsim = 1, seed = NULL, indx = NULL, ...) 
 {
     ## First check cases that won't work (yet?)
     if (!is.null(object$pCCA))
@@ -20,9 +20,12 @@
     if (nsim > 1)
         .NotYetUsed("nsim")
     ftd <- fitted(object)
-    ans <- as.data.frame(ftd + matrix(rnorm(length(ftd), 
-        sd = outer(rep(1,nrow(ftd)), sd(object$CA$Xbar))), 
-        nrow = nrow(ftd)))
+    if (is.null(indx))
+        ans <- as.data.frame(ftd + matrix(rnorm(length(ftd), 
+               sd = outer(rep(1,nrow(ftd)), sd(object$CA$Xbar))), 
+               nrow = nrow(ftd)))
+    else
+        ans <- as.data.frame(ftd + object$CA$Xbar[indx,])
     attr(ans, "seed") <- RNGstate
     ans
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-11-29 09:31:48 UTC (rev 1072)
+++ pkg/vegan/inst/ChangeLog	2009-11-29 10:32:11 UTC (rev 1073)
@@ -17,6 +17,12 @@
 
 	* predict.rda: works now with rank = 0 -- returns matrix of column
 	means.  (Not yet done for predict.cca.)
+
+	* simulate.rda: can now add permuted residuals to the fitted
+	values. Experimental, low level interface that requires giving the
+	index of right length. The permutation index can contain
+	duplicates such as from sample(nrow(data), replace = TRUE) so that
+	bootstrapping is possible unlike in anova.cca/permutest.cca. 
 	
 Version 1.16-32 (closed November 13, 2009)
 

Modified: pkg/vegan/man/simulate.rda.Rd
===================================================================
--- pkg/vegan/man/simulate.rda.Rd	2009-11-29 09:31:48 UTC (rev 1072)
+++ pkg/vegan/man/simulate.rda.Rd	2009-11-29 10:32:11 UTC (rev 1073)
@@ -11,7 +11,7 @@
 }
 
 \usage{
-\method{simulate}{rda}(object, nsim = 1, seed = NULL, ...)
+\method{simulate}{rda}(object, nsim = 1, seed = NULL, indx = NULL, ...)
 }
 \arguments{
   \item{object}{an object representing a fitted \code{\link{rda}} model.}
@@ -20,6 +20,12 @@
   \item{seed}{an object specifying if and how the random number
     generator should be initialized (\sQuote{seeded}). See 
     \code{\link{simulate}} for details. }
+  \item{indx}{Index of residuals added to the fitted values, such as
+    produced by  \code{\link{permuted.index}},
+    \code{\link{permuted.index2}} or \code{\link{sample}}. The index can
+    have duplicate entries so that bootstrapping is allowed. If null,
+    parametric simulation is used and Gaussian error is added to the
+    fitted values.}
   \item{\dots}{additional optional arguments (ignored). }
 }
 



More information about the Vegan-commits mailing list