
> 
> Thanks very much Douglas for the pointer to nlm.
> Maybe the "Notes on R" maintainer can add at least a mention of nlm in the
> section on nonlinear fitting?
> 
> I never did nonlinear fitting in S-Plus before, so I have nothing to
> unlearn, but I was hoping someone could show me how to do a least squares
> fit with nlm.
> 
> example:
> x<-c(1,2,3,4,5,6)
> y<-.3*x^-.6 +.2
> y<-y+rnorm(6,0,.01)
> 
> Please show me how to fit the model
> y=a*x^b + c
> by least squares.  I would like parameter estimates plus the standard
> error for each param.

try
fn <- function(p) (y-p[1]*x^p[2]+p[3])^2
nlm(fn,p=c(0.3,-0.6,0.2))
Of course, you usually will not have such good initial estimates as
those I put in the p vector! There are a lot of further options to nlm
if you have convergence problems. See the help.
  Jim

> 
> (This example could replace the current nonlinear fitting section in
> "Notes on R")
> 
> Thanks very much for any help!
> 
> Bill Simpson
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

