拟合利率曲线功能GydF4y2Ba
This example shows how to useirfunctioncurveGydF4y2Ba
对象建模利率的术语结构(也称为收益曲线)。这可以与对术语结构进行建模与日期和数据向量建模并在点之间进行插值(目前可以使用函数来完成)GydF4y2Baprbyzero
)。这term structure can refer to at least three different curves: the discount curve, zero curve, or forward curve.
这GydF4y2BairfunctioncurveGydF4y2Ba
对象允许您将利率曲线作为函数建模。GydF4y2Ba
This example explores using anirfunctioncurveGydF4y2Ba
object to model the default-free term structure of interest rates in the United Kingdom. Three different forms for the term structure are implemented and are discussed in more detail later:
nels上-s一世eGelGydF4y2Ba
斯文森GydF4y2Ba
使用所谓的可变粗糙度惩罚平滑立方样条(VRP)GydF4y2Ba
选择数据GydF4y2Ba
建模产量曲线的第一个问题是应该使用哪些数据。为了建模无默认的收益曲线,必须使用无默认的,无选项的市场仪器。数据中最重要的组成部分是英国政府债券(称为镀金)。从以下网站检索历史数据:GydF4y2Ba
回购数据用于构建收益曲线的短端。从以下网站检索回购数据:GydF4y2Ba
https://www.ukfinance.org.uk/GydF4y2Ba
还请注意,必须将数据指定为列的矩阵GydF4y2Ba定居GydF4y2Ba
,,,,GydF4y2Bamaturity
,,,,GydF4y2BaCleanpriceGydF4y2Ba
,,,,和GydF4y2BaCouponRate
该工具必须是债券或合成转换为债券的债券。GydF4y2Ba
2008年4月30日截止日期的市场数据已下载并保存到以下数据文件(GydF4y2Baukdata20080430
),通过以下命令将其加载到MATLAB®中:GydF4y2Ba
%加载数据GydF4y2Ba加载GydF4y2Baukdata20080430%将回购利率转换为同等零息债券GydF4y2BaRepoCouponrate = repmat(0,size(reporates));Repprice = BNDPRICE(重新定位,RepoCoupOnrate,Reposettle,ropranturity);GydF4y2Ba%汇总数据GydF4y2Basettle = [reposettle; bondsettle];成熟度= [ropraturity;键符];CleanPrice = [Repprice; BondCleanPrice];优惠蛋白= [RepoCoupOnrate; Bondcouponrate];仪器= [固定成熟度清洁优惠券];仪器period = [repmat(0,6,1); repmat(2,31,1)];curvesttle = datenum(GydF4y2Ba'30 -apr-2008'GydF4y2Ba);
将尼尔森 - 赛格模型适合市场数据GydF4y2Ba
Nelson-Siegel模型提出,瞬时向前曲线可以通过以下方式进行建模:GydF4y2Ba
This can be integrated to derive an equation for the zero curve (see [6] for more information on the equations and the derivation):
see[[GydF4y2Ba1GydF4y2Ba这是给予的For more information.
这GydF4y2BairfunctioncurveGydF4y2Ba
object provides the capability to fit a Nelson Siegel curve to observed market data with theF一世tnels上s一世eGelGydF4y2Ba
method. The fitting is done by calling the Optimization Toolbox™ functionLSQNONLINGydF4y2Ba
。GydF4y2Ba
这GydF4y2BaF一世tnels上s一世eGelGydF4y2Ba
功能需要曲线的输入GydF4y2BaType
,,,,Curve定居GydF4y2Ba
,,,,和a matrix of instrument data.
名称值对参数中指定的可选输入参数为:GydF4y2Ba
irfitoptionsGydF4y2Ba
structure: Provides the capability to choose which quantity to be minimized (price, yield, or duration weighted price) and other optimization parameters (for example, upper and lower bounds for parameters).Curve
Compounding
和GydF4y2Ba基础GydF4y2Ba
((day-count convention)其他仪器参数,GydF4y2Ba
period
,,,,GydF4y2Ba基础GydF4y2Ba
,,,,GydF4y2BaFirstCoupDongateGydF4y2Ba
, 等等。GydF4y2Ba
nsmodel = irfunctioncurve.fitnelsonsiegel(GydF4y2Ba'Zero',曲线,GydF4y2Ba...GydF4y2Ba仪器,,,,GydF4y2Ba'InstrumentPeriod',仪器period);GydF4y2Ba
Fit Svensson Model
一个非常类似的模型- siegel模型the Svensson model, which adds two additional parameters to account for greater flexibility in the term structure. This model proposes that the forward rate can be modeled with the following form:
As above, this can be integrated to derive an equation for the zero curve:
see[[GydF4y2Ba2GydF4y2Ba这是给予的For more information.
将参数拟合到该模型的方式与使用尼尔森 - siegel模型相似的方式进行GydF4y2BaF一世t斯文森GydF4y2Ba
功能。GydF4y2Ba
svenssonmodel = irfunctioncurve.fitsvensson(GydF4y2Ba'Zero',曲线,GydF4y2Ba...GydF4y2Ba仪器,,,,GydF4y2Ba'InstrumentPeriod',仪器period);GydF4y2Ba
Fit Smoothing Spline
这term structure can also be modeled with a spline, specifically, one way to model the term structure is by representing the forward curve with a cubic spline. To ensure that the spline is sufficiently smooth, a penalty is imposed relating to the curvature (second derivative) of the spline:
where the first term is the difference between the observed pricepGydF4y2Ba和预测的价格GydF4y2Bap_hatGydF4y2Ba,(由债券的持续时间加权,GydF4y2BadGydF4y2Ba)总结数据集中的所有债券,第二任期是罚款期(其中GydF4y2Ba兰姆达GydF4y2Ba是惩罚功能,GydF4y2BaFGydF4y2Ba是样条)。GydF4y2Ba
see[[GydF4y2Ba3GydF4y2Ba这是给予的,,,,[[GydF4y2Ba4GydF4y2Ba这是给予的,,,,[[GydF4y2Ba5GydF4y2Ba] 以下。GydF4y2Ba
这re have been different proposals for the specification of the penalty function兰姆达GydF4y2Ba。一种方法,由[GydF4y2Ba4GydF4y2Ba这是给予的,,,,和currently used by the UK Debt Management Office, is a penalty function of the following form:
参数GydF4y2BalGydF4y2Ba,,,,GydF4y2BasGydF4y2Ba,,,,和GydF4y2Bamuare typically estimated from historical data.
这GydF4y2BairfunctioncurveGydF4y2Ba
object can be used to fit a smoothing spline representation of the forward curve with a penalty function using the functionF一世tsmoothingSpline
。GydF4y2Ba
Required inputs, like for the functions above, are aCurveType
,,,,Curve定居GydF4y2Ba
,,,,GydF4y2Ba仪器GydF4y2Ba
矩阵和函数句柄(GydF4y2Balambdafun
)containing the penalty function.
这optional parameters are similar toF一世tnels上s一世eGelGydF4y2Ba
和GydF4y2BaF一世t斯文森GydF4y2Ba
。GydF4y2Ba
% Parameters chosen to be roughly similar to [4] below.l=9.2; S = -1; mu = 1; lambdafun = @(t) exp(L - (L-S)*exp(-t/mu));% Construct penalty functiont = 0:.1:25;GydF4y2Ba% Construct data to plot penalty functiony = lambdafun(t); figure semilogy(t,y); title('Penalty Function for VRP Approach')ylabel('惩罚'GydF4y2Ba)xlabel(GydF4y2Ba'时间'GydF4y2Ba)GydF4y2Ba
VRPModel = IRFunctionCurve.fitSmoothingSpline('向前'GydF4y2Ba,曲线,GydF4y2Ba...GydF4y2Ba乐器,兰巴芬,GydF4y2Ba'Compounding',,,,-1,,,,GydF4y2Ba...GydF4y2Ba'InstrumentPeriod',仪器period);GydF4y2Ba
使用合适的曲线和绘图结果GydF4y2Ba
Once a curve is created, functions are used to extract the Forward and Zero Rates and the Discount Factors. This curve can also be converted into aRatesspecGydF4y2Ba
structure using thetoRatesspecGydF4y2Ba
功能。这GydF4y2BaRatesspecGydF4y2Ba
然后可以与金融工具盒中的许多其他功能一起使用GydF4y2Ba
plottingdates = Curvesettle+20:30:Curvesettle+365*25;timetraturity =年frac(曲线,绘图日期);nsforwardrates = nsmodel.getforwardrates(plottingdates);svenssonforwardrates = svenssonmodel.getforwardrates(plottingdates);vrpforwardrates = vrpmodel.getforwardrates(plottingdates);图GydF4y2Ba上GydF4y2Ba绘图(timetraturity,nsforwardrates,GydF4y2Ba'r'GydF4y2Ba)plot(TimeToMaturity,SvenssonForwardRates,'g')绘图(timetraturity,vrpforwardrates,GydF4y2Ba'b'GydF4y2Ba)t一世tle((GydF4y2Ba'UK Instantaneous Nominal Forward Curve')xlabel(GydF4y2Ba'Years Ahead')leGend({'尼尔森·西格尔'GydF4y2Ba,,,,GydF4y2Ba'Svensson'GydF4y2Ba,,,,GydF4y2Ba'vrp'GydF4y2Ba})
与此链接进行比较GydF4y2Ba
该链接可实时了解英国发布的派生产量曲线GydF4y2Ba
https://www.bankofengland.co.uk
参考书目GydF4y2Ba
此示例基于以下论文和期刊文章:GydF4y2Ba
[[1这是给予的nels上,,,,C.R., Siegel, A.F. "Parsimonious Modelling of Yield Curves."商业杂志。GydF4y2Ba60, pp 473-89, 1987.
[2] Svensson,L.E.O。“估计和解释远期利率:瑞典1992-4。”国际货币基金组织,IMF工作文件,1994/114,1994。GydF4y2Ba
[[3这是给予的Fisher, M., Nychka, D., Zervos, D. "Fitting the Term Structure of Interest Rates with Smoothing Splines." Board of Governors of the Federal Reserve System, Federal Reserve Board Working Paper, 95-1, 1995.
[4] Anderson,N。,Sleath,J。“对英国真实和名义收益曲线的新估计。”GydF4y2Ba英格兰银行季度公告。GydF4y2Ba11月,第384-92页,1999年。GydF4y2Ba
[5] Wagoner,D。“从优惠券债券价格中提取利率曲线的样条方法。”美联储董事会工作文件,97-10,1997。GydF4y2Ba
[[6] "Zero-Coupon Yield Curves: Technical Documentation." BIS Papers No. 25, October 2005.
[7] Bolder,D.J.,Gusba,s。“指数,多项式和傅立叶系列:加拿大银行的更多产量曲线建模。”工作论文02-29,加拿大银行,2002年。GydF4y2Ba
[[8] Bolder, D.J., Streliski, D. "Yield Curve Modelling at the Bank of Canada." Technical Reports 84, Bank of Canada, 1999.