Skip to content
Prev 270241 / 398502 Next

Gradient function in OPTIMX

Hi Kathie,

The gradient check in "optimx" checks if the user specified gradient (at starting parameters) is within roughly 1.e-05 * (1 + fval) of the numerically computed gradient. It is likely that you have correctly coded up the gradient, but still there can be significant differences b/w numerical and exact gradients.  This can happen when the gradients are very large.  

I would check this again separately as follows:

require(numDeriv)

mygrad <-  gr.fy(theta0)

numgrad <- grad(x=theta0, func=gr.fy)

cbind(mygrad, numgrad)

all.equal(mygrad, numgrad)

Can you report these gradients to us?

In "optimx", we should probably change this into a "warning" rather than a "stop". 

Ravi.

-------------------------------------------------------
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu
Message-ID: <2F9EA67EF9AE1C48A147CB41BE2E15C305C79A@DOM-EB-MAIL2.win.ad.jhu.edu>
In-Reply-To: <mailman.27.1314698411.11207.r-help@r-project.org>