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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 4 17:51:06 CET 2010


Author: jarioksa
Date: 2010-11-04 17:51:05 +0100 (Thu, 04 Nov 2010)
New Revision: 1350

Modified:
   pkg/vegan/R/fitspecaccum.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/specaccum.Rd
Log:
fitspecaccum knows more nls() models

Modified: pkg/vegan/R/fitspecaccum.R
===================================================================
--- pkg/vegan/R/fitspecaccum.R	2010-11-04 16:03:50 UTC (rev 1349)
+++ pkg/vegan/R/fitspecaccum.R	2010-11-04 16:51:05 UTC (rev 1350)
@@ -1,8 +1,10 @@
 fitspecaccum <-
-    function(object, model = c("michaelis-menten", "arrhenius"),
-             method = "random",  ...)
+    function(object, model, method = "random",  ...)
 {
-    model <- match.arg(model)
+    MODELS <- c("arrhenius", "gitay", "lomolino", "asymp",
+                "gompertz", "michaelis-menten", "logis",
+                "weibull")
+    model <- match.arg(model, MODELS)
     if (!inherits(object, "specaccum")) 
         object <- specaccum(object, method = method, ...)
     if (is.null(object$perm))
@@ -14,10 +16,23 @@
     else
         x <- object$sites
     mods <- switch(model,
+        "arrhenius" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSarrhenius(x, k, z))),
+        "gitay" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSgitay(x, k, slope))),
+        "lomolino" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSlomolino(x, Asym, xmid, slope))),
+        "asymp" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSlogis(x, Asym, xmid, scal))),
+        "gompertz" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSgompertz(x, Asym, xmid, scal))),
         "michaelis-menten" = apply(SpeciesRichness, 2,
              function(y) nls(y ~ SSmicmen(x, Vm, K))),
-        "arrhenius" = apply(SpeciesRichness, 2,
-                   function(y) nls(y ~ SSarrhenius(x, k, z))))
+        "logis" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSlogis(x, Asym, xmid, scal))),
+        "weibull" = apply(SpeciesRichness, 2,
+             function(y) nls(y ~ SSweibull(x, Asym, Drop, lrc, par)))
+                   )
     object$fitted <- drop(sapply(mods, fitted))
     object$residuals <- drop(sapply(mods, residuals))
     object$coefficients <- drop(sapply(mods, coef))
@@ -26,3 +41,15 @@
     class(object) <- c("fitspecaccum", class(object))
     object
 }
+
+### plot function
+
+`plot.fitspecaccum` <-
+    function(x, col = par("fg"), lty = 1, 
+             xlab = "Sites", ylab = x$method, ...)
+{
+    fv <- fitted(x)
+    matplot(x$sites, fv, col = col, lty = lty, pch = NA,
+            xlab = xlab, ylab = ylab, type = "l", ...)
+    invisible()
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-11-04 16:03:50 UTC (rev 1349)
+++ pkg/vegan/inst/ChangeLog	2010-11-04 16:51:05 UTC (rev 1350)
@@ -4,6 +4,11 @@
 
 Version 1.18-15 (opened November 1, 2010)
 
+	* fitspecaccum: uses now new SS-models for species-area
+	relationship and several of standard SS-models for
+	nls(). Placeholders for documentation added. Has a plot()
+	function. 
+
 	* Self-starting nls() models for species-area relationship: added
 	Gitay and Lomolino models from Dengler 2009 (J Biogeog 36,
 	728-744). Some more should be added, but these were among the best

Modified: pkg/vegan/man/specaccum.Rd
===================================================================
--- pkg/vegan/man/specaccum.Rd	2010-11-04 16:03:50 UTC (rev 1349)
+++ pkg/vegan/man/specaccum.Rd	2010-11-04 16:51:05 UTC (rev 1350)
@@ -5,6 +5,7 @@
 \alias{plot.specaccum}
 \alias{boxplot.specaccum}
 \alias{fitspecaccum}
+\alias{plot.fitspecaccum}
 
 \title{Species Accumulation Curves }
 \description{
@@ -19,6 +20,9 @@
     col = par("fg"), ci.col = col, ci.lty = 1, xlab = "Sites", 
     ylab = x$method, ylim, ...)
 \method{boxplot}{specaccum}(x, add = FALSE, ...)
+fitspecaccum(object, model, method = "random", ...)
+\method{plot}{fitspecaccum}(x, col = par("fg"), lty = 1, xlab = "Sites", 
+    ylab = x$method, ...) 
 }
 
 \arguments{
@@ -52,6 +56,8 @@
     \code{"polygon"}.}
   \item{xlab,ylab}{Labels for \code{x} and \code{y} axis.}
   \item{ylim}{the y limits of the plot.}
+  \item{object}{Either a community data set or fitted \code{specaccum} model.}
+  \item{model}{Nonlinear regression model (\code{\link{nls}}). See Details.}
   \item{...}{Other parameters to functions.}
 }
 \details{
@@ -81,6 +87,8 @@
 
   The function has a \code{plot} method. In addition, \code{method =
     "random"} has \code{summary} and \code{boxplot} methods. 
+
+  Description of \code{fitspecaccum} comes here\dots
 }
 
 \value{



More information about the Vegan-commits mailing list