Hello all, I am having a problem with nls. I have such data as shown below, foo<- Dose var 0 0.000000 100 -1.318178 200 -1.562425 400 -3.579960 1200 -3.788662 however, when I call nls as shown below,>foo.nls<-nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)),+ start=list(Emax=-4,EC50=269,hill=1),trace=T,data=foo) i get the response below. 1.759088 : -4 269 1 Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model if i remove the hill variable, it works. can someone help me out with what I am coding wrong. Thanks, Lanre
Hi! I would suggest trying out a few different starting values as a first unsystematic approach. For example changing hill=1 to hill=2 results in convergence: foo.nls<-nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)), start=list(Emax=-4,EC50=269,hill=2),trace=T,data=foo) Christian
Thanks. I am just not used to having such a huge difference when changing the initial condition by 1 point. it usually tends to be an issue when you are way off (especially since the hill converged at 1.69). Does it have something to do with the algorithm or is the hill just very finicky? Lanre On 10/16/07, Christian Ritz <ritz at life.ku.dk> wrote:> Hi! > > I would suggest trying out a few different starting values as a first unsystematic approach. > > For example changing hill=1 to hill=2 results in convergence: > > foo.nls<-nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)), > start=list(Emax=-4,EC50=269,hill=2),trace=T,data=foo) > > > > Christian > >
Another approach that usually works well is to use the option: algorithm "port". This uses the "nl2sol" routine. foo.nls <- nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)), start=list(Emax=-4,EC50=269,hill=1), algorithm="port", trace=T,data=foo) This generally has more robust convergence than the default "Gauss-Newton" with a Marquardt-type modification. 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 Christian Ritz Sent: Tuesday, October 16, 2007 10:01 AM To: Lanre Okusanya Cc: r-help at stat.math.ethz.ch Subject: Re: [R] help with nls and Hill equation Hi! I would suggest trying out a few different starting values as a first unsystematic approach. For example changing hill=1 to hill=2 results in convergence: foo.nls<-nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)), start=list(Emax=-4,EC50=269,hill=2),trace=T,data=foo) Christian ______________________________________________ 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.
On Tue, Oct 16, 2007 at 10:29:17AM -0400, Lanre Okusanya wrote:> Thanks. > I am just not used to having such a huge difference when changing the > initial condition by 1 point. it usually tends to be an issue when you > are way off (especially since the hill converged at 1.69). Does it > have something to do with the algorithm or is the hill just very > finicky?Convergence of general nonlinear optimization problems is often finicky, being wrong by a large amount in the right direction can produce convergence, while a small amount in the wrong direction causes divergence... These things almost always benefit from trying various starting points, and from doing some analysis to determine a good range of starting points. -- Daniel Lakeland dlakelan at street-artists.org http://www.street-artists.org/~dlakelan
I think its your parameterization that is problematic. ED50^hill is tough for it to work with since both are varying. Try reparameterizing using ED50hill = ED50^hill as a parameter so that the parameters become Emax, ED50hill and hill. You can back transform afterwards. On 10/16/07, Lanre Okusanya <lanre.okusanya at gmail.com> wrote:> Hello all, I am having a problem with nls. I have such data as shown below, > foo<- > Dose var > 0 0.000000 > 100 -1.318178 > 200 -1.562425 > 400 -3.579960 > 1200 -3.788662 > > however, when I call nls as shown below, > > >foo.nls<-nls(var~Emax*(Dose^hill)/((EC50^hill)+(Dose^hill)), > + start=list(Emax=-4,EC50=269,hill=1),trace=T,data=foo) > > i get the response below. > > 1.759088 : -4 269 1 > Error in numericDeriv(form[[3]], names(ind), env) : > Missing value or an infinity produced when evaluating the model > > > if i remove the hill variable, it works. can someone help me out with > what I am coding wrong. > > Thanks, > > > > Lanre > > ______________________________________________ > 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. >