Yuchen Luo wrote: > Dear Colleagues. > > I believe this should be a problem encountered by many: > > nls( ) is a very useful and efficient function to use if we are just to > display the estimated value on screen. What if we need R to store the > estimated parameter in a variable? > > For example: > > x=rnorm(10, mean=1000, sd=10) > > y=x^2+100+rnorm(10) > > a=nls(y~(x^2+para),control=list(maxiter = 1000, minFactor=0.5 > ^1024),start=list(para=0.0)) > > How to store the estimated value of para in this case, in a variable, say, > b? > > It is easy to display a and find all the information. How ever, I need to > fit a different set of x and y in every loop of my code and I need to store > the estimated values for further use. I have checked both the online manual > and several S-plus books but no example as such showed up. > > Your help will be highly appreciated!
coef(a) will get what you want. coef() works for most modelling functions where it makes sense. Duncan Murdoch ______________________________________________ R-help@stat.math.ethz.ch 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.