I'm using optim/nlm to do a maximum likelihood estimation, and my parameters are in a multidimensional array.
The likelihood evaluates fine, i.e. given a data x, and multidimensional array of parameters theta, likelihood(theta,x) gives a real number.
However, using optim/nlm, with a starting value that has the same dimension as the theta had evaluated just fine, I'm getting the following error:
Error in theta[1, 1, 1] : incorrect number of dimensions
when evaluation the likelihood. It turns out that optim/nlm flattens my multidimensional array to a 1D array. Is there anyway I can use optim/nlm with a multidimensional array of parameters?
drop=FALSE
parameter for[
cannot be applied globally. – IRTFM