A couple more suggestions:
Mark Bravington's "debug" package (mvbdebug, available on CRAN) can be a more powerful debugging tool if you want to do a more graphical stepping-through your code; a cruder but effective technique is to put a cat() statement into your objective function, e.g. objfun <- function(params,...) { ## calculate neg log likelihood neg.log.likel <- ... cat(params[1],params[2],neg.log.likel,"\n") neg.log.likel } that way you can see where the function is getting in trouble. Kingsford Jones wrote:
Hi Jeremy, Since R is open source, the code is usually the best reference when you can't decipher an error message. Often the easiest way to see what is going on is to type traceback() after receiving the error message -- this will show you the calls that led to the error. Another very useful tool is to type debug(name.of.function.to.be.debugged) prior to calling the function of interest. The next time you use that function, debug will take you step-by-step through the function calls while allowing full interactive ability so you can, e.g. look at the structure of objects as they are created within the function (using, e.g., the str function). Another option is to open the function's source file in a text window and use Find in your text editor to find the error. Finally, searching for the error message in the help archives can often be fruitful. That technique just led me to this: https://stat.ethz.ch/pipermail/r-help/2006-January/086747.html which indicates what the '[2]' is referring to. Kingsford Jones On Wed, May 7, 2008 at 12:30 PM, Jeremy Claisse <[EMAIL PROTECTED]> wrote:I'm trying to figure out how to overcome this error message: Error in optim(c(5, -0.5), llfunc.prop.female.age, method = "BFGS") : non-finite finite-difference value [2] And particularly would like to know what the "[2]" is pointing towards, I'm assuming that will help me search out the problem. Is there any documentation available that explains the particulars of error messages? Thanks, Jeremy Jeremy Claisse Hawaii Cooperative Fishery Research Unit University of Hawaii <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology_______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
signature.asc
Description: OpenPGP digital signature
_______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology