Skip to content

optima in unimode

2 messages · ms.com, Gavin Simpson

#
On Thu, 2009-05-28 at 07:50 +0000, ms.com wrote:
You're going to have to give us more to go on than that, but...

Are you an ecologist and you want to estimate the optima and tolerance
range from a fitted logit model? If so, here is an example:

## install.packages("analogue") if not installed
require(analogue)
data(ImbrieKipp, SumSST)

## fit a model
mod <- glm(G.pacR ~ SumSST + I(SumSST^2), data = ImbrieKipp/100,
           family = binomial)
## plot it
pdat <- data.frame(SumSST= seq(min(SumSST), max(SumSST), length = 100))
p2 <- predict(mod, pdat, type = "response")
lines(p2 ~ SumSST, data = pdat, col = "blue", lwd = 3)

## model ceofficients
c.mod <- coef(mod)
## optima
-c.mod[2]/(2 * c.mod[3])
## tolerance
sqrt(-(1/(2 * c.mod[3])))
## height == abundance at optimum
exp(c.mod[1] - (c.mod[2]^2/(4 * c.mod[3])))

HTH

G