# Are analytical derivatives unambiguously superior to numerical derivatives in GMM?

I am estimating a non-linear GMM model. In both Stata and R, you need to specify the moment equations and the instruments, but there is no need need to provide analytical derivatives for the estimator to work, in which case these are computed numerically.

For instance, the Stata documentation (page 24) says:

By default, gmm calculates derivatives numerically, and the method used produces accurate results for the vast majority of applications. However, if you refit the same model repeatedly or else have the derivatives available, then gmm will run more quickly if you supply it with analytic derivatives.

Furthermore, regarding numerical calculation of derivatives, page 58 says:

This procedure results in accurate derivatives but can be slow if your model has many instruments or parameters.

The terminology in the documentation of the R package gmm has a stronger suggestion (regarding the specification of element gradv, the analytical derivatives):

[gradv] A function of the form $G(\theta, x)$ which returns a $q\times k$ matrix of derivatives of $\bar{g}(\theta)$ with respect to $\theta$. By default, the numerical algorithm numericDeriv is used. It is of course strongly suggested to provide this function when it is possible. This gradiant is used compute the asymptotic covariance matrix of $\hat \theta$. If "g" is a formula, the gradiant is not required (see the details below).

My intuition is that analytical derivatives are always better, because they are exact, reducing "searching" around, and thus time. But are they unambiguously better? The Stata documentation does not suggest so, whereas the R documentation seems to imply it.

• It's hard to ever declare something "unambiguously better", but I think you get as close as possible to that in your own question when you say that "analytical derivatives are always better, because they are exact, reducing "searching" around, and thus time". Greater precision in less time seems pretty hard to beat! What other criteria might there be that would contradict that? – hamedbh Jul 17 '18 at 9:00