Steven, You haven't given us much information to help you. Are you `maximizing' the log-likelihood or are you `minimizing' the negative log-likelihood? If it is the former, you have to specify the control argument, control$fnscale = -1. This is a common mistake when using optim for likelihood estimation.
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: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml ---------------------------------------------------------------------------- -------- -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Prof. John C Nash Sent: Monday, December 07, 2009 9:01 AM To: r-help@r-project.org Subject: Re: [R] optim with constraints Without the data / script, I'm guessing that it is likely an attempt to evaluate the loss function at an inadmissible point e.g., at the constraint where there is a log(0). Different optimization tools handle things differently, and there are a couple of us working (very slowly due to other things) on trying to provide a nice wrapper to catch these exceptions so that they can be handled better. JN > Message: 56 > Date: Sun, 6 Dec 2009 17:32:54 -0800 (PST) > From: Steven <ytste...@gmail.com> > Subject: Re: [R] optim with constraints > To: r-help@r-project.org > Message-ID: > <88d5c01d-c30c-4e91-900c-2b825d5e3...@z4g2000prh.googlegroups.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi, Prof Nash > > Thanks for your comment! > > I modified my code to be (added an extra parametr): > > optim(c(1.14,0.25,0.06), weibull.like, mydata=mydata, method="L-BFGS- > B", hessian = TRUE, lower = c(0, 0, 0), upper = c(Inf, Inf, 1)) > > But I had the following error: > > Error in optim(c(1.14, 0.25, 0.06), weibull.like, mydata = mydata, > method = "L-BFGS-B", : > non-finite finite-difference value [2] > > What does that mean? Much appreciate your help! > > Steven > ______________________________________________ R-help@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@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.