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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 6 12:00:34 CET 2013


Author: jarioksa
Date: 2013-11-06 12:00:27 +0100 (Wed, 06 Nov 2013)
New Revision: 2657

Modified:
   pkg/vegan/NAMESPACE
   pkg/vegan/R/bioenv.default.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/bioenv.Rd
Log:
add bioenvdist() to extract environmental distances used within bioenv

Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE	2013-11-05 22:51:25 UTC (rev 2656)
+++ pkg/vegan/NAMESPACE	2013-11-06 11:00:27 UTC (rev 2657)
@@ -5,8 +5,8 @@
 
 export(CCorA, MOStest, RsquareAdj, SSarrhenius, SSgitay, SSgleason,
 SSlomolino, adipart, adonis, anosim, beals, betadisper, betadiver,
-bgdispersal, bioenv, bstick, cIndexKM, calibrate, capscale, cascadeKM,
-cca, commsimulator, contribdiv, clamtest, commsim, decorana,
+bgdispersal, bioenv, bioenvdist, bstick, cIndexKM, calibrate, capscale,
+cascadeKM, cca, commsimulator, contribdiv, clamtest, commsim, decorana,
 decostand, designdist, coverscale, dispweight, dispindmorisita, distconnected,
 diversity, downweight, drarefy, eigengrad, eigenvals, envfit,
 estaccumR, estimateR, eventstar, factorfit, fisherfit, fitspecaccum,

Modified: pkg/vegan/R/bioenv.default.R
===================================================================
--- pkg/vegan/R/bioenv.default.R	2013-11-05 22:51:25 UTC (rev 2656)
+++ pkg/vegan/R/bioenv.default.R	2013-11-06 11:00:27 UTC (rev 2657)
@@ -121,11 +121,31 @@
             flush.console()
         }
     }
+    whichbest <- which.max(lapply(best, function(tmp) tmp$est))
     out <- list(names = colnames(env), method = method, index = index,
                 metric = metric, upto = upto, models = best,
-                partial = partpart)
+                whichbest = whichbest,
+                partial = partpart, x = x, distfun = distfun)
     out$call <- match.call()
     out$call[[1]] <- as.name("bioenv")
     class(out) <- "bioenv"
     out
 }
+
+## Function to extract the environmental distances used within
+## bioenv. The default is to take the best model, but any model can be
+## specified by its number.
+
+`bioenvdist`  <-
+    function(x, which = "best")
+{
+    ## any non-numeric argument is regarded as "best"
+    if(!is.numeric(which))
+        which <- x$whichbest
+    if (x$metric == "gower")
+        require(cluster) ||
+            stop("requires package 'cluster' for 'gower' metric")
+    x$distfun(x$x[, x$models[[which]]$best, drop = FALSE])
+}
+
+

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-11-05 22:51:25 UTC (rev 2656)
+++ pkg/vegan/inst/ChangeLog	2013-11-06 11:00:27 UTC (rev 2657)
@@ -4,8 +4,16 @@
 
 Version 2.1-38 (opened November 5, 2013)
 
-	* DESCRIPTION: depends on permute >= 0.7-5.
+	* DESCRIPTION: depends on permute >= 0.7-5, where the
+	permute::how() result object can be updated.
 
+	* bioenv: returns now the number of the best model ('whichbest'),
+	the standardized environmental data ('x') and the distance
+	function used for the environmental data ('distfun'). New function
+	bioenvdist() uses these to re-calculate the environmental
+	distances for the best model, or any other model selected by its
+	number.
+
 	* permutest.cca: permutation test uses 'permute' package. The old
 	interface was retained, and 'permutations' can be a single number
 	or a permutation matrix (as previously), but now it can also be a

Modified: pkg/vegan/man/bioenv.Rd
===================================================================
--- pkg/vegan/man/bioenv.Rd	2013-11-05 22:51:25 UTC (rev 2656)
+++ pkg/vegan/man/bioenv.Rd	2013-11-06 11:00:27 UTC (rev 2657)
@@ -3,6 +3,7 @@
 \alias{bioenv.default}
 \alias{bioenv.formula}
 \alias{summary.bioenv}
+\alias{bioenvdist}
 
 \title{Best Subset of Environmental Variables with
   Maximum (Rank) Correlation with Community Dissimilarities }
@@ -17,6 +18,7 @@
        metric = c("euclidean", "mahalanobis", "manhattan", "gower"),
        parallel = getOption("mc.cores"), ...)
 \method{bioenv}{formula}(formula, data, ...)
+bioenvdist(x, which = "best")
 }
 
 \arguments{
@@ -37,6 +39,9 @@
     cluster.  With \code{parallel = 1} uses ordinary, non-parallel
     processing. The parallel processing is done with \pkg{parallel}
     package which is available only for \R 2.14.0 and later.}
+  \item{x}{\code{bioenv} result object.}
+  \item{which}{The number of the model for which the environmental
+    distances are evaluated, or the \code{"best"} model.}
   \item{...}{Other arguments passed to \code{\link{cor}}.}
 }
 \details{
@@ -77,6 +82,10 @@
   class \code{\link{dist}}. The
   \code{partial} item can be used with any correlation \code{method},
   but it is strictly correct only for Pearson.
+
+  Function \code{bioenvdist} recalculates the environmental distances
+  used within the function. The default is to calculate distances for
+  the best model, but the number of any model can be given.
   
   Clarke & Ainsworth (1993) suggested this method to be used for
   selecting the best subset of environmental variables in interpreting
@@ -92,10 +101,12 @@
   Windows).  In addition, Clarke & Ainsworth suggested a novel method of
   rank correlation which is not available in the current function.
 }
+
 \value{
   The function returns an object of class \code{bioenv} with a
   \code{summary} method.
 }
+
 \references{
   Clarke, K. R & Ainsworth, M. 1993. A method of linking multivariate
   community structure to environmental variables. \emph{Marine Ecology
@@ -103,17 +114,17 @@
 }
 \author{ Jari Oksanen }
 
-\note{
-  If you want to study the \sQuote{significance} of \code{bioenv}
+\note{ If you want to study the \sQuote{significance} of \code{bioenv}
   results, you can use function \code{\link{mantel}} or
   \code{\link{mantel.partial}} which use the same definition of
-  correlation. 
-  However, \code{bioenv} standardizes environmental variables to unit standard
-  deviation using function \code{\link{scale}} and you must do the same
-  in \code{\link{mantel}} for comparable results. Further, \code{bioenv}
-  selects variables to maximize the Mantel correlation, and significance
-  tests based on \emph{a priori} selection of variables are biased. 
-  }
+  correlation.  However, \code{bioenv} standardizes environmental
+  variables depending on the used metric, and you must do the same in
+  \code{\link{mantel}} for comparable results (the standardized data are
+  returned as item \code{x} in the result object). It is safest to use
+  \code{bioenvdist} to extract the environmental distances that really
+  were used within \code{bioenv}. NB., \code{bioenv} selects variables
+  to maximize the Mantel correlation, and significance tests based on
+  \emph{a priori} selection of variables are biased.  }
 
 \seealso{\code{\link{vegdist}}, \code{\link{dist}}, \code{\link{cor}}
   for underlying routines, \code{\link{monoMDS}} and



More information about the Vegan-commits mailing list