I have found that optimisers (R’s optim to be precise) are sometime unstable. Not in a numerical sense, but in a more practical sense, i.e. choking on certain inputs (I wasn’t able to figure out when exactly) and in the end crashing, without the possibility of recovery or error-processing. Which is quite bad, when you’re in the mid of some long calculations, e.g. a Monte-Carlo experiment. I found that optim’s standard method, Nelder-Mead, was unsusceptible to such crashes (Please, geeks, explain me why!). But with Nelder-Mead, you cannot use parameter constraints, so you have to formulate your optimisation problem in an unconstrained way. Here are some of my tricks.