## 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",
ylim = c(1, max(S)))
## The Arrhenius model
marr <- nls(S ~ SSarrhenius(sipoo.area, k, z))
marr
## confidence limits from profile likelihood
confint(marr)
## draw a line
xtmp <- seq(min(sipoo.area), max(sipoo.area), len=51)
lines(xtmp, predict(marr, newdata=data.frame(sipoo.area = xtmp)), lwd=2)
## The normal way is to use linear regression on log-log data,
## but this will be different from the previous:
mloglog <- lm(log(S) ~ log(sipoo.area))
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 = 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 = 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 = 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, Gleason = mgle, Gitay = mgit,
Lomolino = mlom, MicMen= mmic)
sapply(allmods, AIC)
Run the code above in your browser using DataLab