luphord / nelson_siegel_svensson

Implementation of the Nelson-Siegel-Svensson interest rate curve model.
MIT License
111 stars 41 forks source link

Negative values of tau #13

Open jakubrojcek opened 2 years ago

jakubrojcek commented 2 years ago

Description

Tau gets negative in optimization-> produces massive values for factors, least squares can't handle maturities=np.array([ 0.25 0.5 1. 2. 3. 5. 10. 30. ]) yields = np.array([ 7.80846154, 8.16153846, 8.54207692, 9.44315385, 9.78792308, 10.31846154, 10.77930769, 10.92284615])

I recommend supplying bounds in calibrate_ns_ols: opt_res = minimize(errorfn_ns_ols, x0=tau0, args=(t, y), bounds=((0.01,None),))

hsuankou commented 2 years ago

I had similar issues with nss (SVD did not converge in Linear Least Squares) but tried adding bounds (there should be two bounds for NSS) and it works now! Thanks a lot for this!

DDAAVVEE888 commented 2 years ago

Hi, i have the same problem "SVD did not converge in Linear Least Squares". I'm new in python, where do you set bounds for NSS?

DDAAVVEE888 commented 2 years ago

I solved, many thanks for the bounds recommendation!