KalmanFilterResult#

class cultivars.state_space.linear_gaussian.KalmanFilterResult(*, loglikelihood, loglikelihood_contributions, predicted_state, predicted_state_cov, filtered_state, filtered_state_cov)[source]#

Output of a linear-Gaussian forward filtering pass.

For the model of _LinearGaussianStateSpace the pass carries two conditional laws of the state through the sample, each Gaussian and so summarized by a mean and a covariance:

\[a_{t \mid t-1} = \mathbb{E}[\alpha_t \mid y_{1:t-1}], \quad P_{t \mid t-1} = \operatorname{Var}[\alpha_t \mid y_{1:t-1}], \qquad a_{t \mid t} = \mathbb{E}[\alpha_t \mid y_{1:t}], \quad P_{t \mid t} = \operatorname{Var}[\alpha_t \mid y_{1:t}].\]

They are tied together by the update and prediction steps. With the innovation \(v_t = y_t - d_t - Z_t a_{t \mid t-1}\) and its covariance \(F_t = Z_t P_{t \mid t-1} Z_t^\top + H_t\),

\[ \begin{align}\begin{aligned}a_{t \mid t} = a_{t \mid t-1} + P_{t \mid t-1} Z_t^\top F_t^{-1} v_t, \qquad P_{t \mid t} = P_{t \mid t-1} - P_{t \mid t-1} Z_t^\top F_t^{-1} Z_t P_{t \mid t-1},\\a_{t+1 \mid t} = c_t + T_t a_{t \mid t}, \qquad P_{t+1 \mid t} = T_t P_{t \mid t} T_t^\top + R_t Q_t R_t^\top.\end{aligned}\end{align} \]

predicted_state and predicted_state_cov hold the first pair, filtered_state and filtered_state_cov the second.

Variables:
  • predicted_state – One-step-ahead predicted states \(a_{t \mid t-1}\), (n, m).

  • predicted_state_cov – Predicted state covariances \(P_{t \mid t-1}\), (n, m, m).

  • filtered_state – Contemporaneously filtered states \(a_{t \mid t}\), (n, m).

  • filtered_state_cov – Filtered state covariances \(P_{t \mid t}\), (n, m, m).

See also

Attributes#

predicted_state

One-step-ahead predicted states \(a_{t \mid t-1}\), (n, m).

predicted_state_cov

Predicted state covariances \(P_{t \mid t-1}\), (n, m, m).

filtered_state

Contemporaneously filtered states \(a_{t \mid t}\), (n, m).

filtered_state_cov

Filtered state covariances \(P_{t \mid t}\), (n, m, m).

loglikelihood

Total log-likelihood of the data under the model.

loglikelihood_contributions

Per-period contributions, shape (n,).