LinearGaussianSSM#

class cultivars.state_space.linear_gaussian.LinearGaussianSSM(design, obs_cov, transition, selection, state_cov, *, obs_intercept=None, state_intercept=None, initial_state=None, initial_state_cov=None)[source]#

A linear-Gaussian state-space model.

The model is, in the notation of Durbin and Koopman (2012),

\[ \begin{align}\begin{aligned}y_t = d_t + Z_t \alpha_t + \varepsilon_t, \qquad \varepsilon_t \sim \mathcal{N}(0, H_t),\\\alpha_{t+1} = c_t + T_t \alpha_t + R_t \eta_t, \qquad \eta_t \sim \mathcal{N}(0, Q_t),\\\alpha_1 \sim \mathcal{N}(a_1, P_1),\end{aligned}\end{align} \]

with \(y_t\) of dimension \(p\), the state \(\alpha_t\) of dimension \(m\) and the state disturbance \(\eta_t\) of dimension \(r \le m\). The disturbances are mutually and serially uncorrelated and uncorrelated with \(\alpha_1\). Every system matrix is either constant or supplied with a leading time axis of length \(n\).

Because the model is linear and Gaussian, the conditional law of the state given any stretch of the sample is Gaussian, so two moments describe it completely. filter() returns them given the past and the present, smooth() given the whole sample, and loglikelihood() is the prediction-error decomposition

\[\log L = -\frac{1}{2} \sum_{t=1}^{n} \Bigl( p \log 2\pi + \log \det F_t + v_t^\top F_t^{-1} v_t \Bigr), \qquad v_t = y_t - d_t - Z_t a_{t \mid t-1}, \quad F_t = Z_t P_{t \mid t-1} Z_t^\top + H_t,\]

that the filter produces as a by-product.

Parameters:
  • design (ArrayLike) – Observation matrix \(Z\); shape (p, m) or (n, p, m).

  • obs_cov (ArrayLike) – Observation noise covariance \(H\); shape (p, p) or (n, p, p).

  • transition (ArrayLike) – State transition matrix \(T\); shape (m, m) or (n, m, m).

  • selection (ArrayLike) – State disturbance selection \(R\); shape (m, r) or (n, m, r).

  • state_cov (ArrayLike) – State disturbance covariance \(Q\); shape (r, r) or (n, r, r).

  • obs_intercept (ArrayLike | None) – Observation intercept d; shape (p,) or (n, p). Defaults to zero.

  • state_intercept (ArrayLike | None) – State intercept c; shape (m,) or (n, m). Defaults to zero.

  • initial_state (ArrayLike | None) – Prior mean \(a_1\); shape (m,). Defaults to zero.

  • initial_state_cov (ArrayLike | None) – Prior covariance \(P_1\); shape (m, m). Defaults to the stationary covariance when the model is time-invariant and stable, otherwise a large diffuse covariance.

Raises:
  • DimensionError – If any system matrix has an inconsistent shape or rank.

  • NumericalError – If any system matrix contains non-finite values.

See also

  • LinearGaussianSSM – the public name of this class.

  • MFVAR._state_space() – returns an instance.

  • LongMemorySVResult.quasi_state_space() – returns an instance.

  • LinearGaussianSSM._from_arma() – returns an instance.

  • LinearGaussianSSM._from_nelson_siegel_system() – returns an instance.

Attributes#

k_endog

Observation dimension p (number of observed series).

k_posdef

State disturbance dimension \(r\).

k_states

State dimension \(m\).

Methods#

filter(y)

Run the Kalman filter over the observation matrix.

loglikelihood(y)

Return the total Gaussian log-likelihood of the data.

mixed_frequency_state_space(coefficients, ...)

Put a latent high-frequency autoregression into observable form.

simulate(n, *[, seed])

Draw a length-n observation path from the model.

simulation_smoother(y, *[, n_sims, seed])

Draw states from \(p(\alpha \mid y)\) via the Durbin-Koopman (2002) smoother.

smooth(y)

Run the Durbin-Koopman state smoother.

stationary_covariance(transition, selection, ...)

Solve the discrete Lyapunov equation for the stationary state covariance.