[R] Error "singular gradient matrix at initial parameter estimates" in nls

Prof. John C Nash nashjc at uottawa.ca
Wed Mar 31 13:26:59 CEST 2010


If you have a perfect fit, you have zero residuals. But in the nls manual page we have:

> Warning:
> 
>      *Do not use ‘nls’ on artificial "zero-residual" data.*

So this is a case of complaining that your diesel car is broken because you ignored the 
"Diesel fuel only" sign on the filler cap and put in gasoline.

However I've not been happy with this choice in the code of nls -- it's been there a long 
time -- and my own codes from 1974 onwards have always handled zero residual cases. I do 
believe that the code could at least give a better diagnostic message. Zero residuals -- 
perfect fits -- arise when one is interested more or less in an interpolating function 
rather than doing statistics, and I can understand the reluctance of statisticians to 
countenance such a use of nls.

And Bert's comment on overparametrization is almost certainly valid also.

JN



More information about the R-help mailing list