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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 3 21:37:15 CEST 2010


Author: jarioksa
Date: 2010-10-03 21:37:14 +0200 (Sun, 03 Oct 2010)
New Revision: 1325

Added:
   pkg/vegan/R/SSarrhenius.R
Modified:
   pkg/vegan/R/fitspecaccum.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/specaccum.Rd
Log:
added self starting Arrhenius model for nls used this in fitspecaccum

Added: pkg/vegan/R/SSarrhenius.R
===================================================================
--- pkg/vegan/R/SSarrhenius.R	                        (rev 0)
+++ pkg/vegan/R/SSarrhenius.R	2010-10-03 19:37:14 UTC (rev 1325)
@@ -0,0 +1,10 @@
+SSarrhenius <-
+    selfStart(function(area, k, z) k*area^z,
+              function(mCall, data, LHS)
+{
+    xy <- sortedXyData(mCall[["area"]], LHS, data)
+    value <- as.vector(coef(lm(log(xy[,"y"]) ~ log(xy[,"x"]))))
+    names(value) <- mCall[c("k","z")]
+    value
+},
+c("k","z"))

Modified: pkg/vegan/R/fitspecaccum.R
===================================================================
--- pkg/vegan/R/fitspecaccum.R	2010-10-03 13:09:59 UTC (rev 1324)
+++ pkg/vegan/R/fitspecaccum.R	2010-10-03 19:37:14 UTC (rev 1325)
@@ -1,4 +1,6 @@
-fitspecaccum <- function(object, model = "michaelis-menten", method = "random",  ...)
+fitspecaccum <-
+    function(object, model = c("michaelis-menten", "arrhenius"),
+             method = "random",  ...)
 {
     model <- match.arg(model)
     if (!inherits(object, "specaccum")) 
@@ -11,8 +13,11 @@
         x <- object$individuals
     else
         x <- object$sites
-    ## Only Michaelis-Menten implemented now: no need to switch() yet.
-    mods <- apply(SpeciesRichness, 2, function(y) nls(y ~ SSmicmen(x, Vm, K))) 
+    mods <- switch(model,
+        "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))))
     object$fitted <- drop(sapply(mods, fitted))
     object$residuals <- drop(sapply(mods, residuals))
     object$coefficients <- drop(sapply(mods, coef))

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-10-03 13:09:59 UTC (rev 1324)
+++ pkg/vegan/inst/ChangeLog	2010-10-03 19:37:14 UTC (rev 1325)
@@ -9,7 +9,9 @@
 
 	* fitspecaccum: Stephen Sefick suggested adding Michaelis-Menten
 	fit to random species accumulation and sent his model function.
-	These ideas were used to add a new more general function. No
+	These ideas were used to add a new more general function. In
+	addition, there is an option of fitting Arrhenius model S = c*A^z
+	with a new self stargint function SSarrhenius() for nls(). No
 	documentation yet: needs work.
 
 	* decorana: gives warning if residual is bigger than tolerance.

Modified: pkg/vegan/man/specaccum.Rd
===================================================================
--- pkg/vegan/man/specaccum.Rd	2010-10-03 13:09:59 UTC (rev 1324)
+++ pkg/vegan/man/specaccum.Rd	2010-10-03 19:37:14 UTC (rev 1325)
@@ -5,6 +5,7 @@
 \alias{plot.specaccum}
 \alias{boxplot.specaccum}
 \alias{fitspecaccum}
+\alias{SSarrhenius}
 
 \title{Species Accumulation Curves }
 \description{



More information about the Vegan-commits mailing list