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

Bert Gunter gunter.berton at gene.com
Tue Mar 30 19:45:40 CEST 2010


Your model is almost certainly over-parameterized (given the data that you
have to fit it), and the asymptotic correlation matrix of the parameters
that you should get from the solutions that converged will probably have
some large off diagonal elements. In other words, your model is essentially
non-identifiable.

If you don't know what the above means, you shouldn't be using nls.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Gabor Grothendieck
Sent: Tuesday, March 30, 2010 4:25 AM
To: Corrado
Cc: r-help at r-project.org
Subject: Re: [R] Error "singular gradient matrix at initial
parameterestimates" in nls

You could try method="brute-force" in the nls2 package to find starting
values.

On Tue, Mar 30, 2010 at 7:03 AM, Corrado <ct529 at york.ac.uk> wrote:
> I am using nls to fit a non linear function to some data.
>
> The non linear function is:
>
> y= 1- exp(-(k0+k1*p1+ .... + kn*pn))
>
> I have chosen algorithm "port", with lower boundary is 0 for all of the ki
> parameters, and I have tried many start values for the parameters ki
> (including generating them at random).
>
> If I fit the non linear function to the same data using an external
> algorithm, it fits perfectly and finds the parameters.
>
> As soon as I come to my R installation (2.10.1 on Kubuntu Linux 910 64
bit),
> I keep getting the error:
>
> Error in nlsModel(formula, mf, start, wts, upper) :   singular gradient
> matrix at initial parameter estimates
>
> I have read all the previous postings and the documentation, but to no
> avail: the error is there to stay. I am sure the problem is with nls,
> because the external fitting algorithm perfectly fits it in less than a
> second. Also, if my n is 4, then the nls works perfectly (but that
excludes
> all the k5 .... kn).
>
> Can anyone help me with suggestions? Thanks in advance.
>
> Alternatively, what do you suggest I should do? Shall I abandon nls in
> favour of optim?
>
> Regards
>
> --
> 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.
>

______________________________________________
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