Hi there,
Now I'd like to modify slightly this code, in order to keep a given alfa and to find the best sigma. Clearly, this is a much simpler problem since I have a single parameter to calibrate. Unfortunately, I am not an expert user of the library and I'd need some hints in order to reach the goal in a "decent" way... The code I am currently using is more or less the following: CalibrationSet calibrationInstruments; ............. Handle<Model> modelHW(new HullWhite(rhTermStructure));
The modified code should work with a model defined as double givenAlfa;
Thanks for the help Francesco Perissin
This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. Banca del Gottardo (including its group companies) shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt or damage to your system. Banca del Gottardo (or its group companies) does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference. ############################################################################ |
At 03:16 PM 9/16/03, Perissin Francesco wrote:
>I am calibrating my Hull-White model in QL 0.3.1 using more or less the >same code given in bermudan swaption example. This means considering a set >of calibration helpers, and finding the parameters alfa and sigma that >minimize the error function, via the simplex optimization method. > >Now I'd like to modify slightly this code, in order to keep a given alfa >and to find the best sigma. Clearly, this is a much simpler problem since >I have a single parameter to calibrate. Unfortunately, I am not an expert >user of the library and I'd need some hints in order to reach the goal in >a "decent" way... Hi Francesco, long time no see. Upon a superficial inspection of the code, it seems to me that Sad didn't leave a hook for doing what you need. Were I to tackle it, I would do something like: 1) create a new class: class FixedAlphaHullWhite : public HullWhite { ... }; 2) inside the new class, define an inner class: class FixedAlphaConstraint : public Constraint { ... }; equal to Model::PrivateConstraint, but whose method test() works as: if (params[0] != fixedAlpha_) return false; else { ... // same as PrivateConstraint } and whose constructor accepts and store the fixed alpha value besides the other parameters; 3) define the constructor of the FixedAlphaHullWhite class as: FixedAlphaHullWhite(const RelinkableHandle<TermStructure>& ts, double a, double sigma = 0.01) : HullWhite(ts,a,sigma) { constraint_ = Handle<Constraint>( new FixedAlphaConstraint(a, arguments_)); } 4) cross your fingers, compile and hope for the best as the above is highly untested. 5) add a feature request to the QuantLib tracker (https://sourceforge.net/tracker/?group_id=12740&atid=362740) called "Adding custom constraints to short-rate model calibration" or something of the kind. Describe the problem shortly. Hope this helps, Luigi |
In reply to this post by Perissin Francesco
Hi Luigi, Sad, everybody. Following the precious suggestions given by Luigi, I added the attached module to my QuantLib project. Unfortunately, the calibration does not work as expected. This is visible after running the following test: 1) calibrate the standard Hull-White model with a termstructure and a set of calibration helpers. Use Simplex optimization algorithm as in BermudanSwaption example. 2) store the resulting parameters, alpha and sigma
After the 2nd calibration, you wil get the stored alpha, as expected, but the sigma is quite different from the one calibrated previously. I have big trouble in debugging the code. Maybe that somebody who knows better than me the architecture and the mathematics of this part of QuantLib can help me? Thanks
-----Original Message-----
At 03:16 PM 9/16/03, Perissin Francesco wrote:
Hi Francesco,
1) create a new class: class FixedAlphaHullWhite : public HullWhite { ... }; 2) inside the new class, define an inner class: class FixedAlphaConstraint : public Constraint { ... }; equal to Model::PrivateConstraint, but whose method test() works as: if (params[0] != fixedAlpha_)
and whose constructor accepts and store the fixed alpha value besides the
3) define the constructor of the FixedAlphaHullWhite class as: FixedAlphaHullWhite(const RelinkableHandle<TermStructure>& ts,
4) cross your fingers, compile and hope for the best as the above is highly
5) add a feature request to the QuantLib tracker
Hope this helps,
############################### DISCLAIMER ################################# fixedalphahullwhite.hpp (1K) Download Attachment |
In reply to this post by Perissin Francesco
Hi all, after some debuggin I finally solved my problem in calibrating Hull & White model with one free parameter. THe characteristic length lambda, given to the constructor of Simplex, was too high, i.e. 0.25. Setting it to 0.05 resolves the problem. Due to unknown (to me) gemoetrical reasons, the "amoeba" present in the Simplex was adapting itself in the correct way in the 2dim problem even with that big length, but was not able to do the same in 1dim .... Please note that the BermudanSwaption example is using the high value 0.25, therefore I would suggest to replace it with a lower value, maybe 0.05 itself. If everybody agrees, I will file my patch on Sourceforge, otherwise please let me know ciao
This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. Banca del Gottardo (including its group companies) shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt or damage to your system. Banca del Gottardo (or its group companies) does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference. ############################################################################ |
In reply to this post by Perissin Francesco
At 09:05 AM 9/24/2003 +0200, you wrote:
>after some debuggin I finally solved my problem in calibrating Hull & >White model with one free parameter. THe characteristic length lambda, >given to the constructor of Simplex, was too high, i.e. 0.25. Setting it >to 0.05 resolves the problem. [...] >Please note that the BermudanSwaption example is using the high value >0.25, therefore I would suggest to replace it with a lower value, maybe >0.05 itself. > >If everybody agrees, I will file my patch on Sourceforge, otherwise please >let me know ciao -- Nando |
In reply to this post by Perissin Francesco
At 09:05 AM 9/24/03, Perissin Francesco wrote:
>Please note that the BermudanSwaption example is using the high value >0.25, therefore I would suggest to replace it with a lower value, maybe >0.05 itself. Francesco, did you try and see what happens if you do? Just curious, Luigi |
In reply to this post by Perissin Francesco
Yes,
On the other hand, you should consider that the calibration always runs properly with a 2-dim calibration, which is the one available in current QuantLib version, and consequently in BermudanSwaption example. The incorrect behaviour is only visible if one is using a 1-dim Hull&White, which is the piece of code that you suggested me some days ago. Francesco
-----Original Message-----
At 09:05 AM 9/24/03, Perissin Francesco wrote:
Francesco,
Just curious,
This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. Banca del Gottardo (including its group companies) shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt or damage to your system. Banca del Gottardo (or its group companies) does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference. ############################################################################ |
Free forum by Nabble | Edit this page |