[Analogue-commits] r129 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat May 30 00:30:12 CEST 2009


Author: gsimpson
Date: 2009-05-30 00:30:12 +0200 (Sat, 30 May 2009)
New Revision: 129

Modified:
   pkg/R/wa.R
   pkg/man/wa.Rd
Log:
wa now uses WApred and WATpred and returns 'options.tol', a list containing the tolerance tweaking options.
Updated the Rd file.

Modified: pkg/R/wa.R
===================================================================
--- pkg/R/wa.R	2009-05-29 22:23:07 UTC (rev 128)
+++ pkg/R/wa.R	2009-05-29 22:30:12 UTC (rev 129)
@@ -12,7 +12,7 @@
     env <- as.numeric(env)
     ## drop species with no information
     if(any(csum <- colSums(x) == 0))
-    x <- x[, !csum, drop = FALSE]
+        x <- x[, !csum, drop = FALSE]
     ## sample summaries
     n.samp <- nrow(x)
     n.spp <- ncol(x)
@@ -57,14 +57,9 @@
     }
     ## calculate WA estimate of env for each site
     if(tol.dw) {
-        tol2 <- tol^2
-        wa.env <- rowSums(sweep(sweep(x, 2, wa.optima, "*",
-                                      check.margin = FALSE),
-                                2, tol2, "/", check.margin = FALSE)) /
-                                    rowSums(sweep(x, 2, tol2, "/",
-                                                  check.margin = FALSE))
+        wa.env <- WATpred(x, wa.optima, tol)
     } else {
-        wa.env <- ((x %*% wa.optima) / rowSums(x))[,1, drop = TRUE]
+        wa.env <- WApred(x, wa.optima)
     }
     ## taken averages twice so deshrink
     expanded <- switch(deshrink,
@@ -103,7 +98,13 @@
                 n.samp = n.samp, n.spp = n.spp,
                 deshrink = deshrink, tol.dw = tol.dw,
                 call = .call,
-                orig.x = x, orig.env = env)
+                orig.x = x, orig.env = env,
+                options.tol =
+                list(useN2 = useN2,
+                     na.tol = na.tol,
+                     small.tol = small.tol,
+                     min.tol = min.tol,
+                     f = f))
     class(res) <- "wa"
     return(res)
 }

Modified: pkg/man/wa.Rd
===================================================================
--- pkg/man/wa.Rd	2009-05-29 22:23:07 UTC (rev 128)
+++ pkg/man/wa.Rd	2009-05-29 22:30:12 UTC (rev 129)
@@ -130,6 +130,9 @@
   \item{call}{The matched function call.}
   \item{orig.x}{The training set species data.}
   \item{orig.env}{The response data for the training set.}
+  \item{options.tol}{A list, containing the values of the arguments
+  \code{useN2}, \code{na.tol}, \code{small.tol}, \code{min.tol}, and
+  \code{f}.}
   \item{terms, model}{Model \code{\link{terms}} and \code{\link{model.frame}}
     components. Only returned by the \code{formula} method of
     \code{wa}.}



More information about the Analogue-commits mailing list