第一个嵌入式的Nelson-Siegel
function y = NelsonSiegelFunction(m,param)
theta0=param(1);
theta1=param(2);
theta2=param(3);
lambda=param(4);
%par vector contains, respectively, theta0, theta1, theta2, and tau
%parameters are scalars
%input m can be a vector. output would then be a vector too
y=theta0+theta1*(1-exp(-m/lambda))./(m/lambda)+theta2*((1-exp(-m/lambda))./(m/lambda) - exp(-m/lambda));
end
第二个MAIN CODE: Yield Curve Simulation
%import data for the treasury yield curve
yieldData=dataset('File','yieldAndVolatility2000.csv','Delimiter',',')
%par vector contains, respectively, beta0, beta1, beta2, and tau
startPar=[1,1,1,1]
%Alias the error function with observed data and parameters.Obeserved the
%difference between market data and mod