where logLik is the likelihood function and returns a vector of observation
level likelihoods and nuGradient is a function that returns a matrix with
each row corresponding to a single observation and the columns corresponding
to the gradient values for each parameter (as is mentioned in the online
help).

however, this gives me the following error:

*Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
:
the matrix returned by the gradient function (argument 'grad') must have
at least as many rows as the number of parameters (10), where each row must
correspond to the gradients of the log-likelihood function of an individual
(independent) observation:
currently, there are (is) 10 parameter(s) but the gradient matrix has only
2 row(s)
*

It seems it is expecting as many rows as there are parameters. So, I changed
my likelihood function so that it would return the transpose of the earlier
matrix (hence returning a matrix with rows equaling parameters and columns,
observations).

I have verified that my gradient function, when summed across observations
gives the same results as the in built numerical gradient (to the 11th
decimal place - after that, they differ since R's function is numerical).

I am trying to run a very large estimation (1000's of observations and 821
parameters) and all of the other methods are taking way too much time
(days). This method is our last hope and so, any help will be greatly
appreciated.