QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CubicBSplinesFitting Class Reference

CubicSpline B-splines fitting method. More...

#include <nonlinearfittingmethods.hpp>

+ Inheritance diagram for CubicBSplinesFitting:
+ Collaboration diagram for CubicBSplinesFitting:

Public Member Functions

 CubicBSplinesFitting (const std::vector< Time > &knotVector, bool constrainAtZero=true, const Array &weights=Array(), const ext::shared_ptr< OptimizationMethod > &optimizationMethod=ext::shared_ptr< OptimizationMethod >(), const Array &l2=Array(), Real minCutoffTime=0.0, Real maxCutoffTime=QL_MAX_REAL)
 
 CubicBSplinesFitting (const std::vector< Time > &knotVector, bool constrainAtZero, const Array &weights, const Array &l2, Real minCutoffTime=0.0, Real maxCutoffTime=QL_MAX_REAL)
 
Real basisFunction (Integer i, Time t) const
 cubic B-spline basis functions More...
 
std::unique_ptr< FittedBondDiscountCurve::FittingMethodclone () const override
 clone of the current object More...
 
- Public Member Functions inherited from FittedBondDiscountCurve::FittingMethod
virtual ~FittingMethod ()=default
 
virtual Size size () const =0
 total number of coefficients to fit/solve for More...
 
Array solution () const
 output array of results of optimization problem More...
 
Integer numberOfIterations () const
 final number of iterations used in the optimization problem More...
 
Real minimumCostValue () const
 final value of cost function after optimization More...
 
EndCriteria::Type errorCode () const
 error code of the optimization More...
 
virtual std::unique_ptr< FittingMethodclone () const =0
 clone of the current object More...
 
bool constrainAtZero () const
 return whether there is a constraint at zero More...
 
Array weights () const
 return weights being used More...
 
Array l2 () const
 return l2 penalties being used More...
 
ext::shared_ptr< OptimizationMethodoptimizationMethod () const
 return optimization method being used More...
 
DiscountFactor discount (const Array &x, Time t) const
 open discountFunction to public More...
 

Private Member Functions

Size size () const override
 total number of coefficients to fit/solve for More...
 
DiscountFactor discountFunction (const Array &x, Time t) const override
 discount function called by FittedBondDiscountCurve More...
 

Private Attributes

BSpline splines_
 
Size size_
 
Natural N_
 N_th basis function coefficient to solve for when d(0)=1. More...
 

Additional Inherited Members

- Protected Member Functions inherited from FittedBondDiscountCurve::FittingMethod
 FittingMethod (bool constrainAtZero=true, const Array &weights=Array(), ext::shared_ptr< OptimizationMethod > optimizationMethod=ext::shared_ptr< OptimizationMethod >(), Array l2=Array(), Real minCutoffTime=0.0, Real maxCutoffTime=QL_MAX_REAL)
 constructors More...
 
virtual void init ()
 rerun every time instruments/referenceDate changes More...
 
virtual DiscountFactor discountFunction (const Array &x, Time t) const =0
 discount function called by FittedBondDiscountCurve More...
 
- Protected Attributes inherited from FittedBondDiscountCurve::FittingMethod
bool constrainAtZero_
 constrains discount function to unity at \( T=0 \), if true More...
 
FittedBondDiscountCurvecurve_
 internal reference to the FittedBondDiscountCurve instance More...
 
Array solution_
 solution array found from optimization, set in calculate() More...
 
Array guessSolution_
 optional guess solution to be passed into constructor. More...
 
ext::shared_ptr< FittingCost > costFunction_
 base class sets this cost function used in the optimization routine More...
 

Detailed Description

CubicSpline B-splines fitting method.

Fits a discount function to a set of cubic B-splines \( N_{i,3}(t) \), i.e.,

\[ d(t) = \sum_{i=0}^{n} c_i * N_{i,3}(t) \]

See: McCulloch, J. 1971, "Measuring the Term Structure of Interest Rates." Journal of Business, 44: 19-31

McCulloch, J. 1975, "The tax adjusted yield curve." Journal of Finance, XXX811-30

Warning:
"The results are extremely sensitive to the number and location of the knot points, and there is no optimal way of selecting them." James, J. and N. Webber, "Interest Rate Modelling" John Wiley, 2000, pp. 440.
Examples
FittedBondCurve.cpp.

Definition at line 164 of file nonlinearfittingmethods.hpp.

Constructor & Destructor Documentation

◆ CubicBSplinesFitting() [1/2]

CubicBSplinesFitting ( const std::vector< Time > &  knotVector,
bool  constrainAtZero = true,
const Array weights = Array(),
const ext::shared_ptr< OptimizationMethod > &  optimizationMethod = ext::shared_ptr<OptimizationMethod>(),
const Array l2 = Array(),
Real  minCutoffTime = 0.0,
Real  maxCutoffTime = QL_MAX_REAL 
)

Definition at line 180 of file nonlinearfittingmethods.cpp.

+ Here is the call graph for this function:

◆ CubicBSplinesFitting() [2/2]

CubicBSplinesFitting ( const std::vector< Time > &  knotVector,
bool  constrainAtZero,
const Array weights,
const Array l2,
Real  minCutoffTime = 0.0,
Real  maxCutoffTime = QL_MAX_REAL 
)

Definition at line 211 of file nonlinearfittingmethods.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ basisFunction()

Real basisFunction ( Integer  i,
Time  t 
) const

cubic B-spline basis functions

Definition at line 240 of file nonlinearfittingmethods.cpp.

◆ clone()

std::unique_ptr< FittedBondDiscountCurve::FittingMethod > clone ( ) const
overridevirtual

clone of the current object

Implements FittedBondDiscountCurve::FittingMethod.

Definition at line 245 of file nonlinearfittingmethods.cpp.

◆ size()

Size size ( ) const
overrideprivatevirtual

total number of coefficients to fit/solve for

Implements FittedBondDiscountCurve::FittingMethod.

Definition at line 250 of file nonlinearfittingmethods.cpp.

◆ discountFunction()

DiscountFactor discountFunction ( const Array x,
Time  t 
) const
overrideprivatevirtual

discount function called by FittedBondDiscountCurve

Implements FittedBondDiscountCurve::FittingMethod.

Definition at line 254 of file nonlinearfittingmethods.cpp.

Member Data Documentation

◆ splines_

BSpline splines_
private

Definition at line 187 of file nonlinearfittingmethods.hpp.

◆ size_

Size size_
private

Definition at line 188 of file nonlinearfittingmethods.hpp.

◆ N_

Natural N_
private

N_th basis function coefficient to solve for when d(0)=1.

Definition at line 190 of file nonlinearfittingmethods.hpp.