[R] a question on R optimization functions
Ben Bolker
bbolker at gmail.com
Fri Mar 25 13:08:45 CET 2011
Dajiang J. Liu <dajiang.liu <at> gmail.com> writes:
> I use nlminb or optim for maximizing likelihood functions. Sometimes,
> the parameter values happen to be NA, then the program will hang there
> and iterate forever without stopping. No error message will be
> produced. So I can not use error catch method such as "try". Are there
> any suggestions how I can circumvent this problem? Maybe I can time a
> function, and if the time exceeds a threshold, it will be stopped. I
> am not sure if this is feasible in R. As a note, I am running
> simulations with thousands of replicates, so there needs to be a
> systematic way of doing this. Are there any suggestions on how to do
> this? Thank you very much!
It would be very surprising (I suppose not impossible, but
*very* surprising) if this behavior were generated by R's optimization
functions; it would be much more likely for it to be an infinite
loop/hang somewhere inside your objective function.
See ?setTimeLimit (which will fail if the problem is inside
C code that you have written ...)
Ben Bolker
More information about the R-help
mailing list