Hello
I have a problem when calibrating a function because i receive error messages:
nloptr_: Error in is.nloptr(ret) : objective in x0 returns NA
optim_: L-BFGS-B requires finite values of 'fn'
nlm_: it seems to ignore NA but can't impose constraints on parameters (please, let me know if it is possible and how)
etc.
If works for some range of observations but fails for others (strange). I tried several starting values but still the same.
My question is simple: how to ask to ignore error messages and yield back the parameters values?
Thanks a lot
If by "parameters values" you mean an optimal (or near optimal) solution, I don't think you'll get one by ignoring the messages. NA values in the objective function mean the objective is somehow undefined. You need to fix that.
The nlm
package is designed for unconstrained optimization. If you need to impose linear constraints, you might look at constrOptim
. If you need to impose nonlinear constraints, you will need to try other packages, or else implement a barrier or penalty approach on your own.
Hello
Thank you.
=> sure but i don't understand how except that i fixed bound that restrict the region of each parameters and maybe this induce undefined objective function?
Your idea is very good indedd with "constrOptim" but i dont know how to fix the feasible region with ui and ci. I would like to know how to fix ui <- matrix(c( 0, 1, 0, 0, 1), ncol = ..) and ci <- c(0, 1, -1, 0) if you help me please. Thanks again.
Putting bounds on the feasible region can make the problem infeasible, but it cannot make the objective function undefined. Letting the objective function do something like dividing by 0 can result in a result of Inf, but I would not expect the optimizer to come up with NA. I would look closely at the code used to calculate the objective to see if there is any way a valid input could result in it returning NA.
If your ci contains four values, presumably you have four linear inequality constraints defining your feasible region. In that case, your ui parameter should be a 4 x n matrix where n is the number of variables.