[R] Fit a logit curve to the data

(Ted Harding) Ted.Harding at manchester.ac.uk
Fri Mar 14 01:41:01 CET 2008


On 13-Mar-08 22:56:16, Alfonso Pérez wrote:
>     Hello, my name is Alfonso. My data are 0 and 1 values in
> the y axis and fish length in the x axis. I'm trying to get
> a graph where it could be fitted a logit curve to my data,
> how could I get it?

Have a look at

  ?glm

In particular (just going on your bare statement of your problem)
let 'y' denote your vector or 0/1 results:

  x <- fishlength
  y <- glm(y ~ fishlength, family=binomial)$fit
  plot(x,y)
  lines(x,y)

would be a start.

However, I'm intrigued by what your variable y (more likely to
be 1 as fishlength increases) might be. "Sexually mature"?

There might be a better model for it than the logistic curve.

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 14-Mar-08                                       Time: 00:40:59
------------------------------ XFMail ------------------------------



More information about the R-help mailing list