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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 27 05:09:13 CET 2009


Author: psolymos
Date: 2009-02-27 05:09:13 +0100 (Fri, 27 Feb 2009)
New Revision: 709

Added:
   pkg/vegan/R/permat.tsdiag.R
   pkg/vegan/R/print.permat.tsdiag.R
Modified:
   pkg/vegan/man/permatfull.Rd
Log:
time series diagnostics for sequential matrix permutations


Added: pkg/vegan/R/permat.tsdiag.R
===================================================================
--- pkg/vegan/R/permat.tsdiag.R	                        (rev 0)
+++ pkg/vegan/R/permat.tsdiag.R	2009-02-27 04:09:13 UTC (rev 709)
@@ -0,0 +1,18 @@
+permat.tsdiag <-
+function(x, type = "bray") {
+    tsVec <- ts(summary(x)[[type]])
+    ARmod <- arima(tsVec, order = c(1, 0, 0))
+    ARmod$call <- match.call()
+    ARresid <- ARmod$residuals
+    BOX.tsVec <- Box.test(tsVec, lag = 1, type = "Ljung-Box")
+    BOX.tsVec$data.name <- switch(type,
+        "bray" = "Bray-Curtis dissimilarities",
+        "chisq" = "Chi-squared values")
+    BOX.ARresid <- Box.test(ARresid, lag = 1, type = "Ljung-Box")
+    BOX.ARresid$data.name <- "AR residuals"
+    x$perm <- NULL
+    out <- list(call=match.call(), x=x, ts=tsVec,
+        arima=ARmod, box.ts=BOX.tsVec, box.resid=BOX.ARresid)
+    class(out) <- "permat.tsdiag"
+    out
+}


Property changes on: pkg/vegan/R/permat.tsdiag.R
___________________________________________________________________
Name: svn:executable
   + *

Added: pkg/vegan/R/print.permat.tsdiag.R
===================================================================
--- pkg/vegan/R/print.permat.tsdiag.R	                        (rev 0)
+++ pkg/vegan/R/print.permat.tsdiag.R	2009-02-27 04:09:13 UTC (rev 709)
@@ -0,0 +1,8 @@
+print.permat.tsdiag <-
+function(x, ...) {
+    cat("First order autoregressive model\n")
+    print(x$arima)
+    cat("\nTest of independence\n")
+    print(x$box.ts)
+    print(x$box.resid)
+}


Property changes on: pkg/vegan/R/print.permat.tsdiag.R
___________________________________________________________________
Name: svn:executable
   + *

Modified: pkg/vegan/man/permatfull.Rd
===================================================================
--- pkg/vegan/man/permatfull.Rd	2009-02-26 01:45:32 UTC (rev 708)
+++ pkg/vegan/man/permatfull.Rd	2009-02-27 04:09:13 UTC (rev 709)
@@ -8,6 +8,8 @@
 \alias{lagplot.permat}
 \alias{lagplot}
 \alias{print.permat}
+\alias{permat.tsdiag}
+\alias{print.permat.tsdiag}
 \alias{summary.permat}
 \alias{print.summary.permat}
 
@@ -32,8 +34,11 @@
 \method{lines}{permat}(x, type = "bray", ...)
 lagplot(x, ...)
 \method{lagplot}{permat}(x, type = "bray", ...)
+\method{print}{permat}(x, digits = 3, ...)
 \method{summary}{permat}(object, ...)
 \method{print}{summary.permat}(x, digits = 2, ...)
+permat.tsdiag(x, type = "bray")
+\method{print}{permat.tsdiag}(x, ...)
 }
 \arguments{
   \item{m}{a community data matrix with plots (samples) as rows and species (taxa) as columns.}
@@ -101,6 +106,9 @@
 
 The function \code{permat.control} is used to set up quantitative matrix permutations in other functions
 (e.g. \code{\link{oecosimu}} and \code{\link{adipart}}).
+
+The functions \code{lagplot} \code{permat.tsdiag} are useful for testing independence of permuted matrices
+when using sequential algorithms.
 }
 
 \value{
@@ -172,10 +180,9 @@
 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")
+## Time series diagnostics
+tsd <- permat.tsdiag(x.s)
+tsd
 }
 
 \keyword{multivariate}



More information about the Vegan-commits mailing list