[R] Results of nls

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Dec 9 23:47:22 CET 2004


"Y. C. Tao" <nov_tao at yahoo.com> writes:

> This might be an easy question.
> 
> I tried to catch the results of nls, but to no avail.
> For example, if I try to fit a modle y~A*x*x+B*x+C
> nls will print out what A, B, and C, but how can I
> store these numbers to a different variable so that I
> can make use of them? I tried to "unclass" the result
> of nls, but couldn't see any of the parameters.

example(nls)
coef(fm3DNase1)

The coefficients *are* in the nls object, but it's a little
complicated: 

fm3DNase1$m$getPars()

which in turns picks out the stored parameters from it's own lexical
scope. If you want to "burglarize" it, try

get("internalPars",env=environment(fm3DNase1$m$getPars)) 

but in general you're supposed to use access functions like coef() so
that you don't need to know about the internals (they might change!).

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list