[R] nls: "missing value or an infinity" (Error in numericDeriv) and"singular gradient matrix"Error in nlsModel
Ravi Varadhan
rvaradhan at jhmi.edu
Tue Feb 13 22:28:11 CET 2007
Hi Daniela,
Please read the error message from nls. The problem is with the "start
values" for the parameters a and b. You haven't specified any, so it uses
default values of a=1 and b=1, which may not be very good. So, you should
specify good start values, if you have a reasonable idea of what they should
be. If you don't, then you could try selfStart, as the error message tells
you to do.
Ravi.
----------------------------------------------------------------------------
-------
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging and Health
Division of Geriatric Medicine and Gerontology
Johns Hopkins University
Ph: (410) 502-2619
Fax: (410) 614-9625
Email: rvaradhan at jhmi.edu
Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
----------------------------------------------------------------------------
--------
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Daniela Salvini
Sent: Tuesday, February 13, 2007 4:09 PM
To: r-help at stat.math.ethz.ch
Subject: [R] nls: "missing value or an infinity" (Error in numericDeriv)
and"singular gradient matrix"Error in nlsModel
Hi,
I am a non-expert user of R. I am essaying the fit of two different
functions to my data, but I receive two different error messages. I suppose
I have two different problems here... But, of which nature? In the first
instance I did try with some different starting values for the parameters,
but without success.
If anyone could suggest a sensible way to proceed to solve these I would be
really thankful!
Daniela
*******
Details on data and formulas:
> polcurve=read.table("polcurve.txt",header=TRUE)
> polcurve
dist fath
1 1 0.138908965
2 2 0.113768871
3 3 0.114361753
4 4 0.051065765
5 5 0.095787946
6 6 0.123601131
7 7 0.117340746
8 8 0.054049434
9 9 0.112000962
10 10 0.074843028
11 11 0.064735196
12 12 0.098210497
13 13 0.093786895
14 14 0.033752379
15 15 0.038961039
16 16 0.023048216
17 17 0.010018243
18 18 0.007177034
19 19 0.003787879
20 20 0.000000000
21 21 0.000000000
#Exponential power function
> s=nls(fath~((b^2)/(a^2))*exp((-dist/a)^b),polcurve)
Error in numericDeriv(form[[3]], names(ind), env) :
Missing value or an infinity produced when evaluating the model
In addition: Warning message:
No starting values specified for some parameters.
Intializing 'b', 'a' to '1.'.
Consider specifying 'start' or using a selfStart model in: nls(fath ~
((b^2)/(a^2)) * exp((-dist/a)^b), polcurve)
#Geometric function
>s=nls(fath~((b-1)*(b-2)/a)*((1+dist/a)^-b),polcurve)
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
In addition: Warning message:
No starting values specified for some parameters.
Intializing 'b', 'a' to '1.'.
Consider specifying 'start' or using a selfStart model in: nls(fath ~ ((b -
1) * (b - 2)/a) * ((1 + dist/a)^-b),
Daniela Salvini
Ph.D. student
University of Copenhagen,
Faculty of Life Sciences,
Centre for Forest and Landscape
Hørsholm Kongevej 11
2970 Hørsholm, Denmark
e-mail: dsa at life.ku.dk
Tel.: (+45)35281639 / 35281645
Fax.: (+45)35281517
______________________________________________
R-help at stat.math.ethz.ch 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