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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 24 23:20:41 CET 2009


Author: psolymos
Date: 2009-02-24 23:20:41 +0100 (Tue, 24 Feb 2009)
New Revision: 707

Added:
   pkg/vegan/R/lagplot.R
   pkg/vegan/R/lagplot.permat.R
Removed:
   pkg/vegan/R/lag.plot.permat.R
Modified:
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/permatfull.Rd
Log:
S3 method added for lagplot, Box test removed, example added


Deleted: pkg/vegan/R/lag.plot.permat.R
===================================================================
--- pkg/vegan/R/lag.plot.permat.R	2009-02-24 20:14:20 UTC (rev 706)
+++ pkg/vegan/R/lag.plot.permat.R	2009-02-24 22:20:41 UTC (rev 707)
@@ -1,35 +0,0 @@
-`lag.plot.permat` <-
-function(x, type = "bray", sub=NULL, ...)
-{
-    lags <- 1
-    Box.type <- "Ljung-Box"
-    type <- match.arg(type, c("bray", "chisq"))
-    ## this duality is required, because ylab can not be specified for lag.plot
-    switch(type,
-        "bray" = {
-            out <- Bray.Curtis.Dissimilarities <- summary(x)[[type]]
-            if (is.null(sub)) {
-                Bt <- Box.test(out, lag=lags, type=Box.type)[c(1,2,3)]
-                names(Bt)[c(1,2)] <- c("X-squared", "df")
-                Bt[[1]] <- round(Bt[[1]], 3)
-                Bt[[3]] <- if (Bt[[3]] < 0.0001)
-                    "< 0.0001" else round(Bt[[3]], 3)
-                sub <- paste(Box.type, " test: ", paste(names(Bt), "=", Bt, collapse=", "), collapse="")
-            }
-            lag.plot(Bray.Curtis.Dissimilarities, lags=lags, sub=sub, ...)
-            invisible(out)
-        },
-        "chisq" = {
-            out <- Chi.Squared.Values <- summary(x)[[type]]
-            if (is.null(sub)) {
-                Bt <- Box.test(out, lag=lags, type=Box.type)[c(1,2,3)]
-                names(Bt)[c(1,2)] <- c("X-squared", "df")
-                Bt[[1]] <- round(Bt[[1]], 3)
-                Bt[[3]] <- if (Bt[[3]] < 0.0001)
-                    "< 0.0001" else round(Bt[[3]], 3)
-                sub <- paste(Box.type, " test: ", paste(names(Bt), "=", Bt, collapse=", "), collapse="")
-            }
-            lag.plot(Chi.Squared.Values, lags=lags, sub=sub, ...)
-            invisible(out)
-        })
-}

Added: pkg/vegan/R/lagplot.R
===================================================================
--- pkg/vegan/R/lagplot.R	                        (rev 0)
+++ pkg/vegan/R/lagplot.R	2009-02-24 22:20:41 UTC (rev 707)
@@ -0,0 +1,5 @@
+`lagplot` <-
+function (x, ...)
+{
+    UseMethod("lagplot")
+}

Copied: pkg/vegan/R/lagplot.permat.R (from rev 706, pkg/vegan/R/lag.plot.permat.R)
===================================================================
--- pkg/vegan/R/lagplot.permat.R	                        (rev 0)
+++ pkg/vegan/R/lagplot.permat.R	2009-02-24 22:20:41 UTC (rev 707)
@@ -0,0 +1,16 @@
+`lagplot.permat` <-
+function(x, type = "bray", ...)
+{
+    type <- match.arg(type, c("bray", "chisq"))
+    ## this duality is required, because ylab can not be specified for lag.plot
+    switch(type,
+        "bray" = {
+            out <- Bray.Curtis.Dissimilarities <- summary(x)[[type]]
+            lag.plot(Bray.Curtis.Dissimilarities, ...)
+        },
+        "chisq" = {
+            out <- Chi.Squared.Values <- summary(x)[[type]]
+            lag.plot(Chi.Squared.Values, ...)
+        })
+    invisible(out)
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-02-24 20:14:20 UTC (rev 706)
+++ pkg/vegan/inst/ChangeLog	2009-02-24 22:20:41 UTC (rev 707)
@@ -4,9 +4,10 @@
 
 Version 1.16-14 (opened Feb 24, 2009)
 
-    * lag.plot.permat: lag plot for permat simulations to graphically
-    diagnose independence when using sequential algorithms. Ljung-Box
-    test is also performed and returned in the sub title.
+    * lagplot.permat: lagplot for permat simulations to graphically
+    diagnose independence when using sequential algorithms.
+    Reworked examples on the help page shows time series related
+    diagnostics for permat objects.
 
 	* permatswap: two new methods (under "abuswap") added based on the
 	paper of Hardy 2008 (J Ecol 96, 914-926). These preserve row *and*

Modified: pkg/vegan/man/permatfull.Rd
===================================================================
--- pkg/vegan/man/permatfull.Rd	2009-02-24 20:14:20 UTC (rev 706)
+++ pkg/vegan/man/permatfull.Rd	2009-02-24 22:20:41 UTC (rev 707)
@@ -5,7 +5,8 @@
 \alias{permat.control}
 \alias{plot.permat}
 \alias{lines.permat}
-\alias{lag.plot.permat}
+\alias{lagplot.permat}
+\alias{lagplot}
 \alias{print.permat}
 \alias{summary.permat}
 \alias{print.summary.permat}
@@ -29,7 +30,8 @@
 \method{plot}{permat}(x, type = "bray", ylab, xlab, col, lty,
 lowess = TRUE, plot = TRUE, text = TRUE, ...)
 \method{lines}{permat}(x, type = "bray", ...)
-\method{lag.plot}{permat}(x, type = "bray", sub=NULL, ...)
+lagplot(x, ...)
+\method{lagplot}{permat}(x, type = "bray", ...)
 \method{summary}{permat}(object, ...)
 \method{print}{summary.permat}(x, digits = 2, ...)
 }
@@ -47,7 +49,6 @@
   \item{x, object}{object of class \code{"permat"}}
   \item{digits}{number of digits used for rounding.}
   \item{ylab, xlab, col, lty}{graphical parameters for the \code{plot} method.}
-  \item{sub}{a sub title for the plot, if this is \code{NULL} for the \code{lag.plot.permat} function, the results of the Ljung-Box test is plotted as sub title.}
   \item{type}{character, type of plot to be displayed: \code{"bray"} for Bray-Curtis dissimilarities, \code{"chisq"} for Chi-squared values.}
   \item{lowess, plot, text}{logical arguments for the \code{plot} method, whether a lowess curve should be drawn, the plot should be drawn, and statistic values should be printed on the plot.}
   \item{\dots}{other arguments passed to methods.}
@@ -131,11 +132,11 @@
 For other functions to permute matrices:
 
 \code{\link{commsimulator}}, \code{\link{r2dtable}}, \code{\link{sample}}, \code{\link[bipartite]{swap.web}},
-\code{\link{oecosimu}}, \code{\link{adipart}}}
+\code{\link{oecosimu}}, \code{\link{adipart}}
 
 For time-series diagnostics:
 
-\code{\link{Box.test}}, \code{\link{lag.plot}}
+\code{\link{Box.test}}, \code{\link{lag.plot}}, \code{\link{tsdiag}}
 }
 \examples{
 ## A simple artificial community data matrix.
@@ -145,15 +146,12 @@
    0,0,1,2,0,3,
    0,0,0,1,4,3
    ), 4, 6, byrow=TRUE)
-## Using the swap algorithm to create a 
+## Using the quasiswap algorithm to create a 
 ## list of permuted matrices, where
 ## row/columns sums and matrix fill are preserved:
-x1 <- permatswap(m, "swap", burnin = 1000, thin = 100)
+x1 <- permatswap(m, "quasiswap")
 summary(x1)
 plot(x1)
-## The lag plot is useful to diagnose independence
-## of successive simulations for sequential algorithms
-lag.plot.permat(x1)
 ## Unrestricted permutation retaining
 ## row/columns sums but not matrix fill:
 x2 <- permatfull(m)
@@ -169,6 +167,15 @@
 ## check sums within strata:
 x4 <- permatfull(m, strata=c(1,1,2,2))
 summary(x4)
+## The lagplot is useful to diagnose independence
+## of successive simulations for sequential algorithms
+data(BCI)
+x5 <- permatswap(BCI, "swap", burnin=0, thin=100, times=50)
+lagplot.permat(x5)
+## For more time series diagnostics, use e.g.
+a0 <- arima(summary(x5)$bray, order=c(0,0,0))
+tsdiag(a0)
+Box.test(a0$resid, type="Ljung-Box")
 }
 
 \keyword{multivariate}



More information about the Vegan-commits mailing list