Logo

NELSONSIEGEL

Updated 2024-02-23 21:51:30.770000

Syntax

SELECT [wctFinancial].[wct].[NELSONSIEGEL](
  <@Maturity, float,>
 ,<@B0, float,>
 ,<@B1, float,>
 ,<@B2, float,>
 ,<@Tau, float,>)

Description

Use the scalar function NELSONSIEGEL to calculate the zero coupon rate for a date from the supplied parameters. Nelson and Siegel suggested calculating the yield curve at a point using this formula:

y_{\tau}=\beta_1+\beta_2\left(\frac{1-e^{-\lambda\tau}}{\lambda\tau}\right)+\beta_3\left(\frac{1-e^{-\lambda\tau}}{\lambda\tau}-e^{-\lambda\tau}\right)

Arguments

@Tau

The fourth factor passed to the function. @Tau is an expression of type float or of a type that can be implicitly converted to float.

@B1

The second factor passed to the function. @B1 is an expression of type float or of a type that can be implicitly converted to float.

@B0

The first factor passed to the function. @B0 is an expression of type float or of a type that can be implicitly converted to float.

@B2

The third factor passed to the function. @B2 is an expression of type float or of a type that can be implicitly converted to float.

@Maturity

The amount of time, in years, to the maturity date. @Maturity is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

Use the YEARFRAC function to calculate @Maturity.

Use he NSCOEF function to calculate the @B0, @B1, @B2, and @Tau coefficients to pass into the function.

Examples

In this example, we calculate the interpolated values for maturities 1 through 30. We use the SERIESINT function to generate the interpolation points and the NSCOEF function to calculate the coefficients.

SELECT l.SeriesValue as Maturity,
       wct.NELSONSIEGEL(l.seriesvalue, --@Maturity
                        k.B0, --@B0
                        k.B1, --@B1
                        k.B2, --@B2
                        k.Tau --@Tau
       ) as Rate
  FROM wct.NSCOEF(
           'SELECT 1,0.0028 UNION ALL
SELECT 2,0.0056 UNION ALL
SELECT 3,0.0085 UNION ALL
SELECT 5,0.0164 UNION ALL
SELECT 7,0.0235 UNION ALL
SELECT 10,0.0299 UNION ALL
SELECT 20,0.0382 UNION ALL
SELECT 30,0.0406') k
 CROSS APPLY wctMath.wct.SERIESINT(1, 30, NULL, NULL, NULL) l;

This produces the following result.

{"columns":[{"field":"Maturity","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"Rate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Maturity":"1","Rate":"0.00298376016908077"},{"Maturity":"2","Rate":"0.00502183409700056"},{"Maturity":"3","Rate":"0.00882352652310086"},{"Maturity":"4","Rate":"0.0129791854798192"},{"Maturity":"5","Rate":"0.01688451200725"},{"Maturity":"6","Rate":"0.0203250711182928"},{"Maturity":"7","Rate":"0.0232655280620921"},{"Maturity":"8","Rate":"0.0257452146778906"},{"Maturity":"9","Rate":"0.0278282144583457"},{"Maturity":"10","Rate":"0.0295809000334999"},{"Maturity":"11","Rate":"0.0310629320906263"},{"Maturity":"12","Rate":"0.0323245911890544"},{"Maturity":"13","Rate":"0.0334068839430623"},{"Maturity":"14","Rate":"0.0343427004330867"},{"Maturity":"15","Rate":"0.0351582280427677"},{"Maturity":"16","Rate":"0.0358742856167667"},{"Maturity":"17","Rate":"0.0365074605874693"},{"Maturity":"18","Rate":"0.0370710301382507"},{"Maturity":"19","Rate":"0.0375756871537565"},{"Maturity":"20","Rate":"0.038030103897961"},{"Maturity":"21","Rate":"0.0384413665717732"},{"Maturity":"22","Rate":"0.0388153095955544"},{"Maturity":"23","Rate":"0.0391567730501985"},{"Maturity":"24","Rate":"0.0394698016184686"},{"Maturity":"25","Rate":"0.0397577990823069"},{"Maturity":"26","Rate":"0.0400236490213598"},{"Maturity":"27","Rate":"0.0402698097283141"},{"Maturity":"28","Rate":"0.0404983893656884"},{"Maturity":"29","Rate":"0.0407112058966696"},{"Maturity":"30","Rate":"0.0409098352100148"}]}