[Vegan-commits] r2054 - in branches/2.0: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 29 08:19:08 CET 2012


Author: jarioksa
Date: 2012-01-29 08:18:57 +0100 (Sun, 29 Jan 2012)
New Revision: 2054

Modified:
   branches/2.0/R/RsquareAdj.R
   branches/2.0/R/varpart2.R
   branches/2.0/R/varpart3.R
   branches/2.0/R/varpart4.R
   branches/2.0/inst/ChangeLog
   branches/2.0/inst/NEWS.Rd
   branches/2.0/man/RsquareAdj.Rd
   branches/2.0/man/varpart.Rd
Log:
merge r2052 (do not scale constraints in varpart) and r2053 (adjusted R2 for partial RDA)

Modified: branches/2.0/R/RsquareAdj.R
===================================================================
--- branches/2.0/R/RsquareAdj.R	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/R/RsquareAdj.R	2012-01-29 07:18:57 UTC (rev 2054)
@@ -21,10 +21,15 @@
     R2 <- x$CCA$tot.chi/x$tot.chi
     m <- x$CCA$qrank
     n <- nrow(x$CCA$u)
-    if (is.null(x$pCCA))
+    if (is.null(x$pCCA)) {
         radj <- RsquareAdj(R2, n, m)
-    else
-        radj <- NA
+    } else {
+        ## Partial model: same adjusted R2 as for component [a] in two
+        ## source varpart model
+        R2p <- x$pCCA$tot.chi/x$tot.chi
+        p <- x$pCCA$rank
+        radj <- RsquareAdj(R2 + R2p, n, m + p) - RsquareAdj(R2p, n, p)
+    }
     list(r.squared = R2, adj.r.squared = radj)
 }
 
@@ -33,8 +38,6 @@
     function(x, ...)
 {
     R2 <- x$CCA$tot.chi/x$tot.chi
-    m <- x$CCA$qrank
-    n <- nrow(x$CCA$u)
     radj <- NA
     list(r.squared = R2, adj.r.squared = radj)
 }

Modified: branches/2.0/R/varpart2.R
===================================================================
--- branches/2.0/R/varpart2.R	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/R/varpart2.R	2012-01-29 07:18:57 UTC (rev 2054)
@@ -15,8 +15,8 @@
     if (n2 != n) 
         stop("Y and X2 do not have the same number of rows")
     Y <- scale(Y, center = TRUE, scale = FALSE)
-    X1 <- scale(X1)
-    X2 <- scale(X2)
+    X1 <- scale(X1, center = TRUE, scale = FALSE)
+    X2 <- scale(X2, center = TRUE, scale = FALSE)
     SS.Y <- sum(Y * Y)
     dummy <- simpleRDA2(Y, X1, SS.Y, mm1)
     ab.ua <- dummy$Rsquare

Modified: branches/2.0/R/varpart3.R
===================================================================
--- branches/2.0/R/varpart3.R	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/R/varpart3.R	2012-01-29 07:18:57 UTC (rev 2054)
@@ -20,9 +20,9 @@
     if (n3 != n) 
         stop("Y and X3 do not have the same number of rows")
     Y <- scale(Y, center = TRUE, scale = FALSE)
-    X1 <- scale(X1, center = TRUE, scale = TRUE)
-    X2 <- scale(X2, center = TRUE, scale = TRUE)
-    X3 <- scale(X3, center = TRUE, scale = TRUE)
+    X1 <- scale(X1, center = TRUE, scale = FALSE)
+    X2 <- scale(X2, center = TRUE, scale = FALSE)
+    X3 <- scale(X3, center = TRUE, scale = FALSE)
     SS.Y <- sum(Y * Y)
     dummy <- simpleRDA2(Y, X1, SS.Y, mm1)
     adfg.ua <- dummy$Rsquare

Modified: branches/2.0/R/varpart4.R
===================================================================
--- branches/2.0/R/varpart4.R	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/R/varpart4.R	2012-01-29 07:18:57 UTC (rev 2054)
@@ -25,10 +25,10 @@
     if (n4 != n) 
         stop("Y and X4 do not have the same number of rows")
     Y <- scale(Y, center = TRUE, scale = FALSE)
-    X1 <- scale(X1, center = TRUE, scale = TRUE)
-    X2 <- scale(X2, center = TRUE, scale = TRUE)
-    X3 <- scale(X3, center = TRUE, scale = TRUE)
-    X4 <- scale(X4, center = TRUE, scale = TRUE)
+    X1 <- scale(X1, center = TRUE, scale = FALSE)
+    X2 <- scale(X2, center = TRUE, scale = FALSE)
+    X3 <- scale(X3, center = TRUE, scale = FALSE)
+    X4 <- scale(X4, center = TRUE, scale = FALSE)
     SS.Y <- sum(Y * Y)
     dummy <- simpleRDA2(Y, X1, SS.Y)
     aeghklno.ua <- dummy$Rsquare

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/inst/ChangeLog	2012-01-29 07:18:57 UTC (rev 2054)
@@ -3,7 +3,9 @@
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
 Version 2.0-3 (opened November 13, 2011)
-	
+
+	* merge r2053: implement adjusted R2 for partial RDA.
+	* merge r2052: do not scale constraints in varpart[234].
 	* merge r2049: capscale robust for zeroed centroids.
 	* merge r2044: ordistep robust for complete aliasing.
 	* merge r2043: anova.ccabymargin robust for zero effects.

Modified: branches/2.0/inst/NEWS.Rd
===================================================================
--- branches/2.0/inst/NEWS.Rd	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/inst/NEWS.Rd	2012-01-29 07:18:57 UTC (rev 2054)
@@ -27,6 +27,13 @@
       \item \code{betadisper()} failed when the \code{groups} was a
       factor with empty levels.
 
+      \item Some constrained ordination methods and their support
+      functions are more robust in border cases (completely aliased
+      effects, saturated models, user requests for non-existng scores
+      etc). Concerns \code{capscale}, \code{ordistep}, \code{varpart},
+      \code{plot} function for constrained ordination, and
+      \code{anova(<cca.object>, by = "margin")}.
+
     }
   } % end bug fixes	
 		  
@@ -42,6 +49,12 @@
        \item \code{oecosimu} displays the mean of simulations and
        describes alternative hypothesis more clearly in the printed
        output. 
+
+       \item Implemented adjusted \eqn{R^2}{R-squared} for partial
+       RDA. For partial model \code{rda(Y ~ X1 + Condition(X2))} this
+       is the same as the component \code{[a] = X1|X2} in variance
+       partition in \code{varpart} and describes the marginal (unique)
+       effect of constraining term to adjusted \eqn{R^2}{R-squared}.
      
      }
   } % end new features

Modified: branches/2.0/man/RsquareAdj.Rd
===================================================================
--- branches/2.0/man/RsquareAdj.Rd	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/man/RsquareAdj.Rd	2012-01-29 07:18:57 UTC (rev 2054)
@@ -40,17 +40,31 @@
   and then the functions will return \code{NA}. There is no adjusted
   R-squared in \code{\link{cca}}, in partial \code{\link{rda}}, and
   R-squared values are available only for \code{\link{gaussian}}
-  models in \code{\link{glm}}. 
-}
+  models in \code{\link{glm}}.
 
+  The raw \eqn{R^2}{R-squared} of partial \code{rda} gives the
+  proportion explained after removing the variation due to conditioning
+  (partial) terms; Legendre et al. (2011) call this semi-partial
+  \eqn{R^2}{R-squared}. The adjusted \eqn{R^2}{R-squared} is found as
+  the difference of adjusted \eqn{R^2}{R-squared} values of joint effect
+  of partial and constraining terms and partial term alone, and it is
+  the same as the adjusted \eqn{R^2}{R-squared} of component \code{[a] =
+  X1|X2} in two-component variation partition in \code{\link{varpart}}.
+  }
+
 \value{ The functions return a list of items \code{r.squared} and
 \code{adj.r.squared}.  
 }
 
-\references{ 
+\references{
+  Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the
+  significance of canonical axes in redundancy analysis. 
+  \emph{Methods in Ecology and Evolution} 2, 269--277.
+  
   Peres-Neto, P., P. Legendre, S. Dray and D. Borcard. 2006. Variation
   partitioning of species data matrices: estimation and comparison of
-  fractions. \emph{Ecology} 87: 2614-2625.  }
+  fractions. \emph{Ecology} 87, 2614--2625.
+}
 
 \seealso{
   \code{\link{varpart}} uses \code{RsquareAdj}.

Modified: branches/2.0/man/varpart.Rd
===================================================================
--- branches/2.0/man/varpart.Rd	2012-01-27 09:56:05 UTC (rev 2053)
+++ branches/2.0/man/varpart.Rd	2012-01-29 07:18:57 UTC (rev 2054)
@@ -234,9 +234,11 @@
 # Change the data frame with factors into numeric model matrix
 mm <- model.matrix(~ SubsDens + WatrCont + Substrate + Shrub + Topo, mite.env)[,-1]
 mod <- varpart(decostand(mite, "hel"), mm, mite.pcnm)
-# Test fraction [a] using RDA:
-rda.result <- rda(decostand(mite, "hell"), mm, mite.pcnm)
-anova(rda.result, step=200, perm.max=200)
+# Test fraction [a] using partial RDA:
+aFrac <- rda(decostand(mite, "hel"), mm, mite.pcnm)
+anova(aFrac, step=200, perm.max=200)
+# RsquareAdj gives the same result as component [a] of varpart
+RsquareAdj(aFrac)
 
 # Three explanatory matrices 
 mod <- varpart(mite, ~ SubsDens + WatrCont, ~ Substrate + Shrub + Topo,



More information about the Vegan-commits mailing list