A few days ago I posted a question to this discussion group concerning
to origin of an error message < subscript out of bounds > while using
the nonlinear mixed model (nlme) function in R with a self-starting
function.  Thanks for those who responded. This posting is to explain
what (I think) it causing the error.

 

Pinheiro & Bates (2000, pages 342-347) describe how to construct a
self-starting function for use in nls, nlsList and nlme.  A
self-starting function provides, not only the function to be evaluated,
but also estimates of initial values of the parameters that are to be
estimated.  I have written a self-starting function (NRhyperbola) for a
non-rectangular hyperbola with 4 parameters (theta, Am, alpha, Rd).  The
function works:

 

>
getInitial(Photosynthese~NRhyperbola(Irr,theta,Am,alpha,Rd),data=lit.dat
a2,na.action=na.omit)

      theta          Am       alpha          Rd 

 0.69495045 35.32201003  0.03156335  1.26873011

 

If one calls the nlsList function with a grouping variable using
NRhyperbola one gets the parameter estimates for each group:

 

>
nlsList(Photosynthese~NRhyperbola(Irr,theta,Am,alpha,Rd)|Groupe,data=lit
.data2,na.action=na.omit)

 

Coefficients:

          theta        Am      alpha           Rd

1   0.442150628  3.303208 0.00659723 -3.229906256

2   0.838342670 26.331938 0.05824155  0.239244579

3   0.513979519  8.650714 0.07326543  1.931373980

4   0.304795985  6.080392 0.06161286  1.194595984

5   0.870235949  5.245667 0.04243476  1.873685797

6   0.882610059  7.732813 0.04409574  0.039987285

7   0.901297969 12.655540 0.07025121  0.288532206

8   0.319134655 10.378213 0.01228871 -0.009558434

9   0.173420670 18.799837 0.02182253  0.025902109

10           NA        NA         NA           NA

11           NA        NA         NA           NA

12           NA        NA         NA           NA

13  0.898779206 28.232093 0.06589758 10.130898439

14           NA        NA         NA           NA

15  0.588541525 16.076403 0.05198140  4.102262827

16 -0.579787245 85.421300 0.06644187  4.879817577

17  0.538103607 34.046475 0.06338304  3.230418320

18 -0.149304124 46.348766 0.14660061  2.816890625

19  0.001826296 42.038952 0.09758133  0.175960147

20           NA        NA         NA           NA

 

Degrees of freedom: 175 total; 115 residual

Residual standard error: 1.257301

 

Parameter values for some groups cannot be estimated because there is
insufficient variation in the independent value.  Notice that the call
to nlsList returns the 4 parameter values for each group.  To get the
average (fixed effect) values one must use fixef(obj):

 

fixef(nlsList(Photosynthese~NRhyperbola(Irr,theta,Am,alpha,Rd)|Groupe,da
ta=lit.data2,na.action=na.omit))

      theta          Am       alpha          Rd 

 0.43627516 23.42282078  0.05883306  1.84600701

 

When one calls the nonlinear mixed model function (nlme) using this
selfstarting function one gets an error stating that the "subscript is
out of bounds".  However, this error does not occur if one explicitly
gives the starting values as those obtained using the fixed effects.

 

It seems as if the nlme function is receiving more than 1 starting value
for each of the 4 parameters when it uses the self-starting function.  I
suspect that the nlme function calls nlsList to get its starting values
but does not request the fixed effects (i.e. it uses the output from
nlsList rather than the output from fixed(nlsList).  I can't get inside
the nlme function to verify this.

 

 

Bill Shipley

 


	[[alternative HTML version deleted]]


