[R] Fit non-linear regressor

Tony Plate tplate at acm.org
Fri Jan 9 21:58:45 CET 2004

It's reasonably straightforward to use nls() for this:

 > d <- 
 > fit <- nls(y~R*exp(x*A),start=list(R=2,A=0.1),data=d)
 > plot(x,y)
 > lines(x, coef(fit)[1]*exp(x*coef(fit)[2]))

You might want to check that your objective does not have local optima (in 
which case the assumption that minimizing the  sum-squared residual will 
minimize your objective may be false).

hope this helps,

Tony Plate

At Friday 04:35 PM 1/9/2004 -0200, Bernardo Rangel Tura wrote:
>Hi R masters,
>Sorry for first mensage, this is orignal text...
>I need fit R and A in y=f(x)=R*exp(A*x), with minimize sd= sqrt(SRR/(n-2)) 
>where SRR is Sum of the Square of the Residuals
>and n is number of data points (in this case 10)
>How do I make this?
>Thanks in advance
>Bernardo Rangel Tura, MD, MSc
>National Institute of Cardiology Laranjeiras
>Rio de Janeiro Brazil
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Tony Plate   tplate at acm.org

More information about the R-help mailing list