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

Ravi Varadhan rvaradhan at jhmi.edu
Wed Mar 31 15:57:54 CEST 2010


Try the function called `nls.lm' which is contained in the "minpack.lm" package.  See if it solves your problem.

Ravi.  

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Corrado
Sent: Wednesday, March 31, 2010 9:13 AM
Cc: r-help at r-project.org
Subject: Re: [R] Error "singular gradient matrix at initial parameter estimates" in nls

Dear JN, Bert,

1) It is not a perfect fit. I do not think I have ever said that. I said 
that an external algorithms fits the model without any problems: with ~ 
500,000 data points and 19 paramters (ki in the original equation), it 
fits the model in less than 1 second. The data are not artificial data. 
The variables are independent (pi in the original model). The solution 
is unique and the rapidity of convergence is practically independent 
from the selection of start conditions (with a reasonable selection of 
start conditions at least). The resulting residuals are approximately 
normally distributed with mean 0 and sd ~ 4.23.

2) I agree with the comment of Bert on over-parametrization, but again 
the model is not overparamterised, and it is identifiable (in part 
answered already in (1))

Regards


Prof. John C Nash wrote:
> 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
>


-- 
Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk

______________________________________________
R-help at r-project.org 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