DynamicNelsonSiegelResult.state_space#
- property DynamicNelsonSiegelResult.state_space: _LinearGaussianStateSpace[source]#
The fitted system, re-applicable to data it was not estimated on.
The exact linear-Gaussian emitter: its
loglikelihoodon the estimation panel reproducesllf, and filtering a different panel (or the same maturities over new dates) reads it with this fit’s factor dynamics and noise.Example
>>> import numpy as np >>> from cultivars.engine._core._polynomials import _nelson_siegel_loadings >>> rng = np.random.default_rng(0) >>> taus = np.array([0.5, 2.0, 5.0, 10.0]) >>> basis = _nelson_siegel_loadings(taus, 0.6) >>> mu = np.array([5.0, -1.5, 0.5]) >>> f = np.tile(mu, (40, 1)) >>> for t in range(1, 40): ... f[t] = mu + 0.9 * (f[t - 1] - mu) + 0.2 * rng.standard_normal(3) >>> curves = f @ basis.T + 0.05 * rng.standard_normal((40, 4)) >>> res = DynamicNelsonSiegel(curves, taus, decay=0.6).fit() >>> system = res.state_space >>> bool(abs(system.loglikelihood(curves) - res.llf) < 1e-6) True >>> system.filter(curves[:10]).filtered_state.shape (10, 3)