[R] optima in unimode

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu May 28 11:27:35 CEST 2009


On Thu, 2009-05-28 at 07:50 +0000, ms.com wrote:
> Dear all
> i could not estimate the optima value or range value in unimodal plot in glm
> please help me out
> 
> thanking you 
> 
> regard
> madan

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
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list