STARResult.nonlinear_state_space#
- STARResult.nonlinear_state_space(measurement_variance)[source]#
The fitted smooth-transition mean as a noisily observed state space.
The errors-in-variables reading of the fit: the latent state is the lag stack of the true series (deep enough to hold both the autoregression and the transition lag), the transition blends the two regime autoregressions by the fitted weight function – reproduced exactly, exponent clipping included – and the observation reads the current level through Gaussian measurement error of the stated variance, which is required and strictly positive because with none the model is observation-driven and filtering it is vacuous. Unlike the hard-threshold emitter this transition is smooth, so the extended and unscented filters are trustworthy readers alongside the particle filter; the initial state is diffuse at the sample mean and variance.
- Parameters:
measurement_variance (
float) – Observation noise variance the emitted system is read through, strictly positive.- Return type:
_NonlinearStateSpace- Returns:
The
NonlinearSSM.- Raises:
SpecificationError – If the variance is not strictly positive.
Example
Filtering a noisy observation of the series back toward it:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros(400) >>> for t in range(1, 400): ... w = 1.0 / (1.0 + np.exp(-10.0 * y[t - 1])) ... y[t] = (1 - w) * (0.5 + 0.6 * y[t - 1]) + w * (-0.5 - 0.6 * y[t - 1]) ... y[t] += 0.3 * rng.standard_normal() >>> ssm = LSTAR(y, order=1).fit().nonlinear_state_space(0.05) >>> ssm.k_states, ssm.k_endog (1, 1) >>> noisy = y + np.sqrt(0.05) * rng.standard_normal(400) >>> filtered = ssm.unscented_filter(noisy[:, None]).filtered_state[:, 0] >>> bool(np.mean((filtered - y) ** 2) < np.mean((noisy - y) ** 2)) True >>> ssm = LSTAR(y, order=1).fit().nonlinear_state_space(0.0) Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: measurement_variance must be strictly ...