FunctionalVAR._nelson_siegel_basis#
- FunctionalVAR._nelson_siegel_basis()[source]#
Fix or profile the Nelson-Siegel loadings.
With a decay supplied the loadings are built once. Otherwise every grid maturity
tauproposes the decay1.79 / tauthat places the curvature loading’s peak attau, and the candidate with the smallest projection error over the whole sample wins.- Return type:
- Returns:
The loading matrix and the decay it was built at.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> maturities = np.array([0.25, 0.5, 1.0, 2.0, 3.0, 5.0, 7.0, 10.0]) >>> x = 0.6 * maturities >>> slope, curve = (1 - np.exp(-x)) / x, (1 - np.exp(-x)) / x - np.exp(-x) >>> factors = rng.standard_normal((60, 3)) * [0.2, 0.3, 0.4] + [5.0, -1.5, 0.5] >>> yields = factors @ np.column_stack([np.ones(8), slope, curve]).T >>> model = FunctionalVAR(yields, maturities, order=1, basis="nelson-siegel") >>> loadings, decay = model._nelson_siegel_basis() >>> loadings.shape, bool(abs(decay - 0.6) < 0.01) ((8, 3), True)