[Vegan-commits] r755 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 25 09:43:47 CET 2009
Author: jarioksa
Date: 2009-03-25 09:43:47 +0100 (Wed, 25 Mar 2009)
New Revision: 755
Modified:
pkg/vegan/R/
pkg/vegan/R/mrpp.R
pkg/vegan/R/print.mrpp.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/mrpp.Rd
Log:
mrpp: returns class statistics and reports 'classification strength' with weight.type = 3
Property changes on: pkg/vegan/R
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: pkg/vegan/R/mrpp.R
===================================================================
--- pkg/vegan/R/mrpp.R 2009-03-23 11:04:15 UTC (rev 754)
+++ pkg/vegan/R/mrpp.R 2009-03-25 08:43:47 UTC (rev 755)
@@ -2,9 +2,13 @@
function (dat, grouping, permutations = 1000, distance = "euclidean",
weight.type = 1, strata)
{
+ classmean <- function(ind, dmat, indls) {
+ sapply(indls, function(x)
+ mean(c(dmat[ind == x, ind == x]),
+ na.rm = TRUE))
+ }
mrpp.perms <- function(ind, dmat, indls, w) {
- weighted.mean(sapply(indls, function(x) mean(c(dmat[ind ==
- x, ind == x]), na.rm = TRUE)), w = w, na.rm = TRUE)
+ weighted.mean(classmean(ind, dmat, indls), w = w, na.rm = TRUE)
}
if (inherits(dat, "dist"))
dmat <- dat
@@ -20,9 +24,17 @@
N <- nrow(dmat)
ind <- as.numeric(grouping)
indls <- unique(ind)
- w <- sapply(indls, function(x) sum(ind == x))
- w <- switch(weight.type, w, w - 1, w * (w - 1)/2)
- del <- mrpp.perms(ind, dmat, indls, w)
+ ncl <- sapply(indls, function(x) sum(ind == x))
+ w <- switch(weight.type, ncl, ncl - 1, ncl * (ncl - 1)/2)
+ classdel <- classmean(ind, dmat, indls)
+ names(classdel) <- names(ncl) <- levels(grouping)[indls]
+ del <- weighted.mean(classdel, w = w, na.rm = TRUE)
+ ## 'Classification strength' if weight.type == 3
+ if (weight.type == 3) {
+ CS <- N*(N-1)/2*(mean(dmat, na.rm = TRUE) - del)/(N*(N-1)/2 - sum(w))
+ } else {
+ CS <- NA
+ }
if (missing(strata))
strata <- NULL
perms <- sapply(1:permutations, function(x) ind[permuted.index(N,
@@ -33,7 +45,8 @@
E.del <- mean(m.ds)
p <- (1 + sum(del >= m.ds))/(permutations + 1)
r2 <- 1 - del/E.del
- out <- list(call = match.call(), delta = del, E.delta = E.del,
+ out <- list(call = match.call(), delta = del, E.delta = E.del, CS = CS,
+ n = ncl, classdelta = classdel,
Pvalue = p, A = r2, distance = distance, weight.type = weight.type,
boot.deltas = m.ds, permutations = permutations)
if (!is.null(strata)) {
@@ -43,4 +56,3 @@
class(out) <- "mrpp"
out
}
-
Modified: pkg/vegan/R/print.mrpp.R
===================================================================
--- pkg/vegan/R/print.mrpp.R 2009-03-23 11:04:15 UTC (rev 754)
+++ pkg/vegan/R/print.mrpp.R 2009-03-25 08:43:47 UTC (rev 755)
@@ -8,6 +8,14 @@
cat(deparse(x$call), "\n\n")
cat("Dissimilarity index:", x$distance, "\n")
cat("Weights for groups: ", switch(x$weight.type, "n", "n-1", "n(n-1)", "n(n-1)/2"), "\n\n")
+ cat("Class means and counts:\n\n")
+ print(noquote(rbind("delta" = formatC(x$classdelta, digits = digits),
+ "n" = formatC(x$n, digits=0))))
+ cat("\n")
+ if (!is.na(x$CS)) {
+ cat("Classification strength: ")
+ cat(formatC(x$CS, digits = digits), "\n")
+ }
cat("Chance corrected within-group agreement A: ")
cat(formatC(x$A, digits = digits), "\n")
cat("Based on observed delta", formatC(x$delta), "and expected delta",
@@ -23,4 +31,3 @@
cat("\n\n")
invisible(x)
}
-
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-03-23 11:04:15 UTC (rev 754)
+++ pkg/vegan/inst/ChangeLog 2009-03-25 08:43:47 UTC (rev 755)
@@ -2,8 +2,14 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 1.16-15 (opened Mar 10, 2009)
+Version 1.16-16 (openen Mar 25, 2009)
+ * mrpp: reports now "classification strength" when weight.type =
+ 3 or weights n*(n-1) are used. Returns mean dissimilarities and
+ counts for classes.
+
+Version 1.16-15 (closed Mar 25, 2009)
+
* envfit help page: explains the automatic scaling and 'arrow.mul'
argument.
@@ -12,7 +18,7 @@
* oecosimu & permatswap: much faster 'burnin' implemented through
'thin', and hence using a single C loop instead of multiple calls
- and allocations to an R object.
+ and assignments to an R object.
* as.mcmc.permat: provides same functionality for permat objects
as as.mcmc.oecosimu for oecosimu objects.
Modified: pkg/vegan/man/mrpp.Rd
===================================================================
--- pkg/vegan/man/mrpp.Rd 2009-03-23 11:04:15 UTC (rev 754)
+++ pkg/vegan/man/mrpp.Rd 2009-03-25 08:43:47 UTC (rev 755)
@@ -63,6 +63,13 @@
\eqn{A = 1 -\delta/E(\delta)}, where \eqn{E(\delta)} is the expected
\eqn{\delta} assessed as the average of permutations.
+With \code{weight.type = 3}, the function also calculates classification
+strength (Van Sickle 1997) which is defined as the difference between
+average between group dissimilarities and within group
+dissimilarities. With \code{weight.type = 3} the classification strength
+is a simple transformation of \eqn{\delta}, and has the same permutation
+significance.
+
If the first argument \code{dat} can be interpreted as dissimilarities,
they will be used directly. In other cases the function treats
\code{dat} as observations, and uses \code{\link{vegdist}} to find
@@ -76,6 +83,12 @@
\item{delta }{The overall weighted mean of group mean distances.}
\item{E.delta}{expected delta, under the null hypothesis of no group
structure. This is the mean of the permuted deltas.}
+ \item{CS}{Classification strength (Van Sickle 1997) with
+ \code{weight.type = 3} and \code{NA} with other weights.}
+ \item{n}{Number of observations in each class.}
+ \item{classdelta}{Mean dissimilarities within classes. The overall
+ \eqn{\delta} is the weighted average of these values with given
+ \code{weight.type}}.
\item{Pvalue}{Significance of the test.}
\item{A}{A chance-corrected estimate of the proportion of the distances
explained by group identity; a value analogous to a coefficient of
@@ -88,13 +101,18 @@
\item{permutations}{The number of permutations used.}
}
\references{
- P. W. Mielke and K. J. Berry. 2001. \emph{Permutation Methods: A
- Distance Function Approach.} Springer Series in
- Statistics. Springer.
+ B. McCune and J. B. Grace. 2002. \emph{Analysis of Ecological
+ Communities.} MjM Software Design, Gleneden Beach, Oregon, USA.
-B. McCune and J. B. Grace. 2002. \emph{Analysis of Ecological
- Communities.} MjM Software Design, Gleneden Beach, Oregon, USA.
+ P. W. Mielke and K. J. Berry. 2001. \emph{Permutation Methods: A
+ Distance Function Approach.} Springer Series in
+ Statistics. Springer.
+
+ J. Van Sickle 1997. Using mean similarity dendrograms to evaluate
+ classifications. \emph{Journal of Agricultural, Biological, and Environmental
+ Statistics} 2:370-388.
+
}
\author{
M. Herny H. Stevens \email{HStevens at muohio.edu} and Jari Oksanen.
More information about the Vegan-commits
mailing list