[R] start values for nls() that don't yield singular gradients?

Douglas Bates bates at stat.wisc.edu
Sat Apr 23 15:47:13 CEST 2005


James Salsman wrote:
> I'm trying to fit a Gompertz sigmoid as follows:
> 
> x <- c(15, 16, 17, 18, 19)      # arbitrary example data here;
> y <- c(0.1, 1.8, 2.2, 2.6, 2.9) # actual data is similar

It is a good practice to plot the data before trying to fit complicated 
nonlinear models.  If you are going to be able to get a reasonable fit 
of a model with four parameters you should be able to describe four 
characteristics of the curve that the model represents and what would be 
reasonable values based on your data plot.  See, for example, the plots 
of some sample curves in Appendix C of Pinheiro and Bates (Springer, 2000).

Now plot your sample data and describe four characteristics.  I can't 
see four characteristics in that plot.  I would conclude that there is 
insufficient information in those data to fit a four parameter nonlinear 
model of the form you are trying to fit.  The term "singular gradient 
matrix" means exactly that.

Please, always plot the data first.

> gm <- nls(y ~ a+b*exp(-exp(-c*(x-d))), start=c(a=?, b=?, c=?, d=?))
> 
> I have been unable to properly set the starting value '?'s.  All of
> my guesses yield either a "singular gradient" error if they are
> decent guesses, or a "singular gradient matrix at initial parameter
> estimates" error if they are bad guesses like all zeros.
> 
> How can I pick starting values that don't result in singular gradients?
> 
> I have had no luck with the "selfStart" models, e.g., "SSgompertz"
> -- the formula in "SSgompertz" is not the same as the one I need
> above, since it has three parameters instead of four.  I've tried
> it and SSfpl thusly:
> 
>  > getInitial(y ~ SSfpl(x,a,b,c,d),data=data.frame(x=x,y=y))
> Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = 
> xy,  :
>         step factor 0.000488281 reduced below `minFactor' of 0.000976563
> 
> And this:
> 
>  > getInitial(y ~ SSgompertz(x,a,b,c),data=data.frame(x=x,y=y))
> Error in nls(y ~ cbind(1, 1 - exp(-exp(lrc) * x)), data = xy, start = 
> list(lrc = as.vector(log(-coef(lm(log(abs(y -  :
>         singular gradient
> 
> Thanks for any help.




More information about the R-help mailing list