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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 5 12:38:37 CET 2013


Author: jarioksa
Date: 2013-02-05 12:38:37 +0100 (Tue, 05 Feb 2013)
New Revision: 2412

Modified:
   pkg/vegan/R/predict.cca.R
   pkg/vegan/R/predict.rda.R
   pkg/vegan/R/simulate.rda.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/predict.cca.Rd
Log:
predict.cca(..., type='work') & predict.rda(..., type='resp') handle partial models

Modified: pkg/vegan/R/predict.cca.R
===================================================================
--- pkg/vegan/R/predict.cca.R	2013-02-05 10:58:58 UTC (rev 2411)
+++ pkg/vegan/R/predict.cca.R	2013-02-05 11:38:37 UTC (rev 2412)
@@ -31,13 +31,16 @@
         }
         if (take > 0) 
             Xbar <- u %*% slam %*% t(v)
-        if (!is.null(object$pCCA)) 
-            warning("Conditional ('partial') component ignored")
         rc <- outer(rs, cs)
-        if (type == "response") 
+        if (type == "response") {
+            if (!is.null(object$pCCA)) 
+                warning("Conditional ('partial') component ignored")
             out <- (Xbar + 1) * rc * gtot
-        else                 # type == "working"
+        } else {                # type == "working"
             out <- Xbar * sqrt(rc)
+            if (!is.null(object$pCCA))
+                out <- out + object$pCCA$Fit
+        }
     }
     else if (type == "lc") {
         if (model == "CA") 

Modified: pkg/vegan/R/predict.rda.R
===================================================================
--- pkg/vegan/R/predict.rda.R	2013-02-05 10:58:58 UTC (rev 2411)
+++ pkg/vegan/R/predict.rda.R	2013-02-05 11:38:37 UTC (rev 2412)
@@ -25,8 +25,6 @@
         w <- u
     slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take)
     if (type %in% c("response", "working")) {
-        if (!is.null(object$pCCA)) 
-            warning("Conditional ('partial') component ignored")
         if (!missing(newdata)) {
             u <- predict(object, type = if(model == "CCA") "lc" else "wa",
                          newdata = newdata, rank = take)
@@ -52,7 +50,11 @@
                 if (!is.null(scal)) 
                     out <- sweep(out, 2, scal, "*")
                 out <- sweep(out, 2, cent, "+")
+                if (!is.null(object$pCCA))
+                    out <- out + object$pCCA$Fit
             } else {
+                if (!is.null(object$pCCA)) 
+                    warning("Conditional ('partial') component ignored")
                 out <- out/sqrt(nrow(out) - 1)
             }
         }

Modified: pkg/vegan/R/simulate.rda.R
===================================================================
--- pkg/vegan/R/simulate.rda.R	2013-02-05 10:58:58 UTC (rev 2411)
+++ pkg/vegan/R/simulate.rda.R	2013-02-05 11:38:37 UTC (rev 2412)
@@ -30,9 +30,6 @@
     ## an array of response matrices
     
     ftd <- predict(object, type = "response", rank = rank)
-    ## pRDA: add partial Fit to the constrained
-    if (!is.null(object$pCCA))
-        ftd <- ftd + object$pCCA$Fit
     ## Generate an array
     ans <- array(0, c(dim(ftd), nsim))
     for (i in seq_len(nsim)) {
@@ -102,9 +99,6 @@
     sq.r <- sqrt(object$rowsum)
     ## Fitted value
     ftd <- predict(object, type = "working", rank = rank)
-    ## pCCA: add partial Fit to the constrained
-    if (!is.null(object$pCCA))
-        ftd <- ftd + object$pCCA$Fit
     ## Residual Xbar need weighting and back-weighting
     Xbar <- sweep(object$CA$Xbar, 1, sq.r, "*")
     ## Simulation

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-02-05 10:58:58 UTC (rev 2411)
+++ pkg/vegan/inst/ChangeLog	2013-02-05 11:38:37 UTC (rev 2412)
@@ -8,6 +8,12 @@
 	rda, capscale & adonis, and telling how to do this
 	approximately. Please comment and correct.
 
+	* predict.rda, predict.cca: The partial term is handled in
+	predict.rda(..., type = "response") and in predict.cca(..., type =
+	"working").  The partial term was earlier handled only in
+	corresponding simulate.rda(), simulate.cca() functions, but it was
+	now moved to these more basic functions.
+
 	* oecosimu: changed the structure of the oecosimu() result
 	object. It now returns a list of two items: "statistic" is the
 	observed statistic, and "oecosimu" which contains the simulation

Modified: pkg/vegan/man/predict.cca.Rd
===================================================================
--- pkg/vegan/man/predict.cca.Rd	2013-02-05 10:58:58 UTC (rev 2411)
+++ pkg/vegan/man/predict.cca.Rd	2013-02-05 11:38:37 UTC (rev 2412)
@@ -136,13 +136,14 @@
   \code{\link{rda}} and \code{\link{capscale}}. This is often known as
   calibration, bioindication or environmental reconstruction.
   Basically, the method is similar to projecting site scores onto biplot
-  arrows, but it uses regression coefficients.  The function can be called
-  with \code{newdata} so that cross-validation is possible.  The
+  arrows, but it uses regression coefficients.  The function can be
+  called with \code{newdata} so that cross-validation is possible.  The
   \code{newdata} may contain new sites, but species must match in the
-  original and new data  The function
-  does not work with \sQuote{partial} models with \code{Condition} term,
-  and it cannot be used with \code{newdata} for \code{\link{capscale}}
-  results.  The results may only be interpretable for continuous variables.
+  original and new data.  The function may not work with
+  \sQuote{partial} models with \code{Condition} term, or the partial
+  term may be ignored with a warning.  The function cannot be used with
+  \code{newdata} for \code{\link{capscale}} results.  The results may
+  only be interpretable for continuous variables.
   
   Function \code{coef} will give the regression coefficients from centred
   environmental variables (constraints and conditions) to linear



More information about the Vegan-commits mailing list