[Vegan-commits] r1362 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 10 20:32:52 CET 2010
Author: jarioksa
Date: 2010-11-10 20:32:52 +0100 (Wed, 10 Nov 2010)
New Revision: 1362
Added:
pkg/vegan/R/SSgleason.R
Modified:
pkg/vegan/R/fitspecaccum.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/SSarrhenius.Rd
Log:
add SSgleason species-area model
Added: pkg/vegan/R/SSgleason.R
===================================================================
--- pkg/vegan/R/SSgleason.R (rev 0)
+++ pkg/vegan/R/SSgleason.R 2010-11-10 19:32:52 UTC (rev 1362)
@@ -0,0 +1,11 @@
+SSgleason <-
+ selfStart(~ k + slope*log(area),
+ function(mCall, data, LHS)
+{
+ ## Gleason is a linear model: starting values are final ones
+ xy <- sortedXyData(mCall[["area"]], LHS, data)
+ value <- as.vector(coef(lm(xy[,"y"] ~ log(xy[,"x"]))))
+ names(value) <- mCall[c("k","slope")]
+ value
+},
+c("k","slope"))
Modified: pkg/vegan/R/fitspecaccum.R
===================================================================
--- pkg/vegan/R/fitspecaccum.R 2010-11-10 14:03:06 UTC (rev 1361)
+++ pkg/vegan/R/fitspecaccum.R 2010-11-10 19:32:52 UTC (rev 1362)
@@ -1,8 +1,8 @@
fitspecaccum <-
function(object, model, method = "random", ...)
{
- MODELS <- c("arrhenius", "gitay", "lomolino", "asymp",
- "gompertz", "michaelis-menten", "logis",
+ MODELS <- c("arrhenius", "gleason", "gitay", "lomolino",
+ "asymp", "gompertz", "michaelis-menten", "logis",
"weibull")
model <- match.arg(model, MODELS)
if (!inherits(object, "specaccum"))
@@ -18,6 +18,8 @@
mods <- switch(model,
"arrhenius" = apply(SpeciesRichness, 2,
function(y) nls(y ~ SSarrhenius(x, k, z), ...)),
+ "gleason" = apply(SpeciesRichness, 2,
+ function(y) nls(y ~ SSgleason(x, k, slope), ...)),
"gitay" = apply(SpeciesRichness, 2,
function(y) nls(y ~ SSgitay(x, k, slope), ...)),
"lomolino" = apply(SpeciesRichness, 2,
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2010-11-10 14:03:06 UTC (rev 1361)
+++ pkg/vegan/inst/ChangeLog 2010-11-10 19:32:52 UTC (rev 1362)
@@ -4,6 +4,8 @@
Version 1.18-16 (opened November 9, 20109
+ * SSgleason: a new SS-species-area-model.
+
* SSlomolino: improved starting values for 'xmid' (and
'Asym'). Now fitspecaccum(..., "lomolino") works in several cases,
including BCI and bryceveg (but fails in <1% of cases). Now 'Asym'
Modified: pkg/vegan/man/SSarrhenius.Rd
===================================================================
--- pkg/vegan/man/SSarrhenius.Rd 2010-11-10 14:03:06 UTC (rev 1361)
+++ pkg/vegan/man/SSarrhenius.Rd 2010-11-10 19:32:52 UTC (rev 1362)
@@ -2,6 +2,7 @@
\alias{SSarrhenius}
\alias{SSlomolino}
\alias{SSgitay}
+\alias{SSgleason}
\title{
Self-Starting nls Species-Area Models
@@ -17,6 +18,7 @@
\usage{
SSarrhenius(area, k, z)
+SSgleason(area, k, slope)
SSgitay(area, k, slope)
SSlomolino(area, Asym, xmid, slope)
}
@@ -42,6 +44,11 @@
is the steepness of the species-area curve, and \code{k} is the
expected number of species in a unit area.
+ The Gleason model (\code{SSgleason}) is a linear expression
+ \code{k + slope*log(area)} (Dengler 200). This is a linear model,
+ and starting values give the final estimates; it is provided to
+ ease comparison with other models.
+
The Gitay model (\code{SSgitay}) is a quadratic logarithmic expression
\code{(k + slope*log(area))^2} (Gitay et al. 1991, Dengler
2009). Parameter \code{slope} is the steepness of the species-area
@@ -93,7 +100,8 @@
## Get species area data: sipoo.area gives the areas of islands
example(sipoo)
S <- specnumber(sipoo)
-plot(S ~ sipoo.area, xlab = "Island Area (ha)", ylab = "Number of Species")
+plot(S ~ sipoo.area, xlab = "Island Area (ha)", ylab = "Number of Species",
+ ylim = c(1, max(S)))
## The Arrhenius model
marr <- nls(S ~ SSarrhenius(sipoo.area, k, z))
marr
@@ -108,26 +116,29 @@
mloglog
lines(xtmp, exp(predict(mloglog, newdata=data.frame(sipoo.area=xtmp))),
lty=2)
+## Gleason: log-linear
+mgle <- nls(S ~ SSgleason(sipoo.area, k, slope))
+lines(xtmp, predict(mgle, newdata=data.frame(sipoo.area=xtmp)),
+ lwd=2, col=2)
## Gitay: quadratic of log-linear
mgit <- nls(S ~ SSgitay(sipoo.area, k, slope))
lines(xtmp, predict(mgit, newdata=data.frame(sipoo.area=xtmp)),
- lwd=2, col = 2)
+ lwd=2, col = 3)
## Lomolino: using original names of the parameters (Lomolino 2000):
mlom <- nls(S ~ SSlomolino(sipoo.area, Smax, A50, Hill))
mlom
lines(xtmp, predict(mlom, newdata=data.frame(sipoo.area=xtmp)),
- lwd=2, col = 3)
+ lwd=2, col = 4)
## One canned model of standard R:
mmic <- nls(S ~ SSmicmen(sipoo.area, slope, Asym))
lines(xtmp, predict(mmic, newdata = data.frame(sipoo.area=xtmp)),
- lwd =2, col = 4)
-legend("bottomright", c("Arrhenius", "log-log linear", "Gitay",
- "Lomolino", "Michaelis-Menten"), col=c(1,1,2,3,4), lwd=c(2,1,2,2,2),
- lty=c(1,2,1,1,1))
+ lwd =2, col = 5)
+legend("bottomright", c("Arrhenius", "log-log linear", "Gleason", "Gitay",
+ "Lomolino", "Michaelis-Menten"), col=c(1,1,2,3,4,5), lwd=c(2,1,2,2,2,2),
+ lty=c(1,2,1,1,1,1))
## compare models (AIC)
-allmods <- list(Arrhenius = marr, Gitay = mgit, Lomolino = mlom,
- MicMen= mmic)
-sapply(allmods, AIC)
+allmods <- list(Arrhenius = marr, Gleason = mgle, Gitay = mgit,
+ Lomolino = mlom, MicMen= mmic)
}
\keyword{ models }
More information about the Vegan-commits
mailing list