On Tue, Apr 17, 2012 at 12:23 AM, Francisco Mora Ardila <fm...@oikos.unam.mx> wrote: > Hi > > I´m trying to fit a nonlinear model to a derivative of the logistic function > > y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function > with nls) > > The derivative calculated with D function is: > >> logis<- expression(a/(1+exp((b-x)/c))) >> D(logis, "x") > a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 > > So I enter this expression in the nls function: > > ratelogis <- nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, > start=list(a = 21.16322, b = 8.83669, c = 2.957765), > ) > > The data is: > >> Y > [1] 5.5199668 1.5234525 3.3557000 6.7211704 7.4237955 1.9703127 > [7] 4.3939336 -1.4380091 3.2650180 3.5760906 0.2947972 1.0569417 >> X > [1] 1 0 0 4 3 5 12 10 12 100 100 100 > > The problem is that I got the next error: > > Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : > step factor 0.000488281 reduced below 'minFactor' of 0.000976563 >
Try alg = "plinear" noting that we must drop the linear coefficient a from the formula and starting values and .lin in the output represents a: ratelogis <- nls(Y ~ (exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(b = 8.83669, c = 2.957765), alg = "plinear" ) ratelogis plot(X,Y) o <- order(X) lines(X[o], fitted(ratelogis)[o], col = "red") -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.