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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Dec 17 09:47:05 CET 2008


Author: jarioksa
Date: 2008-12-17 09:47:04 +0100 (Wed, 17 Dec 2008)
New Revision: 638

Added:
   pkg/vegan/R/nestednodf.R
Modified:
   pkg/vegan/DESCRIPTION
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/nestedtemp.Rd
Log:
Added nestedness index NODF (Almeira-Neto et al., Oikos 117, 1227-1239; 
2008) as function nestednodf. Coded by Gustavo Carvalho as a part of
R-Forge Feature Request #265"


Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION	2008-12-16 17:39:38 UTC (rev 637)
+++ pkg/vegan/DESCRIPTION	2008-12-17 08:47:04 UTC (rev 638)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.16-7
-Date: December 7, 2008
+Version: 1.16-8
+Date: December 17, 2008
 Author: Jari Oksanen, Roeland Kindt, Pierre Legendre, Bob O'Hara, Gavin L. Simpson, 
    Peter Solymos, M. Henry H. Stevens, Helene Wagner  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>

Added: pkg/vegan/R/nestednodf.R
===================================================================
--- pkg/vegan/R/nestednodf.R	                        (rev 0)
+++ pkg/vegan/R/nestednodf.R	2008-12-17 08:47:04 UTC (rev 638)
@@ -0,0 +1,59 @@
+### NODF metric of nestedness.
+### Code submitted as an R-Forge feature request #265 by Gustavo
+### Carvalho.
+nestednodf <- function(comm)
+{
+    ## Transform the community matrix to presence/ausence  
+    comm <- ifelse(comm > 0, 1, 0)
+    ## Order rows and columns
+    comm <- comm[order(rowSums(comm), decreasing=TRUE),
+                 order(colSums(comm), decreasing=TRUE)]  
+    ## Two matrices with all possible rows and columns combinations
+    ## used to calculate the paired overlap
+    row.combinations <- t(combn(1:dim(comm)[1],2))
+    col.combinations <- t(combn(1:dim(comm)[2],2))
+    ## Saving a bit of cpu time
+    row.sums <- rowSums(comm)
+    col.sums <- colSums(comm)
+    dimensions <- dim(comm)  
+    fill <- sum(comm)/length(comm)
+
+    ## N.paired for columns
+    combcol <- function(x) {
+        N.paired <- 0
+        ## if MTi > MTj
+        if (diff(col.sums[x]) < 0 && !any(col.sums[x] == 0)) {     
+            paired.overlap <- sum(rowSums(comm[,x]) == 2) / col.sums[x[2]]
+            N.paired <- paired.overlap
+        }
+        return(N.paired)
+    }
+
+    ## N.paired for rows
+    combrow <- function(x) {
+        N.paired <- 0
+        ## If MTk > MTl
+        if (diff(row.sums[x]) < 0 && !any(row.sums[x] == 0)) {
+            paired.overlap <- sum(colSums(comm[x,]) == 2) / row.sums[x[2]]
+            N.paired <- paired.overlap
+        }
+        return(N.paired)
+    }
+
+    ## N.paired for all columns and rows
+    N.paired.columns <- apply(col.combinations, 1, combcol)
+    N.paired.rows <- apply(row.combinations, 1, combrow) 
+
+    ## NODF, N.rows, and N.columns
+    NODF <- (sum(c(N.paired.rows, N.paired.columns)) * 100)/
+        ((dimensions[2] * (dimensions[2] - 1) / 2) +
+         (dimensions[1] * (dimensions[1] - 1) / 2))
+    N.rows <- mean(N.paired.rows) * 100  
+    N.columns <- mean(N.paired.columns) * 100
+  
+    ## Returned list (changed to make it more similar to what
+    ## nestedtemp returns).
+    out <- list(comm = comm, fill = fill, N.rows = N.rows,
+                N.columns = N.columns, statistic = NODF)
+    return(out)
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2008-12-16 17:39:38 UTC (rev 637)
+++ pkg/vegan/inst/ChangeLog	2008-12-17 08:47:04 UTC (rev 638)
@@ -2,27 +2,37 @@
 
 VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/
 
-Version 1.16-7
+Version 1.16-8 (opened Dec 17, 2008)
 
-Version 1.16-6 (closeed Dec 7, 2008)
+	* nestedness: added nestendess index based on overlap and
+	decreasing fill (Almeida-Neto et al., Oikos 117, 1227-1239;
+	2008).  Not all properties of the Oikos paper are not yet
+	implemented, and the UI needs work (print, plot methods).  Coding
+	by Gustavo Carvalho as a part of R-Forge Feature Request #265.
+	Documented with nestedtemp.
+	
+Version 1.16-7 (closed Dec 17, 2008)
 
-    * adipart: got a formula interface, and aggregate() was
-    replaced by matrix multiplication. Now it 10 times faster.
-    The formula interface has some consequences on the 
-    specification of the sampling design.
+	* permat*: functions were rationalised, strata argument is used
+	instead of reg and hab, and returned object got several new
+	arguments. The tide of changes affected methods as well, and some
+	other function (adipart, oecosimu). Stratification was tested and
+	corrected.
+	
+Version 1.16-6 (closed Dec 7, 2008)
 
-    * permat*: functions were rationalised, strata argument is
-    used instead of reg and hab, and returned object got several
-    new arguments. The tide of changes affected methods as well,
-    and some other function (adipart, oecosimu). Stratification
-    was tested and corrected.
+	* adipart: got a formula interface, and aggregate() was replaced
+	by matrix multiplication. Now it 10 times faster.  The formula
+	interface has some consequences on the specification of the
+	sampling design.
 
-    * permatfull: Jari Oksanen made the C port for the quantitative
-    quasiswap algorithm. So the permat* null model family is now
-    can be used for a wide array of null model analyses and is
-    quick enough to make reliable testing. The permatswap function
-    and help page were modified accordingly.
 
+	* permatfull: Jari Oksanen made the C port for the quantitative
+	quasiswap algorithm. So the permat* null model family is now can
+	be used for a wide array of null model analyses and is quick
+	enough to make reliable testing. The permatswap function and help
+	page were modified accordingly.
+
 	* plot.rad: gained argument log = "y", allowing log = "xy" so that
 	Zipf model is a straight line, or log = "" with arithmetic
 	scales.  Not (yet) implemented for Lattice alternatives.

Modified: pkg/vegan/man/nestedtemp.Rd
===================================================================
--- pkg/vegan/man/nestedtemp.Rd	2008-12-16 17:39:38 UTC (rev 637)
+++ pkg/vegan/man/nestedtemp.Rd	2008-12-17 08:47:04 UTC (rev 638)
@@ -4,6 +4,7 @@
 \alias{nestedchecker}
 \alias{nestedn0}
 \alias{nesteddisc}
+\alias{nestednodf}
 \alias{print.nestedchecker}
 \alias{print.nestedn0}
 \alias{print.nesteddisc}
@@ -24,6 +25,7 @@
 nestedn0(comm)
 nesteddisc(comm)
 nestedtemp(comm, ...)
+nestednodf(comm)
 \method{plot}{nestedtemp}(x, kind = c("temperature", "incidendce"),
     col=rev(heat.colors(100)),  names = FALSE, ...)
 }
@@ -46,19 +48,27 @@
   
   Function \code{netstedchecker} gives the number of checkerboard units,
   or 2x2 submatrices where both species occur once but on different
-  sites (Stone & Roberts 1990).  Function \code{nestedn0} implements
+  sites (Stone & Roberts 1990).
+
+  Function \code{nestedn0} implements
   nestedness measure N0 which is the number of absences from the sites
   which are richer than the most pauperate site species occurs
-  (Patterson & Atmar 1986).  Function \code{nesteddisc} implements
+  (Patterson & Atmar 1986).
+
+  Function \code{nesteddisc} implements
   discrepancy index which is the number of ones that should be shifted
   to fill a row with ones in a table arranged by species frequencies
   (Brualdi & Sanderson 1999). The original definition arranges species
   (columns) by their frequencies, but did not have any method of
-  handling tied frequencies. The \code{nesteddisc} function tries to
+  handling tied frequencies.
+
+  The \code{nesteddisc} function tries to
   order tied columns to minimize the discrepancy statistic but this is
   rather slow, and with a large number of tied columns there is no
   guarantee that the best ordering was found. In that case a warning
-  of tied columns will be issued. Function \code{nestedtemp} finds the
+  of tied columns will be issued.
+
+  Function \code{nestedtemp} finds the
   matrix temperature which is defined as the sum of \dQuote{surprises}
   in arranged matrix.  In arranged unsurprising matrix all species
   within proportion given by matrix fill are in the upper left corner of
@@ -77,7 +87,15 @@
   cautious in interpreting the results. The details of calculations
   are explained in the \code{\link{vignette}} \emph{Design decisions
   and implementation} that you can read using functions
-  \code{\link{vignette}} or \code{\link{vegandocs}}. 
+  \code{\link{vignette}} or \code{\link{vegandocs}}.
+
+  Function \code{nestednodf} implements a nestedness metric based on
+  overlap and decreasing fill (Almeida-Neto et al., 2008). Two basic
+  properties are required for a matrix to have the maximum degree of
+  nestedness according to this metric: (1) complete overlap of 1's from
+  right to left columns and from down to up rows, and (2) decreasing
+  marginal totals between all pairs of columns and all pairs of
+  rows
 }
 
 \value{
@@ -88,6 +106,12 @@
 }
 
 \references{
+  
+  Almeida-Neto, M., \enc{Gumarães}{Gumaraes}, P.,
+  \enc{Gumarães}{Gumaraes}, P.R., Loyola, R.D. & Ulrich, W. (2008). A
+  consistent metric for nestedness analysis in ecological systems:
+  reconciling concept and measurement. \emph{Oikos} 117, 1227--1239.
+  
   Atmar, W. & Patterson, B.D. (1993). The measurement of order and
   disorder in the distribution of species in fragmented
   habitat. \emph{Oecologia} 96, 373--382.
@@ -110,7 +134,7 @@
   W. (1998). A comparative analysis of nested subset patterns of species
   composition. \emph{Oecologia} 113, 1--20.
   }
-\author{ Jari Oksanen }
+\author{ Jari Oksanen and Gustavo Carvalho (\code{nestednodf}. }
 
 \seealso{
   In general, the functions should be used with \code{\link{oecosimu}}



More information about the Vegan-commits mailing list