|
From: Javit H. <ch...@vi...> - 2010-05-27 17:04:10
|
Alexander,
I believe Luigi forgot to change the generalized HW code when he made the
change in the parameter class to include the positive constraint. Your point
for the "size()" vs "size()+1" is valid.
I didn't notice anything because I still use the older version of GHW with
quantlib 9.7.
Per the tests, I tested the GHW code and it worked when I submitted. I ran
my tests by adding couple of lines into BermudanSwaption.cpp I used only two
timepoints for the volatility and the reversion parameters. It takes
significantly long if you include more time points. I would suggest both
decreasing the timegrid and the timepoints (let me know if you don't
understand what I meant here by timepoints) to decrease the optimization
time. And once optimized, initiate your next search with the most recent
model parameters.
Luigi, please let me know if you would like me to get involved also.
Thank you,
Javit
Alexander Lotter wrote:
>
> Hello Luigi,
>
> thanks for the quick reply.
>
>>The PiecewiseConstantParameter class was modified in revision 17224 to
>>take an optional constraint, so that's taken care of; the code in the
>>trunk instantiates it with a PositiveConstraint.
>
> I am not sure this is enough. This peace of code in QL causes problems:
>
> ----
> PiecewiseConstantParameter(const std::vector<Time>& times,
> const Constraint& constraint =
>
> NoConstraint())
> : Parameter(times.size()+1,
> boost::shared_ptr<Parameter::Impl>(
> new
> PiecewiseConstantParameter::Impl(times)),
> constraint)
> {}
> ----
>
> should be
>
> ----
> public:
> PiecewiseConstantParameter(const std::vector<Time>& times,
> const Constraint& constraint =
>
> NoConstraint())
> : Parameter(times.size(),
> ----
>
> times.size() not times.size() + 1, in this case I get run time exception
> in the following functions
>
> ---
>
> boost::function<Real (Time)> GeneralizedHullWhite::speed() const {
>
> std::vector<Real> speedvals;
> speedvals.push_back(a_(0.0001));
> for (Size i=0;i<a_.size()-1;i++)
> speedvals.push_back(
> a_(
> (speedstructure_[i+1]-speedstructure_[0])/365.0
> - 0.00001));
>
> return PiecewiseLinearCurve(speedperiods_, speedvals);
> }
>
> boost::function<Real (Time)> GeneralizedHullWhite::vol() const {
>
> std::vector<Real> volvals;
> volvals.push_back(sigma_(0.0001));
> for (Size i=0;i<sigma_.size()-1;i++)
> volvals.push_back(
> sigma_(
> (speedstructure_[i+1]-speedstructure_[0])/365.0
> - 0.00001));
>
> return PiecewiseLinearCurve(volperiods_, volvals);
> }
> ---
>
> vector subscript out of range
>
> a_.size() - 1 and sigma_.size() - 1 are bigger than speedstructure_[i+1]
>
>
--
View this message in context: http://old.nabble.com/Generalized-Hull-White-model-problems-tp28647789p28697165.html
Sent from the quantlib-dev mailing list archive at Nabble.com.
|