Dear R users, I'm using optim to optimize a pretty complicated function. This function takes the parameter vector "theta" and within its body I use instructions like
sigma<-theta[a:b]; computations with sigma... out<-c() for (i in 1:d){ a<-theta[(3*d+i):c] out[i]<-evaluation of an expression involving 'a' (I use symbolic differentiation) } Unfortunately for certain problems 'optim' returns a parameter vector which didn't move at all from the initial parameters, and the output says that although the function has been evaluated a high number of times, the gradient (which I fed the function with) has been evaluated only one time. I used the BFGS method. By chance I looked at the help and I read "The parameter vector passed to fn has special semantics and may be shared between calls: the function should not change or copy it" . Could the instructions above be the cause of the failure? If so, how to deal with symbolic differentation? Thanks in advance, Gildas [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.