Skip to content
Back to formatted view

Raw Message

Message-ID: <x2ek68b798.fsf@viggo.kubism.ku.dk>
Date: 2005-10-26T15:57:55Z
From: Peter Dalgaard
Subject: help with a self-starting function in nonlinear least squares regression.
In-Reply-To: <001b01c5da32$8c24d050$9a1ad284@BIO041>

"Bill Shipley" <bill.shipley at usherbrooke.ca> writes:

> 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?

Not telling us how you created NRhyperbola....

 
> 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?


Each group, it seems. Certainly, nlsList is just lapply'ing nls over
split(data, ...), and as far as I can see nlme starts off by running
nlsList. Then nlme.nlsList takes the median of the coefficients to get
the overall starting value. (Of course, you might as well have read
the code yourself...)

-- 
   O__  ---- Peter Dalgaard             ??ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907