Hi,

In my package CatDyn, which uses optimx, I included the gradients of 20 version of the model involved.
I estimate model parameters with numerical gradients, and at the final estimates I calculate the analytical gradients.
In the simplest version of the model the analytical gradients computed post hoc are almost identical to the numerical gradients. This shows that the analytical gradients (whose formulas were obtained by the CAS Maxima) are correct, at least for those simple versions of my model. However, if I try to pass the analytical gradients to optimx in a new optimization, I invariably get the error message that you got: "Gradient function might be wrong - check it!"
This happens regardless of the method used (BFGS, spg, Rcgmin).
Same as you, when I try to pass the gradients to optim, instead of optimx, the gradients are accepted and computed correctly, but then I cann't use the very nice other features of optimx.
I wanted to report this to Ravi and Prof. Nash but I haven't got the time for a full report with several examples and variations.
So now that you report it, here I am, seconding you in calling the attention to this apparent problem in optimx.

Rubén H. Roa-Ureta, Ph. D.
AZTI Tecnalia, Txatxarramendi Ugartea z/g,
Sukarrieta, Bizkaia, SPAIN

-----Original Message-----
From: r-help-bounces@r-project.org on behalf of Kathie
Sent: Mon 8/29/2011 11:10 AM
To: r-help@r-project.org
Subject: [R] gradient function in OPTIMX
 
Dear R users

When I use OPTIM with BFGS, I've got a significant result without an error
message.  However, when I use OPTIMX with BFGS( or spg), I've got the
following an error message.

----------------------------------------------------------------------------------------------------

>  optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS",
> control=list(maxit=10000))

Error: Gradient function might be wrong - check it! 

----------------------------------------------------------------------------------------------------

I checked and checked my gradient function line by line. I could not find
anything wrong.

Is it a bug or something?  I prefer OPTIMX, so I'd like to know why.

Thanks a lot in advance

Regards,

Kathryn Lord 

--
View this message in context: http://r.789695.n4.nabble.com/gradient-function-in-OPTIMX-tp3775791p3775791.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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]]

