ARNNResult.nonlinear_state_space#
- ARNNResult.nonlinear_state_space(measurement_variance)[source]#
The learned mean as a noisily observed state space.
The errors-in-variables reading of the fit: the latent state is the
order-deep lag stack of the true series, the transition applies the trained network to the stack, and the observation reads the current level through Gaussian measurement error of the stated variance – required and strictly positive, because with none the model is observation-driven and filtering it is vacuous. The network is smooth, so all three filters are available; the unscented filter avoids differencing through the network. The initial state is diffuse at the sample mean and variance. One caveat is the network’s own: outside the range of states seen in training, the learned mean is extrapolation, and so is every filtered path that wanders there.- 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(300) >>> for t in range(1, 300): ... y[t] = 0.8 * np.tanh(2.0 * y[t - 1]) + 0.3 * rng.standard_normal() >>> ssm = ARNN(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(300) >>> filtered = ssm.unscented_filter(noisy[:, None]).filtered_state[:, 0] >>> bool(np.mean((filtered - y) ** 2) < np.mean((noisy - y) ** 2)) True