[R-sig-eco] Logistic regression

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Jun 7 10:09:29 CEST 2011


On Mon, 2011-06-06 at 15:25 -0300, Luiz Ernesto Costa-Schmidt wrote:
> Dear fellows from R-sig-Ecology,
> 
> Given that I am not familiar with general linear models, I would like to
> consult you for a specific situation that I am facing with my dataset. I am
> trying to calculate the predation risk of an heterospecific interaction
> based on the size differences of the individuals and two other categorical
> variables. My dataset is composed by the following variables:

>From your description, it sounds like you mean a generalised linear
model (the general linear model is something quite different).

Anyway, is there a reason why you don't want to use the standard R
function glm() to fit your logistic regression?

At the very least, you might get more informative warnings about
problems with the fit/data than with a general purpose optimisation
routine that can be used for far more things than just logistic
regression.

G

> Predation: binary (0 or 1)
> 
> Size difference: continuous (mm)
> 
> Treatment: categorical (group A, group B)
> 
> Pairing: categorical (species a-b, species b-a)
> 
> I am using the mle2 function from the package bbmle, based on a binomial
> distribution.
> 
> The models that I am testing are the following:
> 
> Model 1: null model:
> 
> > m1 <- mle2 (k ~ dbinom (prob = p, size = 1), start = list (p = .5), data =
> list (N =1, k=predation))
> 
> Model 2: predation ~ size difference:
> 
> > modlogist = function (x, a, b) {
> 
> >             exp (a + b * (x))/(1 + exp (a + b * (x)))
> 
> >             }
> 
> > m2 <- mle2 (k ~ dbinom (prob = modlogist (size difference, a, b), size =
> 1),
> 
> + start = list (a = 0, b =0), data = list (N = 1, k = predation))
> 
> Model 3: predation ~ size difference*treatment:
> 
> > start.3 = as.list (coef (m2))
> 
> > m3 <- mle2 (k ~ dbinom (prob = modlogist (size difference, a, b), size =
> 1), start = start.3,
> 
> + data = list (N = 1, k = predation), parameters = list (a ~ treatment, b ~
> treatment))
> 
> 
> 
> Model 4: predation ~ size difference*pairing
> 
> > start.4 = as.list (coef (m2))
> 
> > m4 <- mle2 (k ~ dbinom (prob = modlogist (size difference, a, b), size =
> 1), start = start.4,
> 
> + data = list (N = 1, k = predation), parameters = list (a ~ pairing, b ~
> pairing))
> 
> 
> 
> Model 5: predation ~ size difference*treatment:pairing
> 
> > start.5 = as.list (coef (m2))
> 
> > m5 <- mle2 (k ~ dbinom (prob = modlogist (size difference, a, b), size =
> 1), start = start.5,
> 
>                 + data = list (N = 1, k = predation), parameters = list (a ~
> treat:pair, b ~ treat:pair))
> 
> 
> 
> For one of the pairing groups (let say species a-b) not a single predation
> event occurred. When I call the summary of the 4th model, the standard
> errors of the estimates are absurdly high. Initially I thought that this
> could be related to the optimization algorithm. However, even performing
> some of the basic changes in the mle2 optimization parameters I could not
> find a proper solution.
> 
> Can anyone suggest me where to find the necessary information in order to
> solve this situation? Are there any other points that I am missing here?
> 
> Thanks in advance!
> 
> Ernesto
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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-sig-ecology mailing list