[Vegan-commits] r797 - in branches/1.15: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 7 06:46:42 CEST 2009


Author: jarioksa
Date: 2009-04-07 06:46:41 +0200 (Tue, 07 Apr 2009)
New Revision: 797

Added:
   branches/1.15/R/nestednodf.R
   branches/1.15/R/print.nestednodf.R
Modified:
   branches/1.15/inst/ChangeLog
   branches/1.15/man/nestedtemp.Rd
Log:
merged nestednodf to branches/1.15

Copied: branches/1.15/R/nestednodf.R (from rev 796, pkg/vegan/R/nestednodf.R)
===================================================================
--- branches/1.15/R/nestednodf.R	                        (rev 0)
+++ branches/1.15/R/nestednodf.R	2009-04-07 04:46:41 UTC (rev 797)
@@ -0,0 +1,44 @@
+`nestednodf` <- 
+    function(comm, order = TRUE)
+{
+    comm <- ifelse(comm > 0, 1, 0)
+    ## Order rows and columns
+    if (order)
+        comm <- comm[order(rowSums(comm), decreasing=TRUE),
+                     order(colSums(comm), decreasing=TRUE)]    
+    dimensions <- dim(comm)
+    fill <- sum(comm)/length(comm)
+    N.paired <- 0
+    ## Function to be applied to each combination of rows and columns
+    comb <- function(x, rows) {
+        if (identical(rows,TRUE)) {
+            comb.first <- comm[x[1],]
+            comb.second <- comm[x[2],]
+        }
+        else {
+            comb.first <- comm[,x[1]]
+            comb.second <- comm[,x[2]]
+        }
+        ## if MTi > MTj
+        if (sum(comb.first) > sum(comb.second) && sum(comb.second) > 0) {
+            paired.overlap <- sum((comb.first + comb.second) == 2) /
+                sum(comb.second)
+            N.paired <- paired.overlap
+        }
+        return(N.paired)
+    }
+    ## N.paired for all combinations of columns and rows
+    N.paired.rows <- combn(1:dimensions[1],2, comb, rows=TRUE)
+    N.paired.columns <- combn(1:dimensions[2],2, comb, rows=FALSE)
+    ## Index calculations
+    N.columns <- mean(N.paired.columns) * 100
+    N.rows <- mean(N.paired.rows) * 100  
+    NODF <- (sum(c(N.paired.rows, N.paired.columns)) * 100) /
+        ((dimensions[2] * (dimensions[2] - 1) / 2) + 
+         (dimensions[1] * (dimensions[1] - 1) / 2))
+    ## Returned list
+    out <- list(comm = comm, fill = fill, 
+                statistic=c("N.columns" = N.columns, "N.rows" = N.rows, "NODF" = NODF))
+    class(out) <- "nestednodf"
+    return(out)
+}

Copied: branches/1.15/R/print.nestednodf.R (from rev 796, pkg/vegan/R/print.nestednodf.R)
===================================================================
--- branches/1.15/R/print.nestednodf.R	                        (rev 0)
+++ branches/1.15/R/print.nestednodf.R	2009-04-07 04:46:41 UTC (rev 797)
@@ -0,0 +1,9 @@
+`print.nestednodf` <-
+    function(x, ...)
+{    
+    cat("N columns  :", format(x$statistic["N.columns"], ...), "\n")
+    cat("N rows     :", format(x$statistic["N.rows"], ...), "\n")
+    cat("NODF       :", format(x$statistic["NODF"], ...), "\n")
+    cat("Matrix fill:", format(x$fill, ...), "\n")
+    invisible(x)
+}

Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog	2009-04-06 09:13:24 UTC (rev 796)
+++ branches/1.15/inst/ChangeLog	2009-04-07 04:46:41 UTC (rev 797)
@@ -5,6 +5,9 @@
 
 Version 1.15-2 (opened January 14, 2009)
 
+	* copied nestednodf.R and print.nestednodf.R from pkg/vegan at
+	rev651, updated docs at rev653.
+
 	* merge r788: add "..." to decostand so that stressplot(metaMDS(x,
 	dist="gower", trymax=40)) works.
 

Modified: branches/1.15/man/nestedtemp.Rd
===================================================================
--- branches/1.15/man/nestedtemp.Rd	2009-04-06 09:13:24 UTC (rev 796)
+++ branches/1.15/man/nestedtemp.Rd	2009-04-07 04:46:41 UTC (rev 797)
@@ -4,10 +4,12 @@
 \alias{nestedchecker}
 \alias{nestedn0}
 \alias{nesteddisc}
+\alias{nestednodf}
 \alias{print.nestedchecker}
 \alias{print.nestedn0}
 \alias{print.nesteddisc}
 \alias{print.nestedtemp}
+\alias{print.nestednodf}
 \alias{plot.nestedtemp}
 
 \title{ Nestedness Indices for Communities of Islands or Patches }
@@ -24,6 +26,7 @@
 nestedn0(comm)
 nesteddisc(comm)
 nestedtemp(comm, ...)
+nestednodf(comm, order = TRUE)
 \method{plot}{nestedtemp}(x, kind = c("temperature", "incidendce"),
     col=rev(heat.colors(100)),  names = FALSE, ...)
 }
@@ -34,6 +37,7 @@
   \item{col}{Colour scheme for matrix temperatures.}
   \item{kind}{The kind of plot produced.}
   \item{names}{Label columns and rows in the plot using names in \code{comm}.}
+  \item{order}{Order rows and columns by frequencies.}
   \item{\dots}{Other arguments to functions.}
 }
 
@@ -45,13 +49,21 @@
   
   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). Function \code{nestedtemp} finds the
+  (Brualdi & Sanderson 1999). The original definition arranges species
+  (columns) by their frequencies, but did not have any method of
+  handling tied frequencies.
+
+  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
@@ -70,7 +82,20 @@
   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. The nestedness statistic is evaluated separately for columns
+  (\code{N columns}) for rows (\code{N rows}) and combined for the whole
+  matrix (\code{NODF}).  If you set \code{order = FALSE}, the statistic
+  is evaluated with the current matrix ordering allowing tests of other
+  meaningful hypothesis of matrix structure than ordering by row and
+  column totals (see Almeida-Neto et al. 2008).
 }
 
 \value{
@@ -81,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.
@@ -103,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