[Vegan-commits] r249 - in pkg: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 2 19:14:21 CET 2008
Author: jarioksa
Date: 2008-03-02 19:14:21 +0100 (Sun, 02 Mar 2008)
New Revision: 249
Modified:
pkg/DESCRIPTION
pkg/R/nestedtemp.R
pkg/inst/ChangeLog
pkg/man/oecosimu.Rd
Log:
nestedtemp updated according to Rodriquez-Girones & Santamaria: alternately pack cols and rows to minimal temperatures
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2008-02-28 08:36:02 UTC (rev 248)
+++ pkg/DESCRIPTION 2008-03-02 18:14:21 UTC (rev 249)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 1.12-1
-Date: Feb 19, 2008
+Version: 1.12-2
+Date: Mar 2, 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/nestedtemp.R
===================================================================
--- pkg/R/nestedtemp.R 2008-02-28 08:36:02 UTC (rev 248)
+++ pkg/R/nestedtemp.R 2008-03-02 18:14:21 UTC (rev 249)
@@ -1,12 +1,45 @@
`nestedtemp` <-
function(comm, ...)
{
- #.NotYetImplemented()
+ ## J Biogeogr 33, 924-935 (2006) says that Atmar & Patterson try
+ ## to pack presences and absence to minimal matrix temperature,
+ ## and the following routines try to reproduce the (partly verbal)
+ ## description. Index s should pack ones, and index t should pack
+ ## zeros, and the final ordering should be "a compromise".
+ colpack <- function(x, rr)
+ {
+ ind <- matrix(rep(rr, ncol(x)), nrow=nrow(x))
+ s <- rank(-colSums((x*ind)^2), ties="aver")
+ t <- rank(-colSums((nrow(x) - (1-x)*ind + 1)^2), ties="aver")
+ st <- rank(s+t, ties="random")
+ st
+ }
+ rowpack <- function(x, cr)
+ {
+ ind <- matrix(rep(cr, each=nrow(x)), nrow=nrow(x))
+ s <- rank(-rowSums((x*ind)^2), ties="aver")
+ t <- rank(-rowSums((ncol(x) - (1-x)*ind + 1)^2), ties="aver")
+ st <- rank(s+t, ties="random")
+ st
+ }
comm <- ifelse(comm > 0, 1, 0)
- rs <- rowSums(comm)
- cs <- colSums(comm)
- r <- (rank(-rs, ties="aver") - 0.5)/(nrow(comm))
- c <- (rank(-cs, ties="aver") - 0.5)/(ncol(comm))
+ ## Start with columns, expect if nrow > ncol
+ if (ncol(comm) >= nrow(comm)) {
+ i <- rank(-rowSums(comm), ties="average")
+ } else {
+ j <- rank(-colSums(comm), ties="average")
+ i <- rowpack(comm, j)
+ }
+ ## Improve eight times
+ for (k in 1:8) {
+ j <- colpack(comm, i)
+ i <- rowpack(comm, j)
+ }
+ if (ncol(comm) < nrow(comm))
+ j <- colpack(comm, i)
+ comm <- comm[order(i), order(j)]
+ r <- ppoints(nrow(comm), a=0.5)
+ c <- ppoints(ncol(comm), a=0.5)
dis <- outer(r, c, pmin)
totdis <- 1 - abs(outer(r, c, "-"))
fill <- sum(comm)/prod(dim(comm))
@@ -38,10 +71,9 @@
colnames(u) <- colnames(comm)
rownames(u) <- rownames(comm)
temp <- 100*sum(u)/prod(dim(comm))/0.04145
- i <- rev(order(rs))
- j <- rev(order(cs))
- out <- list(comm = comm[i,j], u = u[i,j], r = r[i], c = c[j],
+ out <- list(comm = comm, u = u, r = r, c = c,
fill=fill, statistic = temp, smooth=smo)
class(out) <- "nestedtemp"
out
}
+
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2008-02-28 08:36:02 UTC (rev 248)
+++ pkg/inst/ChangeLog 2008-03-02 18:14:21 UTC (rev 249)
@@ -2,8 +2,25 @@
VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
-Version 1.12-1 (Feb 25, 2008, working...)
+Version 1.12-2 (Mar 2, 2008, working...)
+ * nestedtemp: Rodriguez-Girones & Santamaria (J. Biogeogr. 33,
+ 924-935; 2006) have had a look inside the original temperature
+ calculator code and give a more explicit description of the
+ method. Following their paper, I implemented an iterative
+ procedure to alternately pack columns and rows for ones and
+ zeros. The fill line is still a parabola, but this seems to be
+ very similar to the R-G & S fill line with fills 0.2...0.8 and I
+ don't hurry with this. There still are differences in many aspects
+ of implementation. The iterative procedure gives slightly
+ different results between runs, but here tests: Rocky mountain
+ mammals 3.87 (A&P 3.81, was 3.59 in 1.12-1), Baja
+ birds (Bajabs.txt) 10.17 (A&P 7.25, was 7.75), Queen Charlotte
+ birds 14.78 (A&P 15.87, was 14.51). Some results are indeed more
+ different than they used to be...
+
+Version 1.12-1 (closed Mar 2, 2008)
+
* biplot.rda: gained argument col to select colours for sites and
species.
Modified: pkg/man/oecosimu.Rd
===================================================================
--- pkg/man/oecosimu.Rd 2008-02-28 08:36:02 UTC (rev 248)
+++ pkg/man/oecosimu.Rd 2008-03-02 18:14:21 UTC (rev 249)
@@ -78,12 +78,16 @@
matrix all species within proportion given by matrix fill are in the
upper left corner of the matrix, and the surprise of the absence or
presences is the diagonal distance from the fill line (Atmar &
- Patterson 1993). Function \code{nestedtemp} also has a \code{plot}
- method which can display either incidences or temperatures of the
- surprises. Matrix temperature is so vaguely described in the
- literature (Atmar & Patterson 1993) that it may be impossible to
- reproduce the results of other implementations, and the user should
- be cautious in interpreting the results.
+ Patterson 1993). Function tries to pack species and sites to a
+ minimal temperature (Rodriguez-Girones & Santamaria 2006), but this
+ is an iterative procedure, and the temperatures usually vary among
+ runs. Function \code{nestedtemp} also has a \code{plot} method
+ which can display either incidences or temperatures of the
+ surprises. Matrix temperature was rather vaguely described (Atmar &
+ Patterson 1993), but Rodriguez-Girones & Santamaria (2006) are more
+ explicit and their description is used here. However, the results
+ probably differ from other implementations, and users should be
+ cautious in interpreting the results.
In addition to these functions provided in \pkg{vegan}, any function
can be used that takes \code{comm} as the first argument, and
@@ -185,6 +189,10 @@
of insular mammalian faunas and archipelagos. \emph{Biol. J. Linnean
Soc.} 28, 65--82.
+ Rodriguez-Girones & Santamaria (2006). A new algorithm to calculate
+ the nestedness temperature of presence-absence
+ matrices. \emph{J. Biogeogr.} 33, 924--935.
+
Stone, L. & Roberts, A. (1990). The checkerboard score and species
distributions. \emph{Oecologia} 85, 74--79.
@@ -228,9 +236,6 @@
\examples{
data(sipoo)
nestedchecker(sipoo)
-mod <- oecosimu(sipoo, nestedtemp, "r00")
-mod
-plot(mod)
## Use the first eigenvalue of correspondence analysis as an index
## of structure: a model for making your own functions.
## This is a minimal structure; fancier functions give fancier results
More information about the Vegan-commits
mailing list