[Vegan-commits] r2699 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 11 19:30:53 CET 2013


Author: jarioksa
Date: 2013-11-11 19:30:52 +0100 (Mon, 11 Nov 2013)
New Revision: 2699

Modified:
   pkg/vegan/R/anova.ccalist.R
   pkg/vegan/R/anovacca.R
Log:
anova.ccalist passes 'model' and 'parallel' permutest.cca (could be neater)

Modified: pkg/vegan/R/anova.ccalist.R
===================================================================
--- pkg/vegan/R/anova.ccalist.R	2013-11-11 10:37:56 UTC (rev 2698)
+++ pkg/vegan/R/anova.ccalist.R	2013-11-11 18:30:52 UTC (rev 2699)
@@ -1,7 +1,10 @@
 `anova.ccalist` <-
-    function(object, ..., permutations = 99)
+    function(object, permutations, model, parallel)
 {
-    ## 'object' *must* be a list of cca objects
+    ## 'object' *must* be a list of cca objects, and 'permutations'
+    ## *must* be a permutation matrix -- we assume that calling
+    ## function takes care of this, and this function is not directly
+    ## called by users.
     nmodels <- length(object)
     ## check that input is valid
     ## 1. All models must be fitted with the same method
@@ -27,11 +30,7 @@
         if(!all(trms[[o[i-1]]] %in% trms[[o[i]]]))
             stop("models must be nested")
         
-    ## Create permutation matrix if it does not exist. FIXME: should
-    ## take arguments for restricted permutation
-    if (length(permutations) == 1) 
-            permutations <- shuffleSet(N, permutations)
-    ## permutations is now matrix
+    ## Check permutation matrix
     nperm <- nrow(permutations)
     ## check
     if (ncol(permutations) != N)
@@ -42,9 +41,10 @@
     ## be used to assess the significance of differences of fitted
     ## models. This strictly requires nested models (not checked
     ## here): all terms of the smaller model must be included in the
-    ## larger model. FIXME: should pass arguments to permutest.cca.
+    ## larger model. 
     mods <- lapply(object, function(z)
-                   permutest(z, permutations = permutations))
+                   permutest.cca(z, permutations = permutations,
+                                 model = model, parallel = parallel))
     dfs <- sapply(mods, function(z) z$df)
     dev <- sapply(mods, function(z) z$chi)
     resdf <- dfs[2,]

Modified: pkg/vegan/R/anovacca.R
===================================================================
--- pkg/vegan/R/anovacca.R	2013-11-11 10:37:56 UTC (rev 2698)
+++ pkg/vegan/R/anovacca.R	2013-11-11 18:30:52 UTC (rev 2699)
@@ -32,11 +32,24 @@
     dotargs <- list(...)
     if (length(dotargs)) {
         isCCA <- sapply(dotargs, function(z) inherits(z, "cca"))
-        dotargs <- dotargs[isCCA]
-        if (length(dotargs)) {
+        if (any(isCCA)) {
+            ## we do not want to give dotargs to anova.ccalist, but we
+            ## evaluate 'parallel' and 'model' here
+            if (is.null(dotargs$model))
+                model <- "reduced"
+            else
+                model <- dotargs$model
+            if (is.null(dotargs$parallel))
+                parallel <- NULL
+            else
+                parallel <- dotargs$parallel
+            dotargs <- dotargs[isCCA]
             object <- c(list(object), dotargs)
-            sol <- anova.ccalist(object, ...,
-                                 permutations = permutations)
+            sol <-
+                anova.ccalist(object, 
+                              permutations = permutations,
+                              model = model,
+                              parallel = parallel)
             return(sol)
         }
     }



More information about the Vegan-commits mailing list