HongSheng Liao
2008-Feb-15 17:41 UTC
[R] Error 'singular gradient' in nonlinear model fitting
w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
start=list(alpha=1, beta=3),
data=spottedseatrout2004.female.data)
I am trying to fit above model to length-weight data of a fish species
(spotted seatrout) by year (1999-2006). The convergence occurred for all
the years except 2002 and 2004. In these two year, R shows the error
called 'singular gradient' in the model. Could anyone please help me to
fix the error? I don't think there are any problems with my data because I
can fit the same model to 2004 data without any problems using SAS. Thank
you very much in advance.
Hongsheng (Hank) Liao, Ph.D.
Lab Manager
Center for Quantitative Fisheries Ecology
800 West 46th Street
Old Dominion University
Norfolk, Virginia 23508
Phone:757.683.4571
Fax:757.683.5293
Ravi Varadhan
2008-Feb-15 17:48 UTC
[R] Error 'singular gradient' in nonlinear model fitting
Try a different set of starting values for alpha & beta.
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 r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of HongSheng Liao
Sent: Friday, February 15, 2008 12:42 PM
To: r-help at r-project.org
Subject: [R] Error 'singular gradient' in nonlinear model fitting
w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
start=list(alpha=1, beta=3),
data=spottedseatrout2004.female.data)
I am trying to fit above model to length-weight data of a fish species
(spotted seatrout) by year (1999-2006). The convergence occurred for all
the years except 2002 and 2004. In these two year, R shows the error
called 'singular gradient' in the model. Could anyone please help me to
fix the error? I don't think there are any problems with my data because I
can fit the same model to 2004 data without any problems using SAS. Thank
you very much in advance.
Hongsheng (Hank) Liao, Ph.D.
Lab Manager
Center for Quantitative Fisheries Ecology
800 West 46th Street
Old Dominion University
Norfolk, Virginia 23508
Phone:757.683.4571
Fax:757.683.5293
______________________________________________
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.
Peter Dalgaard
2008-Feb-15 17:49 UTC
[R] Error 'singular gradient' in nonlinear model fitting
HongSheng Liao wrote:> w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454, > start=list(alpha=1, beta=3), > data=spottedseatrout2004.female.data) > > I am trying to fit above model to length-weight data of a fish species > (spotted seatrout) by year (1999-2006). The convergence occurred for all > the years except 2002 and 2004. In these two year, R shows the error > called 'singular gradient' in the model. Could anyone please help me to > fix the error? I don't think there are any problems with my data because I > can fit the same model to 2004 data without any problems using SAS. Thank > you very much in advance. >If your starting values are poor, it can be a toss-up whether nls() converges or not. One idea is to try the PORT algorithm, another is to get better starting values from cf <- coef(lm(log(WEIGHT*454)~log(TOTAL))) start = list(alpha=exp(cf[1]), beta=cf[2])> Hongsheng (Hank) Liao, Ph.D. > Lab Manager > Center for Quantitative Fisheries Ecology > 800 West 46th Street > Old Dominion University > Norfolk, Virginia 23508 > Phone:757.683.4571 > Fax:757.683.5293 > > ______________________________________________ > 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. >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Gabor Grothendieck
2008-Feb-15 17:50 UTC
[R] Error 'singular gradient' in nonlinear model fitting
Try fitting regressing log(WEIGHT) against log(TOTAL) using lm and then transform the results into starting values for nls (or possibly that is sufficient and you don't need the nls results). On Fri, Feb 15, 2008 at 12:41 PM, HongSheng Liao <HLiao at odu.edu> wrote:> > w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454, > start=list(alpha=1, beta=3), > data=spottedseatrout2004.female.data) > > I am trying to fit above model to length-weight data of a fish species > (spotted seatrout) by year (1999-2006). The convergence occurred for all > the years except 2002 and 2004. In these two year, R shows the error > called 'singular gradient' in the model. Could anyone please help me to > fix the error? I don't think there are any problems with my data because I > can fit the same model to 2004 data without any problems using SAS. Thank > you very much in advance. > > Hongsheng (Hank) Liao, Ph.D. > Lab Manager > Center for Quantitative Fisheries Ecology > 800 West 46th Street > Old Dominion University > Norfolk, Virginia 23508 > Phone:757.683.4571 > Fax:757.683.5293 > > ______________________________________________ > 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. >