Corrections to G2 model attached if anyone interested.
Changes: mux_ was wrong sign. muy_ wasn't set. operator() result value was not correct c.f. Brigo & Mercurio book. Ba_[i], Bb[i] were not correctly set. Bracketing problems with setting y(x). Used larger min/max. Also changed g2::swaption to have 2 further arguments for use in integration. I've found that range = 6.0 and intervals=16 can give 1e-8 - 1e-9 accuracy. Will depend on parameters though. The range corresponds to number of standard deviations away from mux_ in the exponential part of the integration formula. Also attached swaption pricing engine for use with G2, so that usage is same as e.g. for jamshidianswaption in the bermudanswaption example. BTW, does anyone know how to set things so that additional constraints apply to the G2 parameters when fitting (outside of changing code for G2 constructor)? For example, if I wanted to set boundary conditions for a to be in range (0.0- 0.05). I can't work out how to do it otherwise. Mike -- g2.hpp (7K) Download Attachment g2.cpp (11K) Download Attachment G2Swaption.hpp (1K) Download Attachment G2Swaption.cpp (284 bytes) Download Attachment |
On 2004.06.06 23:49, [hidden email] wrote:
> Corrections to G2 model attached if anyone interested. Mike, I'm interested indeed. I'm merging your changes into CVS presently. Small question: who owns the copyright of the code? Thanks, Luigi |
Hi Luigi,
I'm new to all this, so maybe you can help me out. I've seen the copyright notices in the header files, but don't know what that means e.g. in open source software. I don't know how important it is. To me, Sad did the hard work. If I get a small acknowledgement then great, but I wouldn't cry if I didn't. BTW, is anyone looking at implementing Libor market models ? Also, referring to my previous email on constrained optimization. Would you need to add a public interface in the particular model? I see that calibrate in model.cpp has an additional optimization parameter, but I don't know how to relate that back to the model's parameters. Any ideas ? Mike Quoting Luigi Ballabio <[hidden email]>: > On 2004.06.06 23:49, [hidden email] wrote: > > Corrections to G2 model attached if anyone interested. > > Mike, > I'm interested indeed. I'm merging your changes into CVS > presently. Small question: who owns the copyright of the code? > > Thanks, > Luigi > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the one > installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Quantlib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > -- |
Hi Mike,
thank you very much for your contribution. >I've seen the copyright notices in the header files, but don't know what that >means e.g. in open source software. I don't know how important it is. It's very important. As the author you own the copyright of the code you've written, even if you do nothing to this effect. As copyright holder you have to tell the world under which license agreement your code can be used. Since you've sent the code to the QuantLib mailing list I've assumed you will adopt the QuantLib licence (http://www.quantlib.org/license.html) and I need a public confirmation about it. If you would pick up a different licence your code couldn't be merged in QuantLib. The code you've contributed is now in the QuantLib CVS "Copyright (C) 2004 Mike Parker", licensed with the QuantLib license. BTW have you tried to use Lattice2D to price Bermudan Swaption using a calibrated G2? If you check out the current QuantLib CVS you might want to look at the Bermudan example and try to integrate G2 Bermudan pricing. That Bermudan example also shows what might be a problem about G2, or simplex optimization, or simply about my understanding :( The G2 model has 5 parameters and it is calibrated to 5 European swaptions so I was expecting perfect calibration (zero errors), but this is not the case... >is anyone looking at implementing Libor market models ? Nobody I know of. ciao -- Nando |
On 2004.06.08 11:37, Ferdinando Ametrano wrote:
> That Bermudan example also shows what might be a problem about G2, or > simplex optimization, or simply about my understanding :( > The G2 model has 5 parameters and it is calibrated to 5 European > swaptions so I was expecting perfect calibration (zero errors), but > this is not the case... You'll have zero errors if the objective function of those 5 parameters is well-behaved enough to let the optimizer find the true minimum. It might as well be that in this case, the simplex is getting itself stuck in a local minimum... Bye, Luigi |
In reply to this post by mike.parkerql
On 2004.06.07 14:38, [hidden email] wrote:
> BTW, does anyone know how to set things so that additional > constraints apply to the G2 parameters when fitting (outside of > changing code for G2 constructor)? > For example, if I wanted to set boundary conditions for a to be in > range (0.0-0.05). I can"t work out how to do it otherwise. > Would you need to add a public interface in the particular model? I > see that calibrate in model.cpp has an additional optimization > parameter, but I don't know how to relate that back to the model's > parameters. Any ideas ? Mike, it's a bit of work, but it can be done. You'll have to define your own specific constraint first, as in: class AConstraint : public Constraint { private: class Impl : public Constraint::Impl { public: Impl(Real low, Real high) : low_(low), high_(high) {} bool test(const Array& params) const { // a is parameter # 0 in G2 return ((params[0] > low_) && (params[0] < high_)) } private: Real low_, high_; }; public: AConstraint(Real low, Real high) : Constraint(boost::shared_ptr<Constraint::Impl>( new AConstraint::Impl(low, high))) {} }; There's a bit of machinery involved---mainly because Constraint is implemented via the Strategy pattern, which might or might not be the right choice in this case---but the point is that test() should return true if the parameters satisfy the desired constraints and false otherwise. You can easily extend the above so that it checks more parameters. Afterwards, you should be able to do G2 model(...); model.calibrate(helpers, method, AConstraint(0.0,0.05)); and the calibration should take into account your constraint besides the ones intrinsic to the model. Hope this helps, Luigi |
Thanks Luigi,
I'm still leaning towards requiring some public constraint interface. The contraints are hidden at the moment + it is difficult to add multiple constraints (my 2 australs). A model would have a list of constraints. A constraint would have a constraint type (boundary, positive, none, addition, subtraction, multiplication etc.) and a parameter list (unary, binary). Please let me know if I'm talking trash. Mike Quoting Luigi Ballabio <[hidden email]>: > On 2004.06.07 14:38, [hidden email] wrote: > > BTW, does anyone know how to set things so that additional > > constraints apply to the G2 parameters when fitting (outside of > > changing code for G2 constructor)? > > For example, if I wanted to set boundary conditions for a to be in > > range (0.0-0.05). I can"t work out how to do it otherwise. > > > Would you need to add a public interface in the particular model? I > > see that calibrate in model.cpp has an additional optimization > > parameter, but I don't know how to relate that back to the model's > > parameters. Any ideas ? > > Mike, > it's a bit of work, but it can be done. You'll have to define > your own specific constraint first, as in: > > class AConstraint : public Constraint { > private: > class Impl : public Constraint::Impl { > public: > Impl(Real low, Real high) > : low_(low), high_(high) {} > bool test(const Array& params) const { > // a is parameter # 0 in G2 > return ((params[0] > low_) && (params[0] < high_)) > } > private: > Real low_, high_; > }; > public: > AConstraint(Real low, Real high) > : Constraint(boost::shared_ptr<Constraint::Impl>( > new AConstraint::Impl(low, high))) {} > }; > > There's a bit of machinery involved---mainly because Constraint is > implemented via the Strategy pattern, which might or might not be the > right choice in this case---but the point is that test() should return > true if the parameters satisfy the desired constraints and false > otherwise. You can easily extend the above so that it checks more > parameters. > > Afterwards, you should be able to do > > G2 model(...); > model.calibrate(helpers, method, AConstraint(0.0,0.05)); > > and the calibration should take into account your constraint besides > the ones intrinsic to the model. > > Hope this helps, > Luigi > -- |
Hi,
On 2004.06.15 02:16, [hidden email] wrote: > I'm still leaning towards requiring some public constraint interface. You mean, other than the one provided for passing an additional constraint to calibrate? > The contraints are hidden at the moment + it is difficult to add > multiple constraints (my 2 australs). Well, the intrinsic constraints are hidden because they're not supposed to be tampered with. When calling calibrate(), you can add an additional constraint; multiple constraints can be collapsed into one by using CompositeConstraint. > A model would have a list of constraints. A constraint would have a > constraint type (boundary, positive, none, addition, subtraction, > multiplication etc.) and a parameter list (unary, binary). > Please let me know if I'm talking trash. No, it's not trash---but you can do it already. Later, Luigi |
In reply to this post by mike.parkerql
Hi Luigi,
Yeah, I know you have a composite constraint but I was wondering how you would implement a constraint like a+b <> 0 ? Can you do this with the current constraint classes ? Also, there may be other constraints that someone may wish to impose, on top of the base constraints imposed by a particular model. e.g. I may want to restrict the drift (not necessarily risk-neutral) to lie between certain bounds. This points to an additional public interface. Mike p.s. I owe(?) some code for G2++ and simulated annealing. Apologies, but other things have taken precedence. Are there any deadlines coming up? Quoting Luigi Ballabio <[hidden email]>: > > Hi, > > On 2004.06.15 02:16, [hidden email] wrote: > > I'm still leaning towards requiring some public constraint interface. > > You mean, other than the one provided for passing an additional > constraint to calibrate? > > > The contraints are hidden at the moment + it is difficult to add > > multiple constraints (my 2 australs). > > Well, the intrinsic constraints are hidden because they're not supposed > to be tampered with. When calling calibrate(), you can add an > additional constraint; multiple constraints can be collapsed into one > by using CompositeConstraint. > > > A model would have a list of constraints. A constraint would have a > > constraint type (boundary, positive, none, addition, subtraction, > > multiplication etc.) and a parameter list (unary, binary). > > Please let me know if I'm talking trash. > > No, it's not trash---but you can do it already. > > Later, > Luigi > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Quantlib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > -- |
Free forum by Nabble | Edit this page |