[Vegan-commits] r285 - in pkg: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 25 16:56:11 CET 2008


Author: gsimpson
Date: 2008-03-25 16:56:10 +0100 (Tue, 25 Mar 2008)
New Revision: 285

Modified:
   pkg/DESCRIPTION
   pkg/R/permDisper.R
   pkg/R/permutest.cca.R
   pkg/R/print.permDisper.R
   pkg/inst/ChangeLog
   pkg/man/TukeyHSD.betadisper.Rd
   pkg/man/anova.cca.Rd
   pkg/man/betadisper.Rd
   pkg/man/permDisper.Rd
   pkg/man/permuted.index2.Rd
Log:
permutest is now generic and permutest.cca becomes the cca method, with permutest.betadisper replacing permDisper

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/DESCRIPTION	2008-03-25 15:56:10 UTC (rev 285)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.12-6
-Date: Mar 24, 2008
+Version: 1.12-7
+Date: Mar 25, 2008
 Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson, 
   M. Henry H. Stevens  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>

Modified: pkg/R/permDisper.R
===================================================================
--- pkg/R/permDisper.R	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/R/permDisper.R	2008-03-25 15:56:10 UTC (rev 285)
@@ -1,5 +1,5 @@
-`permDisper` <- function(object, pairwise = FALSE,
-                         control = permControl(nperm = 999))
+`permutest.betadisper` <- function(x, pairwise = FALSE,
+                                   control = permControl(nperm = 999), ...)
 {
     t.statistic <- function(x, y) {
         m <- length(x)
@@ -13,24 +13,24 @@
         pooled <- sqrt(((m-1)*xvar + (n-1)*yvar) / (m+n-2))
         (xbar - ybar) / (pooled * sqrt(1/m + 1/n))
     }
-    if(!inherits(object, "betadisper"))
+    if(!inherits(x, "betadisper"))
         stop("Only for class \"betadisper\"")
-    nobs <- length(object$distances)
-    mod <- lm(object$distances ~ object$group)
+    nobs <- length(x$distances)
+    mod <- lm(x$distances ~ x$group)
     mod.Q <- mod$qr
     p <- mod.Q$rank
-    resids <- qr.resid(mod.Q, object$distances)
+    resids <- qr.resid(mod.Q, x$distances)
     res <- numeric(length = control$nperm + 1)
     res[1] <- summary(mod)$fstatistic[1]
     ## pairwise comparisons
     if(pairwise) {
         ## unique pairings
-        combin <- combn(levels(object$group), 2)
+        combin <- combn(levels(x$group), 2)
         n.pairs <- ncol(combin)
         t.stats <- matrix(0, ncol = n.pairs, nrow = control$nperm + 1)
-        t.stats[1,] <- apply(combn(levels(object$group), 2), 2, function(x) {
-            t.statistic(object$distances[object$group == x[1]],
-                        object$distances[object$group == x[2]])})
+        t.stats[1,] <- apply(combn(levels(x$group), 2), 2, function(z) {
+            t.statistic(x$distances[x$group == z[1]],
+                        x$distances[x$group == z[2]])})
     }
     for(i in seq(along = res[-1])) {
         perm <- permuted.index2(nobs, control = control)
@@ -45,32 +45,32 @@
         ## pairwise comparisons
         if(pairwise) {
             for(j in seq_len(n.pairs)) {
-                grp1 <- object$distance[perm][object$group == combin[1, j]]
-                grp2 <- object$distance[perm][object$group == combin[2, j]]
+                grp1 <- x$distance[perm][x$group == combin[1, j]]
+                grp2 <- x$distance[perm][x$group == combin[2, j]]
                 t.stats[i+1, j] <- t.statistic(grp1, grp2)
             }
         }
     }
     pval <- sum(res >= res[1]) / length(res)
     if(pairwise) {
-        df <- apply(combin, 2, function(x) {
-            length(object$distances[object$group == x[1]]) +
-                length(object$distance[object$group == x[2]]) - 2})
+        df <- apply(combin, 2, function(z) {
+            length(x$distances[x$group == z[1]]) +
+                length(x$distance[x$group == z[2]]) - 2})
         pairwise <- list(observed = 2 * pt(-abs(t.stats[1,]), df),
                          permuted = apply(t.stats, 2,
-                         function(x) sum(abs(x) >= x[1])/length(x)))
+                         function(z) sum(abs(z) >= z[1])/length(z)))
         names(pairwise$observed) <- names(pairwise$permuted) <-
             apply(combin, 2, paste, collapse = "-")
     } else {
         pairwise <- NULL
     }
-    mod.aov <- anova(object)
+    mod.aov <- anova(x)
     retval <- cbind(mod.aov[, 1:4], c(control$nperm, NA), c(pval, NA))
     dimnames(retval) <- list(c("Groups", "Residuals"),
                              c("Df", "Sum Sq", "Mean Sq", "F", "N.Perm",
                                "Pr(>F)"))
     retval <- list(tab = retval, pairwise = pairwise,
-                   groups = levels(object$group), control = control)
-    class(retval) <- "permDisper"
+                   groups = levels(x$group), control = control)
+    class(retval) <- "permutest.betadisper"
     retval
 }

Modified: pkg/R/permutest.cca.R
===================================================================
--- pkg/R/permutest.cca.R	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/R/permutest.cca.R	2008-03-25 15:56:10 UTC (rev 285)
@@ -1,3 +1,9 @@
+permutest <- function(x, ...)
+    UseMethod("permutest")
+
+permutest.default <- function(x, ...)
+    stop("No default permutation test defined")
+
 `permutest.cca` <-
     function (x, permutations = 100, model = c("direct", "reduced", 
                                      "full"), first = FALSE, strata, ...) 

Modified: pkg/R/print.permDisper.R
===================================================================
--- pkg/R/print.permDisper.R	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/R/print.permDisper.R	2008-03-25 15:56:10 UTC (rev 285)
@@ -1,5 +1,5 @@
-`print.permDisper` <- function(x, digits = max(getOption("digits") - 2, 3),
-                             ...)
+`print.permutest.betadisper` <- function(x, digits = max(getOption("digits") - 2, 3),
+                                         ...)
 {
     ## uses code from stats:::print.anova by R Core Development Team
     cat("\n")

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/inst/ChangeLog	2008-03-25 15:56:10 UTC (rev 285)
@@ -2,8 +2,16 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 1.12-6 (opened Mar 24, 2008)
+Version 1.12-7 (opened Mar 25, 2008)
 
+	* permutest: Now a generic function. permutest.cca is now the
+	'cca' method.
+
+	* permDisper: This function has been renamed to permutest.betadisper
+	and documentation updated.
+	
+Version 1.12-6 (closed Mar 25, 2008)
+
 	* metaMDS: WA scores for species are now based on the same
 	transformations and standardization (like wisconsin(sqrt())) as
 	the dissimilarities. They used to be based on the original data

Modified: pkg/man/TukeyHSD.betadisper.Rd
===================================================================
--- pkg/man/TukeyHSD.betadisper.Rd	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/man/TukeyHSD.betadisper.Rd	2008-03-25 15:56:10 UTC (rev 285)
@@ -32,11 +32,12 @@
   unbalanced designs.
 }
 \author{
-  Douglas Bates
+  Gavin L. Simpson
 }
 \seealso{
-  \code{\link{betadisper}}, \code{\link{permDisper}},
-  \code{\link{aov}}.
+  \code{\link{betadisper}}, \code{\link{permutest.betadisper}},
+  \code{\link{aov}}. The fitting function itself is
+  \code{\link{TukeyHSD}}.
 }
 \examples{
 ## continue the example from ?betadisper

Modified: pkg/man/anova.cca.Rd
===================================================================
--- pkg/man/anova.cca.Rd	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/man/anova.cca.Rd	2008-03-25 15:56:10 UTC (rev 285)
@@ -3,6 +3,8 @@
 \alias{anova.ccabyaxis}
 \alias{anova.ccabyterm}
 \alias{anova.ccabymargin}
+\alias{permutest}
+\alias{permutest.default}
 \alias{permutest.cca}
 \alias{print.permutest.cca}
 
@@ -18,9 +20,11 @@
 \method{anova}{cca}(object, alpha=0.05, beta=0.01, step=100, perm.max=9999,
       by = NULL, ...)
 
-permutest.cca(x, permutations = 100,
-              model = c("direct", "reduced", "full"),
-              first = FALSE, strata, ...)
+permutest(x, ...)
+
+\method{permutest}{cca}(x, permutations = 100,
+          model = c("direct", "reduced", "full"),
+          first = FALSE, strata, ...)
 }
 
 \arguments{

Modified: pkg/man/betadisper.Rd
===================================================================
--- pkg/man/betadisper.Rd	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/man/betadisper.Rd	2008-03-25 15:56:10 UTC (rev 285)
@@ -76,12 +76,12 @@
   To test if one or more groups is more variable than the others, ANOVA
   of the distances to group centroids can be performed and parametric
   theory used to interpret the significance of F. An alternative is to
-  use a permutation test. \code{\link{permDisper}} permutes model
+  use a permutation test. \code{\link{permutest.betadisper}} permutes model
   residuals to generate a permutation distribution of F under the Null
   hypothesis of no difference in dispersion between groups.
 
   Pairwise comprisons of group mean dispersions can also be performed
-  using \code{\link{permDisper}}. An alternative to the classical
+  using \code{\link{permutest.betadisper}}. An alternative to the classical
   comparison of group dispersions, is to calculate Tukey's Honest
   Significant Differences between groups, via
   \code{\link{TukeyHSD.betadisper}}.
@@ -132,7 +132,7 @@
   \strong{9(6)}, 683--693.
 }
 \author{Gavin L. Simpson}
-\seealso{\code{\link{permDisper}}, \code{\link[stats]{anova.lm}},
+\seealso{\code{\link{permutest.betadisper}}, \code{\link[stats]{anova.lm}},
   \code{\link{scores}}, \code{\link[graphics]{boxplot}},
   \code{\link{TukeyHSD.betadisper}}. Further measure of beta diversity
   can be found in \code{\link{betadiver}}.}
@@ -153,7 +153,7 @@
 anova(mod)
 
 ## Permutation test for F
-permDisper(mod, pairwise = TRUE)
+permutest(mod, pairwise = TRUE)
 
 ## Tukey's Honest Significant Differences
 (mod.HSD <- TukeyHSD(mod))

Modified: pkg/man/permDisper.Rd
===================================================================
--- pkg/man/permDisper.Rd	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/man/permDisper.Rd	2008-03-25 15:56:10 UTC (rev 285)
@@ -1,6 +1,6 @@
-\name{permDisper}
-\alias{permDisper}
-\alias{print.permDisper}
+\name{permutest.betadisper}
+\alias{permutest.betadisper}
+\alias{print.permutest.betadisper}
 \title{Permutation test of ultivariate homogeneity of groups dispersions
   (variances)}
 \description{
@@ -9,24 +9,26 @@
   \code{\link{betadisper}}.
 }
 \usage{
-permDisper(object, pairwise = FALSE, control = permControl(nperm = 999))
+\method{permutest}{betadisper}(x, pairwise = FALSE,
+         control = permControl(nperm = 999), \dots)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{object}{an object of class \code{"betadisper"}, the result of a
+  \item{x}{an object of class \code{"betadisper"}, the result of a
     call to \code{betadisper}.}
   \item{pairwise}{logical; perform pairwise comparisons of group means?}
   \item{control}{a list of control values for the permutations
     to replace the default values returned by the function
-    \code{\link{permControl}}.}
+    \code{\link{permControl}}}
+  \item{\dots}{Arguments passed to other methods.}
 }
 \details{
   To test if one or more groups is more variable than the others, ANOVA
   of the distances to group centroids can be performed and parametric
   theory used to interpret the significance of F. An alternative is to
-  use a permutation test. \code{permDisper} permutes model residuals to
-  generate a permutation distribution of F under the Null hypothesis of
-  no difference in dispersion between groups.
+  use a permutation test. \code{permutest.betadisper} permutes model
+  residuals to generate a permutation distribution of F under the Null
+  hypothesis of no difference in dispersion between groups.
 
   Pairwise comprisons of group mean dispersions can be performed by
   setting argument \code{pairwise} to \code{TRUE}. A classicial t test
@@ -37,8 +39,8 @@
   between groups, via \code{\link{TukeyHSD.betadisper}}.
 }
 \value{
-  \code{permDisper} returns a list of class \code{"permDisper"} with the
-  following components:
+  \code{permutest.betadisper} returns a list of class
+  \code{"permutest.betadisper"} with the following components:
 
   \item{tab}{the ANOVA table which is an object inheriting from class
     \code{"data.frame"}.}
@@ -78,7 +80,7 @@
 anova(mod)
 
 ## Permutation test for F
-permDisper(mod, pairwise = TRUE)
+permutest(mod, pairwise = TRUE)
 
 ## Tukey's Honest Significant Differences
 (mod.HSD <- TukeyHSD(mod))

Modified: pkg/man/permuted.index2.Rd
===================================================================
--- pkg/man/permuted.index2.Rd	2008-03-25 14:23:28 UTC (rev 284)
+++ pkg/man/permuted.index2.Rd	2008-03-25 15:56:10 UTC (rev 285)
@@ -79,9 +79,9 @@
 }
 \note{
   \code{permuted.index2} is currently used in one Vegan function;
-  \code{\link{permDisper}}. Over time, the other functions that
-  currently use the older \code{\link{permuted.index}} will be updated
-  to use \code{permuted.index2}.
+  \code{\link{permutest.betadisper}}. Over time, the other functions
+  that currently use the older \code{\link{permuted.index}} will be
+  updated to use \code{permuted.index2}.
 }
 %\references{
 %}



More information about the Vegan-commits mailing list