nss
Syntax
nss(maturity, yield, [method="nss"])
Arguments
maturity is a numeric vector with negative elements, indicating the maturity (in years) of a bond.
yield is a numeric vector of the same length as maturity, indicating the bond yield.
method (optional) is a string indicating the model used. It can be:

"nss" (default): NelsonSiegelSvensson model

"ns": NelsonSiegel model
Details
Fit yield curve using NS/NSS model with NelderMead algorithm.
Return value: A dictionary with the following keyvalue pairs:

modelName: The model used.

params: The fitted model parameters.

NS model: a vector of length 4, containing β_{0}, β_{1}, β_{2}, λ.

NSS model: a vector of length 6, containing β_{0}, β_{1}, β_{2}, β_{3}, λ_{0}, λ_{1}.


fminResult: The optimization result of the NelderMead method, as detailed in the function fmin.

predict: The prediction function generated by the model. The method is
model.predict(T)
where T is the maturity in years. It returns the predicted yield with this model.
maturity = [1,2,3,4,5,8,10,15,20,25,30]
yield = [0.0039,0.0061,NULL,NULL,0.0166,NULL,0.0258,NULL,NULL,0.0332,NULL]
model = nss(maturity, yield)
model.modelName
//output: nss
model.params
//output：[0.038184469794996,0.048575389082029,0.022287414169806,0.047523360012739,1.873046195772644,0.161159907274023]
model.fminResult
/* Output:
xopt>[0.038184469794996,0.048575389082029,0.022287414169806,0.047523360012739,1.873046195772644,0.161159907274023]
fopt>5.456415848001168E9
iterations>541
fcalls>860
warnFlag>0
*/
// make predictions
model.predict([3,1])
/* Output:
[0.009904201306001,0.003891991292041]
*/