I have a ML I want to maximize in R's function optim. I am currently using the method BFGS. The optim procedure is quite slow however, and I was hoping to speed up the process by specifying the gradient function by the grad-option. Doing this, I suddenly became very confused.
I am optimizing the log-likelihood $l(x;\theta)$ for the parameters $\theta$. So is the gradient the derivative of x, $\frac{\partial l}{\partial x}$ or of the parameters $\theta$, $(\frac{\partial l}{\partial \theta_1},\dots,\frac{\partial l}{\partial \theta_k})$? The latter certainly makes more sense..