# fitNelsonSiegel

Fit Nelson-Siegel model to bond market data

Since R2020a

## Description

example

outCurve = fitNelsonSiegel(Settle,Instruments,CleanPrice) fits a Nelson-Siegel model to bond data.

After creating a parametercurve object for outCurve, you can use the associated object functions discountfactors, zerorates, and forwardrates.

example

outCurve = fitNelsonSiegel(___,Name=Value) fits a Nelson-Siegel model to bond data using optional name-value arguments for Basis, x0, lb, and ub.

## Examples

collapse all

Define the bond data and use fininstrument to create FixedBond instrument objects.

Settle = datetime(2017,9,15);
Maturity = [datetime(2019,9,15);datetime(2021,9,15);...
datetime(2023,9,15);datetime(2026,9,7);...
datetime(2035,9,15);datetime(2047,9,15)];

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];

nInst = numel(CouponRate);
Bonds(nInst,1) = fininstrument.FinInstrument;
for ii=1:nInst
Bonds(ii) = fininstrument("FixedBond",'Maturity',Maturity(ii),...
'CouponRate',CouponRate(ii));
end

Use fitNelsonSiegel to create a parametercurve object.

NSModel = fitNelsonSiegel(Settle,Bonds,CleanPrice)
Local minimum possible.

lsqnonlin stopped because the final change in the sum of squares relative to
its initial value is less than the value of the function tolerance.
NSModel =
parametercurve with properties:

Type: "zero"
Settle: 15-Sep-2017
Compounding: -1
Basis: 0
FunctionHandle: @(t)fitF(Params,t)
Parameters: [3.5556e-08 0.0363 0.0900 16.5823]

## Input Arguments

collapse all

Settlement date, specified as a scalar datetime, string, or date character vector.

To support existing code, fitNelsonSiegel also accepts serial date numbers as inputs, but they are not recommended.

Bond instrument objects, specified as a scalar bond object or an array of bond instruments objects using FixedBond.

Data Types: object

Observed market prices, specified as a vector.

Data Types: double

### Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: NSModel = fitNelsonSiegel(Settle,Bonds,CleanPrice,Basis=4)

Since R2024a

Day count basis, specified as Basis and a scalar or a NINST-by-1 matrix.

• 0 — actual/actual

• 1 — 30/360 (SIA)

• 2 — actual/360

• 3 — actual/365

• 4 — 30/360 (PSA)

• 5 — 30/360 (ISDA)

• 6 — 30/360 (European)

• 7 — actual/365 (Japanese)

• 8 — actual/actual (ICMA)

• 9 — actual/360 (ICMA)

• 10 — actual/365 (ICMA)

• 11 — 30/360E (ICMA)

• 12 — actual/365 (ISDA)

• 13 — BUS/252

Data Types: double

Since R2024a

Initial estimate, specified as x0 and a vector.

Data Types: double

Since R2024a

Lower bound, specified as lb and a vector.

Data Types: double

Since R2024a

Upper bound, specified as ub and a vector.

Data Types: double

## Output Arguments

collapse all

Fitted Nelson-Siegel model, returned as a parametercurve object.

## Version History

Introduced in R2020a

expand all