Dear R experts,
I have been encountering problems with the optim routine using for
loops. I am determining the optimal parameters of several nested models by
minimizing the negative Log-Likelihood (NLL) of a dataset.
The aim is to find the model which best describes the data. To this end,
Without more detail - a reproducible example - it is hard to give you
concrete advice.
I wonder if the functions NLL23 and NLL21 depend on numerical solutions
of a system of ODEs, since you invoke the odesolve package? If so, try
switching to the Nelder-Mead optimizer, enforcing the parameter
Two possibilities for why your 7 parameter model fits worse than the 6
are that you are finding a local maximum, which might suggest using a
different parameterisation or the functions are accessing some global
data and so aren't behaving as expected. This could be why they work
properly when run