Re: [R] How to store the parameter estimated by nls( ) to a variable?

2007-08-13 Thread Joerg van den Hoff
On Sun, Aug 12, 2007 at 10:50:59AM -0700, Yuchen Luo wrote:
 Dear Professor Murdoch.
 Thank you so much
 
 Best Wishes
 Yuchen Luo
 
 On 8/12/07, Duncan Murdoch [EMAIL PROTECTED] wrote:
 
  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
 
 

further information might be extracted from the `summary' return value.
e.g., if you need not only the parameters but also their error
estimates, you could get them via

summary(a)$parameters[, Std. Error]

(question: is this the canonical way to do it or is their a better one?)

__
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.


[R] How to store the parameter estimated by nls( ) to a variable?

2007-08-12 Thread Yuchen Luo
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!

Best Wishes

Yuchen Luo

[[alternative HTML version deleted]]

__
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.


Re: [R] How to store the parameter estimated by nls( ) to a variable?

2007-08-12 Thread Duncan Murdoch
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.


Re: [R] How to store the parameter estimated by nls( ) to a variable?

2007-08-12 Thread Yuchen Luo
Dear Professor Murdoch.
Thank you so much

Best Wishes
Yuchen Luo

On 8/12/07, Duncan Murdoch [EMAIL PROTECTED] wrote:

 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


[[alternative HTML version deleted]]

__
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.