the function leasqr (part of the optim package) is used to fit non-linear data. In my case, some values for the parameters (there's 3 of them) make no physical sense so I made a condition inside the function so it returns before evaluating such values.
However, when leasqr attempts to fit such values, it returns an error (at least that's my understanding of the origin of the error, when I looked into the source) which makes sense because he tries to subtract two values, one with zero size. Here's the error
error: operator -: nonconformant arguments (op1 is 1x26, op2 is 0x0) error: called from: error: /usr/share/octave/packages/3.2/optim-1.0.10/leasqr.m at line 320, column 3
If I got it right, op1 = y (argument of leasqrand) and op2 = f (return of feval with function F).
I guess it makes sense for the code to check this but in that case how can I check for this and make sure that leasqr doesn't give me certain values? Or should this be considered a bug? I though about making a while loop with a try statement inside to catch any errors and change the initial guess of the parameters values until leasqr doesn't try one that makes no sense on its iterations. But I fear that sometimes this will create an infinite loop.