Nelson-Siegel function using IRFunctionCurve.fitNelsonSiegel
5 views (last 30 days)
Show older comments
The below coding is an example for coding under "Fit Nelson-Siegel function to bond market data". The only change I did to this is that:
line one: settle date 30- Apr-2008 changed to 30-Apr-2000 lin ten : set the same date 30-Apr-2000
Bassically what I did is chaging the date that we estimate the in model. I got the codings from the below link: http://uk.mathworks.com/help/fininst/fitnelsonsiegelirfunctioncurve.html?nocookie=true
But if you run this code, the relevant NS parameters and the graph goes totally away from the data points. It doesn't looks like the function " IRFunctionCurve.fitNelsonSiegel" working properly. Could anyone give suggestion for this please .
The example give in the URL used settle date '30-Apr-2008' and if we give a date closer to this date, it closely fit the curve. But, if we give a date few years away, the fitted curve is totally away from the datapoints. This looks like the function only works if we give a settle date closer to lowest maturity date, which is 07-Mar-2009 in this case.
The below are the codings:
Settle = repmat(datenum('30-Apr-2000'),[6 1]); Maturity = [datenum('07-Mar-2009');datenum('07-Mar-2011');... datenum('07-Mar-2013');datenum('07-Sep-2016');... datenum('07-Mar-2025');datenum('07-Mar-2036')];
CleanPrice = [100.1;100.1;100.8;96.6;103.3;96.3]; CouponRate = [0.0400;0.0425;0.0450;0.0400;0.0500;0.0425]; Instruments = [Settle Maturity CleanPrice CouponRate]; PlottingPoints = datenum('07-Mar-2009'):180:datenum('07-Mar-2036'); Yield = bndyield(CleanPrice,CouponRate,Settle,Maturity);
NSModel = IRFunctionCurve.fitNelsonSiegel('Zero',datenum('30-Apr-2000'),Instruments);
NSModel.Parameters
% create the plot plot(PlottingPoints, getParYields(NSModel, PlottingPoints),'r') hold on scatter(Maturity,Yield,'black') datetick('x')
0 Comments
Answers (0)
See Also
Categories
Find more on Yield Curves in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!