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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 14 14:36:08 CEST 2010


Author: jarioksa
Date: 2010-10-14 14:36:07 +0200 (Thu, 14 Oct 2010)
New Revision: 1332

Modified:
   pkg/vegan/R/anova.ccabyaxis.R
   pkg/vegan/inst/ChangeLog
Log:
anova.ccabyaxis really uses marginal tests for all axes

Modified: pkg/vegan/R/anova.ccabyaxis.R
===================================================================
--- pkg/vegan/R/anova.ccabyaxis.R	2010-10-12 19:04:06 UTC (rev 1331)
+++ pkg/vegan/R/anova.ccabyaxis.R	2010-10-14 12:36:07 UTC (rev 1332)
@@ -8,15 +8,11 @@
     if (is.null(object$terms)) 
         stop("Analysis is only possible for models fitted using formula")
     lc <- object$CCA$u
-    mf <- model.frame(object)
     ## Handle missing values in scores, both "omit" and "exclude" to
     ## match dims with data.
     if (!is.null(object$na.action)) {
         lc <- stats:::napredict.exclude(object$na.action, lc)
-        mf <- lapply(mf, function(x) stats:::napredict.exclude(object$na.action, x))
-        mf <- as.data.frame(mf)
     }
-    newdata <- cbind(lc, mf)
     axnam <- colnames(lc)
     df <- c(rep(1, rnk), object$CA$rank)
     chi <- c(object$CCA$eig, Residual = object$CA$tot.chi)
@@ -24,23 +20,23 @@
     nperm <- c(numeric(rnk), NA)
     Pval <- rep(NA, rnk+1)
     out <- data.frame(df, chi, Fval, nperm, Pval)
-    sol <- anova(object, first = TRUE, ...)
+    environment(object$terms) <- environment()
+    fla <- update(formula(object), . ~ lc[,1] + Condition(lc[,-1]))
+    sol <- anova(update(object, fla),  ...)
     out[c(1, rnk + 1), ] <- sol
     seed <- attr(sol, "Random.seed")
     attr(out, "names") <- attr(sol, "names")
-    attr(out, "heading") <- attr(sol, "heading")
+    .call <- pasteCall(object$call, "Model:")
+    attr(out, "heading") <- sub(" \n","", .call)
     attr(out, "Random.seed") <- seed
     bigseed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
     bigperm <- out$N.Perm[1]
-    environment(object$terms) <- environment()
     if (rnk > 1) {
         for (.ITRM in 2:rnk) {
-            zz <- paste(paste("Condition(", axnam[1:(.ITRM - 1)], 
-                ")"), collapse = "+")
-            fla <- update(formula(object), paste(". ~ . +", zz))
-            sol <- update(object, fla, data = newdata)
+            fla <- update(formula(object),  .~ lc[, .ITRM] + Condition(lc[,-(.ITRM)]) )
+            sol <- update(object, fla)
             assign(".Random.seed", seed, envir = .GlobalEnv)
-            out[.ITRM, ] <- as.matrix(anova(sol, first = TRUE, ...))[1, 
+            out[.ITRM, ] <- as.matrix(anova(sol, ...))[1, 
                 ]
             if (out[.ITRM, "N.Perm"] > bigperm) {
                 bigperm <- out[.ITRM, "N.Perm"]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-10-12 19:04:06 UTC (rev 1331)
+++ pkg/vegan/inst/ChangeLog	2010-10-14 12:36:07 UTC (rev 1332)
@@ -4,6 +4,14 @@
 
 Version 1.18-13 (opened September 26, 2010)
 
+	* anova.cca(..., by = "axis"): now really uses marginal tests for
+	every axis. Significance of axis k with LC scores lc is from model
+	update(object, . ~ lc[,k] + Condition(lc[,-k])). That is, That is,
+	axis k is used as constraint and all other axes as conditions,
+	when axis k is analysed. This also solves the failure of
+	anova(..., by = "ax") of rda(dune ~ poly(pH, 2) + Baresoil,
+	varechem) of PR#945, but no other problems of the same report.
+
 	* treedive: handles trivial cases of zero (diversity NA) or one
 	species (diversity 0). 
 



More information about the Vegan-commits mailing list