I am having the same problem as one Rebecca Sela(see bellow). On 21/12/2007 12:07 AM, Rebecca Sela wrote:>* I am trying to optimize a likelihood function using NLMINB. After running without a problem for quite a few iterations (enough that my intermediate output extends further than I can scroll back), it tries a vector of parameter values NaN. This has happened with multiple Monte Carlo datasets, and a few different (but very similar) likelihood functions. (They are complicated, but I can send them to someone if desired.)*Instead I try to use optim() for my optimization needs but it fails when finding the 0/0: " Error in optim(c(phi[, k]), maxphi, lower = 0.01, upper = 0.99, method = "L-BFGS-B") : L-BFGS-B needs finite values of 'fn' In addition: There were 50 or more warnings (use warnings() to see the first 50) " Any suggestions? Harlan Campbell McGIll University [[alternative HTML version deleted]]
Hi, Can you provide a little more information about your problem? If you are trying to find a local maximum of "maxphi", then you need to tell that to optim(),. It tries to find a local minimum by default. You can do this via the `fnscale' control parameter (control = list(fnscale = -1)). If this still does not work, try the function spg() in the "BB" package. 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 H c Sent: Wednesday, May 06, 2009 2:19 PM To: r-sig-mixed-models at r-project.org; r-help at r-project.org Subject: [R] NLMINB() produces NaN! I am having the same problem as one Rebecca Sela(see bellow). On 21/12/2007 12:07 AM, Rebecca Sela wrote:>* I am trying to optimize a likelihood function using NLMINB. After >running without a problem for quite a few iterations (enough that my >intermediate output extends further than I can scroll back), it tries a >vector of parameter values NaN. This has happened with multiple Monte >Carlo datasets, and a few different (but very similar) likelihood >functions. (They are complicated, but I can send them to someone if >desired.)*Instead I try to use optim() for my optimization needs but it fails when finding the 0/0: " Error in optim(c(phi[, k]), maxphi, lower = 0.01, upper = 0.99, method "L-BFGS-B") : L-BFGS-B needs finite values of 'fn' In addition: There were 50 or more warnings (use warnings() to see the first 50) " Any suggestions? Harlan Campbell McGIll University [[alternative HTML version deleted]] ______________________________________________ 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.
I have trimmed the address to the mixed models list since you (and I ) are asked in the Posting Guide to pick one of the lists rather than cross posting. Have you looked at the possibility of using the try function around your individual optim calls? ?try -- David Winsemius ----- Original Message ----- From: "H c" <harlancampbell@gmail.com> To: r-sig-mixed-models@r-project.org, r-help@r-project.org Sent: Wednesday, May 6, 2009 1:19:00 PM GMT -06:00 US/Canada Central Subject: [R] NLMINB() produces NaN! I am having the same problem as one Rebecca Sela(see bellow). On 21/12/2007 12:07 AM, Rebecca Sela wrote:>* I am trying to optimize a likelihood function using NLMINB. After running without a problem for quite a few iterations (enough that my intermediate output extends further than I can scroll back), it tries a vector of parameter values NaN. This has happened with multiple Monte Carlo datasets, and a few different (but very similar) likelihood functions. (They are complicated, but I can send them to someone if desired.)*Instead I try to use optim() for my optimization needs but it fails when finding the 0/0: " Error in optim(c(phi[, k]), maxphi, lower = 0.01, upper = 0.99, method = "L-BFGS-B") : L-BFGS-B needs finite values of 'fn' In addition: There were 50 or more warnings (use warnings() to see the first 50) " Any suggestions? Harlan Campbell McGIll University [[alternative HTML version deleted]] ______________________________________________ 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. [[alternative HTML version deleted]]