Hello No worries anymore. Figured it out. Thanks for everything. Luz ---------- Forwarded message ---------- Date: Sun, 18 Jun 2006 23:12:25 -0600 (MDT) From: Luz Maria Palacios Derflingher <palacios at math.ucalgary.ca> To: r-help at lists.R-project.org Cc: r-help at stat.math.ethz.ch. Subject: help on nlm (gradient) Hello. I am having some trouble using nlm in R for windows version 2.2.1. I have to minimise a function which includes in its insides the evaluation of integrals through the "adapt" function. In order to make R work less, I calculated the gradient and coded it. I made sure that the code and function for the gradient worked. So I know that the main function (the one to minimise,let's call it "func1") yields values when evaluated. I know that the gradient I coded also works and yields values when evaluated (on its own); when I put it all together and use nlm I get the following message: Error in nlm(func1, starting values, : probable coding error in analytic gradient Any light that can be shed on this would be highly appreciated. Many thanks Luz Palacios PhD Candidate University of Calgary