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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 16 20:21:26 CET 2010


Author: jarioksa
Date: 2010-11-16 20:21:26 +0100 (Tue, 16 Nov 2010)
New Revision: 1373

Modified:
   pkg/vegan/R/fitted.procrustes.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/procrustes.Rd
Log:
predict.procrustes does not work wit symmetric analysis without large-ish changes in procrustes()

Modified: pkg/vegan/R/fitted.procrustes.R
===================================================================
--- pkg/vegan/R/fitted.procrustes.R	2010-11-16 11:24:27 UTC (rev 1372)
+++ pkg/vegan/R/fitted.procrustes.R	2010-11-16 19:21:26 UTC (rev 1373)
@@ -10,15 +10,15 @@
 ## Like above, except when takes 'newata'
 
 `predict.procrustes` <-
-    function(object, newdata, truemean = TRUE, ...)
+    function(object, newdata, ...)
 {
     if (missing(newdata))
-        return(fitted(object, truemean = truemean))
+        return(fitted(object, truemean = TRUE))
+    if (object$symmetric)
+        stop(gettextf("'predict' not available for symmetric procrustes analysis with 'newdata'"))
     Y <- as.matrix(newdata)
     ## scaling and rotation
     Y <- object$scale * Y %*% object$rotation
-    ## translation
-    if (truemean)
-        Y <- sweep(Y, 2, object$translation, "+")
-    Y
+    ## translation: always
+    sweep(Y, 2, object$translation, "+")
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-11-16 11:24:27 UTC (rev 1372)
+++ pkg/vegan/inst/ChangeLog	2010-11-16 19:21:26 UTC (rev 1373)
@@ -5,8 +5,8 @@
 Version 1.18-16 (opened November 9, 2010)
 
 	* procrustes: fixed centring of fitted(). Added predict() method
-	that can be used to add new rotated coordinates to the
-	target. Need to check working with 'symmetric = TRUE'.
+	that can be used to add new rotated coordinates to the target. The
+	function cannot be used for symmetric analysis with 'newdata'.
 
 	* vignette on design decision: updated to changes in 'const' in
 	scores.rda()  in 1.18-15 and to Canoco 4. Explains now 'const'

Modified: pkg/vegan/man/procrustes.Rd
===================================================================
--- pkg/vegan/man/procrustes.Rd	2010-11-16 11:24:27 UTC (rev 1372)
+++ pkg/vegan/man/procrustes.Rd	2010-11-16 19:21:26 UTC (rev 1373)
@@ -29,7 +29,7 @@
 \method{lines}{procrustes}(x, type = c("segments", "arrows"), choices = c(1, 2), ...)  
 \method{residuals}{procrustes}(object, ...)
 \method{fitted}{procrustes}(object, truemean = TRUE, ...)
-\method{predict}{procrustes}(object, newdata, truemean = TRUE, ...)
+\method{predict}{procrustes}(object, newdata, ...)
 protest(X, Y, scores = "sites", permutations = 999, strata, ...)
 }
 
@@ -58,8 +58,8 @@
     segments or arrows.}
   \item{truemean}{Use the original range of target matrix instead of
     centring the fitted values.}
-  \item{newdata}{Matrix of coordinates to be rotated (and translated if
-    \code{truemean = TRUE}) to the target.}
+  \item{newdata}{Matrix of coordinates to be rotated and translated to
+     the target.}
   \item{permutations}{Number of permutation to assess the significance
     of the symmetric Procrustes statistic. }
   \item{strata}{An integer vector or factor specifying the strata for
@@ -124,8 +124,11 @@
   match dimensions. This means that the function can be used to rotate
   an ordination configuration to an environmental variable (most
   practically extracting the result with the \code{fitted}
-  function). Function \code{predict} can be usd to add new rotated
-  coordinates to the target. 
+  function). Function \code{predict} can be used to add new rotated
+  coordinates to the target. The \code{predict} function will always
+  translate coordinates to the original non-centred matrix. The
+  function canot be used with \code{newdata} for \code{symmetric}
+  analysis.
 
   Function \code{protest} calls \code{procrustes(..., symmetric = TRUE)}
   repeatedly to estimate the `significance' of the Procrustes



More information about the Vegan-commits mailing list