the original data are V2 =c(371000,285000 ,156000, 20600, 4420, 3870, 5500 ) T2=c( 0.3403 ,0.4181 ,0.4986 ,0.7451 ,1.0069 ,1.553) nls2=nls(V2~v0*(1-epi+epi*exp(-cl*(T2-t0))),start=list(v0=10^7,epi=0.9,cl=6.2,t0=8.7)) after execution error occurs as below ################################################################ Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates In addition: Warning messages: 1: In lhs - rhs : longer object length is not a multiple of shorter object length 2: In .swts * attr(rhs, "gradient") : longer object length is not a multiple of shorter object length could anyone help me ?thansks -- View this message in context: http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3494454.html Sent from the R help mailing list archive at Nabble.com.
The fact that T2 and V2 are of different lengths seems like a likely culprit. Other than that, you need to find start points that do not lead to a singular gradient. There are several books that provide advice on obtaining initial parameter estimates for non-linear models. Google Books might help you. Cheers Andrew On Tue, May 03, 2011 at 09:08:03PM -0700, sterlesser wrote:> the original data are > V2 =c(371000,285000 ,156000, 20600, 4420, 3870, 5500 ) > T2=c( 0.3403 ,0.4181 ,0.4986 ,0.7451 ,1.0069 ,1.553) > nls2=nls(V2~v0*(1-epi+epi*exp(-cl*(T2-t0))),start=list(v0=10^7,epi=0.9,cl=6.2,t0=8.7)) > after execution error occurs as below > ################################################################ > Error in nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates > Error in nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates > In addition: Warning messages: > 1: In lhs - rhs : > longer object length is not a multiple of shorter object length > 2: In .swts * attr(rhs, "gradient") : > longer object length is not a multiple of shorter object length > > could anyone help me ?thansks > > -- > View this message in context: http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3494454.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.-- Andrew Robinson Program Manager, ACERA Department of Mathematics and Statistics Tel: +61-3-8344-6410 University of Melbourne, VIC 3010 Australia (prefer email) http://www.ms.unimelb.edu.au/~andrewpr Fax: +61-3-8344-4599 http://www.acera.unimelb.edu.au/ Forest Analytics with R (Springer, 2011) http://www.ms.unimelb.edu.au/FAwR/ Introduction to Scientific Programming and Simulation using R (CRC, 2009): http://www.ms.unimelb.edu.au/spuRs/
Thanks Andrew. I am sorry for some typos that I omit some numbers of T2. Based on your suggestion,I think the problem is in the initial values. And I will read more theory about the non-linear regression. -- View this message in context: http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495672.html Sent from the R help mailing list archive at Nabble.com.
In addition to the suggestion about finding a good initial value, you should also scale your response V2 (and, of course, V0). Divide V2 by 10^4, for example. Now your V0 should also be scaled by this factor. This would likely help with convergence. Ravi. ------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of sterlesser Sent: Wednesday, May 04, 2011 10:08 AM To: r-help at r-project.org Subject: Re: [R] nls problem with R Thanks Andrew. I am sorry for some typos that I omit some numbers of T2. Based on your suggestion,I think the problem is in the initial values. And I will read more theory about the non-linear regression. -- View this message in context: http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495672.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.