- That your objective function always returns finite real values at feasible points,
- That lsqnonlin avoids iterating over non-feasible points where the objective function is not finite-valued.
Calibration lsqnonlin NaN Infinity Error messages
5 views (last 30 days)
Show older comments
Hi there,
I am trying to implement a calibration using lsqnonlin.
Specifically, I am using the Heston model in order to obtain the cumulative distribution function by inversion of the Fourier Transform. Then, I am trying to minimise the difference in the sum of the squared errors between the probabilities obtained by inversion of the Fourier transform and the ones estimated from the market (from CDS spreads mid-quotes).
Hence, my objective is to estimate the parameters involved in the inversion of the c.f. using lsqnonlin, such that the probabilities coming from my model, and the market are almost matched.
The problem with this procedure is that, apart from being extremely sensitive to the initial set of parameters, I obtain a lot of NaN or Infinity warning messages while running the optimisation.
Is there anybody who has ever faced a similar problem? How about heuristic methods? (I was thinking about Simulated Annealing)
Moreover, I suspect that problem is with the integrand function, which itself contains a logarithm with complex argument.
Thanks in advance, V.
0 Comments
Answers (1)
Matt J
on 16 Aug 2013
Edited: Matt J
on 16 Aug 2013
I suspect that problem is with the integrand function, which itself contains a logarithm with complex argument.
Sounds like you've answered your own question. You must make sure
For (2), setting appropriate ub,lb bounds may help. If that's not enough, FMINCON's sqp algorithm has the ability to recover from NaNs and Infs, so you might consider switching to that.
2 Comments
Matt J
on 18 Aug 2013
Valerio Commented
Matt j, thanks for you answer.
I found a paper with a slightly different characteristic function which seems to get around the problem of the logarithm with complex argument, i.e. of the branch curve. With the current set of initial parameters no warning message appears, but if I try to make the set of initial parameters random, it is most likely I get an error/warning message. Specifically I get: "Objective function is returning undefined values at initial point. lsqnonlin cannot continue."
Anyway, I tried Fmincon, but it needs the obj function to be a scalar, and in my case, having 5 parameters that I am calibrating at the same time, it is a vector then. Therefore, fmincon does not work in this case...
Matt J
on 18 Aug 2013
Edited: Matt J
on 19 Aug 2013
but if I try to make the set of initial parameters random,
No, you shouldn't be choosing the initial parameters randomly. You're supposed to be making a systematic initial guess, not a random one. The initial parameter guess is meant to be as accurate a guess as you can devise of the final solution. That way you reduce iteration time and improve your chances of avoiding local minima. Obviously also, you should be making an initial guess that is legitimately in the domain of your objective function, i.e., where it has a finite and well-defined value.
but it needs the obj function to be a scalar, and in my case, having 5 parameters that I am calibrating at the same time, it is a vector then.
The objective function in LSQNONLIN isn't really a vector. The vector elements get squared and summed, and that's the thing being minimized by lsqnonlin. (That's what the "LSQ" means.) You could do the same square summation manually in fmincon.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!