[R] non-linear curve fitting

Philippe Grosjean phgrosjean at sciviews.org
Thu Mar 22 14:01:58 CET 2007


Hello,

If a least-square criterion is fine for you, you should use nls(). For 
the logistic curve, you have a convenient self-starting model available: 
SSlogis(). Look at:

?nls
?SSlogis

Best,

Philippe Grosjean

..............................................<°}))><........
  ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..............................................................

Hufkens Koen wrote:
> Hi list,
>  
> I have a little curve fitting problem.
>  
> I would like to fit a sigmoid curve to my data using the following equation:
>  
> f(x) = 1/(1 + exp(-(x-c)*b)) (or any other form for that matter)
>  
> Where x is the distance/location within the dataframe, c is the shift of the curve across the dataframe and b is the steepness of the curve.
>  
> I've been playing with glm() and glm.fit() but without any luck.
>  
> for example the most simple example
>  
> x = -10:10
> y = 1/(1 + exp(-x))
> glm(y ~ x, family=binomial(link="logit"))
>  
> I get a warning:
> non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) 
>  
> and some erratic results
>  
> This is the most simple test to see if I could fit a curve to this perfect data so since this didn't work out, bringing in the extra parameters is a whole other ballgame so could someone give me a clue?
>  
> Kind regards,
> Koen
>  
>



More information about the R-help mailing list