[R] help with nlme function

Spencer Graves spencer.graves at pdf.com
Sun Nov 12 20:28:31 CET 2006


      The primary (if not the only) documentation for the 'nlme' 
function, beyond that in the 'nlme' package, is Pinheiro and Bates. 

      Your example is not self contained, which makes it not feasible 
for me to say much about your problem.  Have you tried to reduce the 
size and complexity of your example as much as possible and still get 
the same error?  Also, have you worked the examples in the 'nlme' help 
files plus Pinheiro and Bates, then gradually increasing the complexity 
of one of their examples until you get what you want?  (In particular, 
have you worked through the files "ch06.R" and "ch08.R" in 
"~\library\nlme\scripts" in the installation of R on your hard drive?)  
With luck, these steps will either answer your question or produce a 
simple, self-contained example you can send to this list to illustrate 
your question. 

      If I tried all that without success, I'd try using 'debug' to walk 
through the code line by line until I reached enlightenment.  The first 
step on this journey is the following: 

 > methods("nlme")
[1] nlme.formula nlme.nlsList

      This already suggests an alternative path you might try, namely 
'nlme(fit)' with the output of 'nlsList'.  Have you tried that?  If that 
produced the same result. I'd make a local copy of 'nlme.formula', then 
issue 'debug("nlme.formula")' and follow that with your call to 'nlme'.  
This will allow you to walk through the function line by line until you 
see where it dies.  In the process, you will likely find the problem. 

      Hope this helps. 
      Spencer Graves

Bill Shipley wrote:
> Hello.  I am trying to fit a nonlinear mixed model involving 3 parameters.
> I have successfully made a self-starting function.  getInitial() correctly
> outputs the initial estimates.  I can also use the nlsList with this
> function to get the separate nonlinear fits by group.  However, I get an
> error message when using the nlme function.  Here is the relevent code:
>
> fit<-nlsList(photosynthesis~photo(irradiance,Q,Am,LCP)|species/plant/leaf,da
> ta=marouane.data,
> + na.action=na.omit)
>
> This works, showing that the function "photo" works as a self-starting
> function.
>
> nlme(model=photosynthesis~photo(irradiance,Q,Am,LCP),
> + data=marouane.data,fixed=Q+Am+LCP~1,
> + random=Q+Am+LCP~1|species,na.action=na.omit)
> Error: subscript out of bounds
>
> This is what happens when I use the nlme function.  I don't know what
> "subscript out of bounds" means but I assume that there is something wrong
> with the syntax of my code.
>
> The data frame (marouane.data) has dimensions of 1000 and 9.  The first
> three columns give the group structure (species, plants within species,
> leaves within plants).  "species" is a factor while "plants" is coded 1 or 2
> and "leaves" is also coded 1 or 2.  The other columns give values of
> measured variables.
>
> Could someone explain what I am doing wrong?  Alternatively, is there
> another text besides Pinheiro & Bates that explains the basic syntax of the
> nlme function?
>
> Thanks.
> Bill Shipley
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list