[R] help with a self-starting function in nonlinear least squares regression.

From: Bill Shipley <bill.shipley_at_usherbrooke.ca>
Date: Wed 26 Oct 2005 - 23:38:27 EST


Hello. I am having a problem setting up a self-starting function for use in nonlinear regression (and eventually in the mixed model version). The function is a non-rectangular hyperbola - called "NRhyperbola" - which is used for fitting leaf photosynthetic rate to light intensity. It has one independent variable (Irr) and four parameters (theta, Am, alpha and Rd). I have created this to act as a self-starting function. The self-starting function seems to work (i.e. when I call "getInitial" it provides the initial values), but I can't get it to work when used within "nls". Here is an example:  

1)

>

getInitial(Photosynthese~NRhyperbola(Irr,theta,Am,alpha,Rd),data=lit.dat a[1:11,])

        theta Am alpha Rd

 0.5021546914 3.7466359015 0.0005743723 -3.0685671752  

So, "getInitial" succeeds in extracting the initial values from the function.  

2)

>

nls(Photosynthese~NRhyperbola(Irr,theta,Am,alpha,Rd),data=lit.data[1:11, ])

Error in eval(expr, envir, enclos) : Object "theta" not found  

But the call to "nls" does not find the parameter theta, even though the call "getInitial" did find it and returned its initial value.  

I am working from the Pinheiro & Bates book on mixed-effects models in S and S-PLUS. According to that book (p. 346): "When nls is called without initial values for the parameters and a self-start model function is provided, nls calls getInitial to provide the initial values."  

Two questions:  

  1. what am I doing wrong?
  2. When a self-Starting model is called from within nlsList or nlme, is getInitial only called one (to get the values ignoring any hierarchical structure in the data) or is it called for each group?

Thanks.  

Bill Shipley  

        [[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 Received on Thu Oct 27 00:09:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:47 EST